Class: Cult::Artifact
- Inherits:
-
Object
- Object
- Cult::Artifact
- Includes:
- SingletonInstances, Transferable
- Defined in:
- lib/cult/artifact.rb
Overview
I’d love to just call this “File”, but the ambiguity with ::File would make it a pain.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(role, path) ⇒ Artifact
constructor
A new instance of Artifact.
- #inspect ⇒ Object (also: #to_s)
- #relative_path ⇒ Object
Methods included from SingletonInstances
Methods included from Transferable
#binary?, #collection_name, #contents, #file_mode, included, #name, #remote_path, #role_relative_path
Constructor Details
#initialize(role, path) ⇒ Artifact
Returns a new instance of Artifact.
24 25 26 27 |
# File 'lib/cult/artifact.rb', line 24 def initialize(role, path) @role = role @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/cult/artifact.rb', line 21 def path @path end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
22 23 24 |
# File 'lib/cult/artifact.rb', line 22 def role @role end |
Class Method Details
.all_for_role(project, role) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/cult/artifact.rb', line 36 def self.all_for_role(project, role) Dir.glob(File.join(role.path, "files", "**/*")).map do |filename| next if File.directory?(filename) new(role, filename).tap do |new_file| yield new_file if block_given? end end.compact.to_named_array end |
.collection_name ⇒ Object
11 12 13 |
# File 'lib/cult/artifact.rb', line 11 def self.collection_name "files" end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
30 31 32 |
# File 'lib/cult/artifact.rb', line 30 def inspect "\#<#{self.class.name} role:#{role&.name.inspect} name:#{name.inspect}>" end |
#relative_path ⇒ Object
16 17 18 |
# File 'lib/cult/artifact.rb', line 16 def relative_path name end |