class Packwerk::Package
Constants
- ROOT_PACKAGE_NAME
Attributes
dependencies[R]
name[R]
Public Class Methods
new(name:, config:)
click to toggle source
# File lib/packwerk/package.rb, line 12 def initialize(name:, config:) @name = name @config = config || {} @dependencies = Array(@config["dependencies"]).freeze end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/packwerk/package.rb, line 58 def <=>(other) return nil unless other.is_a?(self.class) name <=> other.name end
dependency?(package)
click to toggle source
# File lib/packwerk/package.rb, line 26 def dependency?(package) @dependencies.include?(package.name) end
enforce_dependencies?()
click to toggle source
# File lib/packwerk/package.rb, line 22 def enforce_dependencies? @config["enforce_dependencies"] == true end
enforce_privacy()
click to toggle source
# File lib/packwerk/package.rb, line 18 def enforce_privacy @config["enforce_privacy"] end
eql?(other)
click to toggle source
# File lib/packwerk/package.rb, line 63 def eql?(other) self == other end
hash()
click to toggle source
# File lib/packwerk/package.rb, line 67 def hash name.hash end
package_path?(path)
click to toggle source
# File lib/packwerk/package.rb, line 30 def package_path?(path) return true if root? path.start_with?(@name) end
public_path()
click to toggle source
# File lib/packwerk/package.rb, line 35 def public_path @public_path ||= begin unprefixed_public_path = user_defined_public_path || "app/public/" if root? unprefixed_public_path else File.join(@name, unprefixed_public_path) end end end
public_path?(path)
click to toggle source
# File lib/packwerk/package.rb, line 47 def public_path?(path) path.start_with?(public_path) end
root?()
click to toggle source
# File lib/packwerk/package.rb, line 75 def root? @name == ROOT_PACKAGE_NAME end
to_s()
click to toggle source
# File lib/packwerk/package.rb, line 71 def to_s name end
user_defined_public_path()
click to toggle source
# File lib/packwerk/package.rb, line 51 def user_defined_public_path return unless @config["public_path"] return @config["public_path"] if @config["public_path"].end_with?("/") @config["public_path"] + "/" end