Class: Spade::Packager::Package
- Inherits:
-
Object
- Object
- Spade::Packager::Package
- Defined in:
- lib/spade/packager/package.rb
Constant Summary collapse
- EXT =
"spd"
- METADATA =
%w[keywords licenses engines main bin directories]
- FIELDS =
%w[name version description author homepage summary]
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#directories ⇒ Object
Returns the value of attribute directories.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#json_path ⇒ Object
Returns the value of attribute json_path.
-
#lib_path ⇒ Object
writeonly
Sets the attribute lib_path.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#test_path ⇒ Object
writeonly
Sets the attribute test_path.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(email = "") ⇒ Package
constructor
A new instance of Package.
- #spade=(path) ⇒ Object
- #to_ext ⇒ Object
- #to_full_name ⇒ Object
- #to_spec ⇒ Object
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(email = "") ⇒ Package
Returns a new instance of Package.
11 12 13 |
# File 'lib/spade/packager/package.rb', line 11 def initialize(email = "") @email = email end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def attributes @attributes end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def dependencies @dependencies end |
#directories ⇒ Object
Returns the value of attribute directories.
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def directories @directories end |
#errors ⇒ Object
Returns the value of attribute errors.
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def errors @errors end |
#json_path ⇒ Object
Returns the value of attribute json_path.
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def json_path @json_path end |
#lib_path=(value) ⇒ Object
Sets the attribute lib_path
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def lib_path=(value) @lib_path = value end |
#metadata ⇒ Object
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def @metadata end |
#test_path=(value) ⇒ Object
Sets the attribute test_path
8 9 10 |
# File 'lib/spade/packager/package.rb', line 8 def test_path=(value) @test_path = value end |
Instance Method Details
#as_json(options = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/spade/packager/package.rb', line 43 def as_json( = {}) json = self..clone FIELDS.each{|key| json[key] = send(key)} json["dependencies"] = self.dependencies json end |
#spade=(path) ⇒ Object
15 16 17 18 |
# File 'lib/spade/packager/package.rb', line 15 def spade=(path) format = LibGems::Format.from_file_by_path(path) fill_from_gemspec(format.spec) end |
#to_ext ⇒ Object
54 55 56 |
# File 'lib/spade/packager/package.rb', line 54 def to_ext "#{self.to_full_name}.#{EXT}" end |
#to_full_name ⇒ Object
50 51 52 |
# File 'lib/spade/packager/package.rb', line 50 def to_full_name "#{name}-#{version}" end |
#to_spec ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/spade/packager/package.rb', line 20 def to_spec return unless valid? LibGems::Specification.new do |spec| spec.name = name spec.version = version spec. = [] spec.email = @email spec.homepage = homepage spec.summary = summary spec.description = description spec.requirements = [.to_json] spec.files = directory_files + ["package.json"] spec.test_files = glob_files(test_path) if test_path spec.bindir = bin_path spec.executables = bin_files.map{|p| File.basename(p) } if bin_path spec.rubyforge_project = "spade" def spec.file_name "#{full_name}.#{EXT}" end dependencies.each{|d,v| spec.add_dependency(d, v) } if dependencies end end |
#valid? ⇒ Boolean
66 67 68 |
# File 'lib/spade/packager/package.rb', line 66 def valid? read && parse && validate end |
#validate ⇒ Object
62 63 64 |
# File 'lib/spade/packager/package.rb', line 62 def validate validate_fields && validate_version && validate_paths end |