Class: Vendor::VendorSpec::Builder
- Inherits:
-
Object
- Object
- Vendor::VendorSpec::Builder
- Defined in:
- lib/vendor/vendor_spec/builder.rb
Defined Under Namespace
Classes: NoFilesError
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#vendor_spec ⇒ Object
readonly
Returns the value of attribute vendor_spec.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(vendor_spec) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(vendor_spec) ⇒ Builder
Returns a new instance of Builder.
19 20 21 22 23 24 25 26 |
# File 'lib/vendor/vendor_spec/builder.rb', line 19 def initialize(vendor_spec) @folder = File.(File.join(vendor_spec, '..')) @vendor_spec = Vendor::Spec.load vendor_spec @name = safe_filename(@vendor_spec.name) @version = safe_filename(@vendor_spec.version) @filename = "#{@name}-#{@version}.vendor" end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
16 17 18 |
# File 'lib/vendor/vendor_spec/builder.rb', line 16 def filename @filename end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/vendor/vendor_spec/builder.rb', line 14 def name @name end |
#vendor_spec ⇒ Object (readonly)
Returns the value of attribute vendor_spec.
17 18 19 |
# File 'lib/vendor/vendor_spec/builder.rb', line 17 def vendor_spec @vendor_spec end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/vendor/vendor_spec/builder.rb', line 15 def version @version end |
Instance Method Details
#build ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vendor/vendor_spec/builder.rb', line 28 def build tmpdir = Dir.mktmpdir(@filename) vendor_file = File.join(tmpdir, "vendor.json") data_dir = File.join(tmpdir, "data") data_files = copy_files(data_dir) open(vendor_file, 'w+') { |f| f << @vendor_spec.to_json } FileUtils.rm(@filename) if File.exist?(@filename) zip_file @filename, [ vendor_file, *data_files ], tmpdir true end |