Class: Spade::Package
- Inherits:
-
Object
- Object
- Spade::Package
- Defined in:
- lib/spade/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.
9 10 11 |
# File 'lib/spade/package.rb', line 9 def initialize(email = "") @email = email end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/spade/package.rb', line 6 def attributes @attributes end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
6 7 8 |
# File 'lib/spade/package.rb', line 6 def dependencies @dependencies end |
#directories ⇒ Object
Returns the value of attribute directories.
6 7 8 |
# File 'lib/spade/package.rb', line 6 def directories @directories end |
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/spade/package.rb', line 6 def errors @errors end |
#json_path ⇒ Object
Returns the value of attribute json_path.
6 7 8 |
# File 'lib/spade/package.rb', line 6 def json_path @json_path end |
#lib_path=(value) ⇒ Object
Sets the attribute lib_path
6 7 8 |
# File 'lib/spade/package.rb', line 6 def lib_path=(value) @lib_path = value end |
#metadata ⇒ Object
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/spade/package.rb', line 6 def @metadata end |
#test_path=(value) ⇒ Object
Sets the attribute test_path
6 7 8 |
# File 'lib/spade/package.rb', line 6 def test_path=(value) @test_path = value end |
Instance Method Details
#as_json(options = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/spade/package.rb', line 41 def as_json( = {}) json = self..clone FIELDS.each{|key| json[key] = send(key)} json["dependencies"] = self.dependencies json end |
#spade=(path) ⇒ Object
13 14 15 16 |
# File 'lib/spade/package.rb', line 13 def spade=(path) format = Gem::Format.from_file_by_path(path) fill_from_gemspec(format.spec) end |
#to_ext ⇒ Object
52 53 54 |
# File 'lib/spade/package.rb', line 52 def to_ext "#{self.to_full_name}.#{EXT}" end |
#to_full_name ⇒ Object
48 49 50 |
# File 'lib/spade/package.rb', line 48 def to_full_name "#{name}-#{version}" end |
#to_spec ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/spade/package.rb', line 18 def to_spec return unless valid? Gem::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
64 65 66 |
# File 'lib/spade/package.rb', line 64 def valid? read && parse && validate end |
#validate ⇒ Object
60 61 62 |
# File 'lib/spade/package.rb', line 60 def validate validate_fields && validate_version && validate_paths end |