lib/jsus/source_file.rb in jsus-0.1.3 vs lib/jsus/source_file.rb in jsus-0.1.4

- old
+ new

@@ -1,8 +1,7 @@ module Jsus class SourceFile - attr_accessor :header attr_accessor :relative_filename attr_accessor :filename attr_accessor :content attr_accessor :package # constructors @@ -33,31 +32,50 @@ nil end end # Public API - def dependencies(options = {}) - header["requires"] = [header["requires"] || []].flatten - header["requires"].map! {|r| r.gsub(/^\//, "") } + def header=(new_header) + @header = new_header + # prepare defaults + @header["description"] ||= "" + @header["requires"] = [@header["requires"] || []].flatten + @header["requires"].map! {|r| r.gsub(/^(\.)?\//, "") } + @header["provides"] = [@header["provides"] || []].flatten + end + + def header + self.header = {} unless @header + @header + end + + def dependencies(options = {}) if !options[:short] && package header["requires"].map {|r| r.index("/") ? r : "#{package.name}/#{r}"} else header["requires"] end end alias_method :requires, :dependencies - def provides(options = {}) - header["provides"] = [header["provides"] || []].flatten + def external_dependencies + dependencies(:short => true).select {|d| d.index("/") } + end + + def internal_dependencies + dependencies(:short => true) - external_dependencies + end + + def provides(options = {}) if !options[:short] && package header["provides"].map {|p| "#{package.name}/#{p}"} else header["provides"] end end def description - header["description"] ||= "" + header["description"] end def to_hash { "desc" => description, \ No newline at end of file