lib/bpm/package.rb in bpm-1.0.0.beta.4 vs lib/bpm/package.rb in bpm-1.0.0.beta.5
- old
+ new
@@ -17,10 +17,11 @@
"version" => :string,
"description" => :string,
"author" => :string,
"homepage" => :string,
"summary" => :string,
+ "url" => :string,
"dependencies" => :hash,
"dependencies:development" => :hash,
"bpm:build" => :hash,
"bpm:formats" => :hash,
"bpm:transport" => :string,
@@ -29,16 +30,16 @@
}
PLUGIN_FIELDS = %w[bpm:formats bpm:minifier bpm:transport bpm:use:transport]
# Fields that can be loaded straight into the gemspec
- SPEC_FIELDS = %w[name email homepage summary description]
+ SPEC_FIELDS = %w[name email]
# Fields that should be bundled up into JSON in the gemspec
METADATA_FIELDS = %w[keywords licenses engines main bin directories pipeline bpm:build bpm:formats bpm:transport]
- REQUIRED_FIELDS = %w[name description summary homepage author version directories]
+ REQUIRED_FIELDS = %w[name author version]
attr_accessor *FIELDS.keys.map{|f| f.gsub(':', '_') }
attr_accessor :json_path, :email
attr_reader :root_path, :errors
@@ -72,10 +73,14 @@
spec.test_files = glob_files(tests_path)
spec.bindir = bin_path
spec.licenses = licenses.map{|l| l["type"]}
spec.executables = bin_files.map{|p| File.basename(p) } if bin_path
+ spec.homepage = homepage || url
+ spec.description = description || summary
+ spec.summary = summary || description
+
metadata = Hash[METADATA_FIELDS.map{|f| [f, send(c2u(f)) ] }]
spec.requirements = [metadata.to_json]
# TODO: Is this right?
spec.rubyforge_project = "bpm"
@@ -134,11 +139,10 @@
end
build_names += PLUGIN_FIELDS.map do |field_name|
val = self.send(c2u(field_name))
val = val && val =~ /^#{name}\// ? val[name.size+1..-1]+'.js' : nil
- puts "FIELD: #{field_name} #{self.send(c2u(field_name))} val=#{val}"
val
end
(dir_names+build_names).flatten.compact.uniq.map do |dir|
glob_files(dir)
@@ -189,11 +193,11 @@
end
# Returns a hash of dependencies inferred from the build settings.
def dependencies_build
ret = {}
-
+
bpm_build.each do |target_name, opts|
next unless opts.is_a?(Hash)
minifier = opts['minifier']
case minifier
@@ -219,11 +223,11 @@
end
generator
end
def validate
- validate_fields && validate_version && validate_paths
+ validate_fields && validate_version && validate_paths && validate_summary && validate_homepage
end
def valid?
load_json && validate
end
@@ -388,9 +392,17 @@
true
end
end
end
+ def validate_summary
+ summary || description
+ end
+
+ def validate_homepage
+ homepage || url
+ end
+
def add_error(message)
self.errors << message
end
def glob_files(path)