lib/kde_frameworks_creator.rb in inqlude-0.10.0 vs lib/kde_frameworks_creator.rb in inqlude-0.11.0

- old
+ new

@@ -15,46 +15,46 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class KdeFrameworksCreator attr_reader :warnings, :errors - + def initialize @frameworks = Hash.new @warnings = [] @errors = [] end - + def parse_checkout dir_name, options = {} @warnings = [] @errors = [] Dir.entries( dir_name ).each do |entry| next if entry =~ /^\./ next if entry == "kapidox" next if entry == "kde4support" next if !File.exist?(File.join(dir_name, entry, ".git")) - + @frameworks[entry] = {} parse_readme File.join(dir_name,entry), options parse_metainfo File.join(dir_name,entry) parse_authors File.join(dir_name,entry) end end def frameworks @frameworks.keys end - + def framework name f = @frameworks[name] raise InqludeError.new("Unable to read '#{name}'") if !f f end - + def parse_readme path, options = {} @errors = [] if !@errors - + name = extract_name( path ) framework = @frameworks[name] || {} framework["link_home_page"] = "http://api.kde.org/frameworks-api/frameworks5-apidocs/#{name}/html/index.html" framework["link_mailing_list"] = "https://mail.kde.org/mailman/listinfo/kde-frameworks-devel" @@ -65,11 +65,11 @@ if line =~ /^# (.*)/ framework["title"] = $1 state = :parse_summary next elsif line =~ /^## Introduction/ - framework["introduction"] = "" + framework["introduction"] = "" state = :parse_introduction next elsif line =~ /^## Links/ state = :parse_links next @@ -82,20 +82,20 @@ if !line.strip.empty? framework["summary"] = line.strip end end end - + if state == :parse_introduction if line =~ /^##/ framework["introduction"].strip! state = nil else framework["introduction"] += line end end - + if state == :parse_links if line =~ /^##/ state = nil else if line =~ /- (.*): (.*)/ @@ -108,27 +108,27 @@ framework["link_#{link_name}"] = url end end end end - + required_fields = [] [ "title", "introduction", "link_home_page" ].each do |field| if !options[:ignore_errors] || !options[:ignore_errors].include?(field) required_fields.push field end end - + required_fields.each do |field| if !framework.has_key?(field) || framework[field].strip.empty? @errors.push( { :name => name, :issue => "missing_" + field } ) end end @frameworks[name] = framework end - + def parse_metainfo path name = extract_name( path ) metainfo_path = File.join(path,"metainfo.yaml") if ( !File.exists?( metainfo_path ) ) @@ -153,40 +153,45 @@ if ( !File.exists?( authors_path ) ) @warnings.push( { :name => name, :issue => "missing_file", :details => "AUTHORS" } ) return end - + authors = [] File.open(authors_path).each_line do |line| if line =~ /(.* <.*@.*>)/ authors.push $1 end end framework = @frameworks[name] || {} framework["authors"] = authors - + @frameworks[name] = framework end def extract_name path path.split("/").last end - + def create_manifests output_dir settings = Settings.new settings.manifest_path = output_dir @frameworks.each do |name,framework| creator = Creator.new settings, name - manifest = creator.create_generic_manifest + generic_manifest_filename = creator.manifest_basename + ".manifest" + if File.exist?(generic_manifest_filename) + manifest = Manifest.parse_file(creator.manifest_basename + ".manifest") + else + manifest = creator.create_generic_manifest + end fill_in_data framework, manifest creator.create_dir creator.write_manifest manifest end end - + def fill_in_data framework, manifest manifest.display_name = framework["title"] manifest.summary = framework["summary"] manifest.description = framework["introduction"] manifest.urls.vcs = framework["link_git_repository"]