lib/java/artifact.rb in buildr-0.20.0 vs lib/java/artifact.rb in buildr-0.21.0

- old
+ new

@@ -27,11 +27,11 @@ # The artifact identifier. attr_reader :id # The group identifier. attr_reader :group - # The file type. + # The file type. (Symbol) attr_reader :type # The version number. attr_reader :version # Optional artifact classifier. attr_reader :classifier @@ -42,11 +42,11 @@ # Returns the artifact specification as a hash. For example: # com.example:app:jar:1.2 # becomes: # { :group=>"com.example", # :id=>"app", - # :type=>"jar", + # :type=>:jar, # :version=>"1.2" } def to_spec_hash() base = { :group=>group, :id=>id, :type=>type, :version=>version } classifier.blank? ? base : base.merge(:classifier=>classifier) end @@ -66,12 +66,12 @@ # :call-seq: # pom() => Artifact # # Convenience method that returns a POM artifact. def pom() - return self if type.to_s == "pom" - artifact(:group=>group, :id=>id, :version=>version, :type=>"pom", :classifier=>classifier) + return self if type == :pom + artifact(:group=>group, :id=>id, :version=>version, :type=>:pom, :classifier=>classifier) end protected # Apply specification to this artifact. @@ -92,12 +92,12 @@ # # Note: You can enhance this task to create the artifact yourself, e.g. download it from # a site that doesn't have a remote repository structure, copy it from a different disk, etc. class Artifact < Rake::FileCreationTask - # The default file type for artifacts, if not specified. - DEFAULT_FILE_TYPE = "jar" + # The default artifact type. + DEFAULT_TYPE = :jar include ActsAsArtifact class << self @@ -140,11 +140,11 @@ # Sanitize the hash and check it's valid. spec = ARTIFACT_ATTRIBUTES.inject({}) { |h, k| h[k] = spec[k].to_s if spec[k] ; h } fail "Missing group identifier for #{spec.inspect}" if spec[:group].blank? fail "Missing artifact identifier for #{spec.inspect}" if spec[:id].blank? fail "Missing version for #{spec.inspect}" if spec[:version].blank? - spec[:type] = DEFAULT_FILE_TYPE if spec[:type].blank? + spec[:type] = spec[:type].blank? ? DEFAULT_TYPE : spec[:type].to_sym spec elsif String === spec group, id, type, version, *rest = spec.split(":") unless rest.empty? # Optional classifier comes before version. @@ -164,20 +164,20 @@ # a string, hash or any object that responds to to_spec. def to_spec(hash) hash = to_hash(hash) unless Hash === hash version = ":#{hash[:version]}" unless hash[:version].blank? classifier = ":#{hash[:classifier]}" unless hash[:classifier].blank? - "#{hash[:group]}:#{hash[:id]}:#{hash[:type] || DEFAULT_FILE_TYPE}#{classifier}#{version}" + "#{hash[:group]}:#{hash[:id]}:#{hash[:type] || DEFAULT_TYPE}#{classifier}#{version}" end # :call-seq: # hash_to_file_name(spec_hash) => file_name # # Convert a hash spec to a file name. def hash_to_file_name(hash) version = "-#{hash[:version]}" unless hash[:version].blank? classifier = "-#{hash[:classifier]}" unless hash[:classifier].blank? - "#{hash[:id]}#{version}#{classifier}.#{hash[:type] || DEFAULT_FILE_TYPE}" + "#{hash[:id]}#{version}#{classifier}.#{hash[:type] || DEFAULT_TYPE}" end end def initialize(*args) #:nodoc: