diff --git a/Rakefile b/Rakefile index 111e0de3..d683cc34 100644 --- a/Rakefile +++ b/Rakefile @@ -24,16 +24,7 @@ def name end def version - line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/] - line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] -end - -def date - Date.today.to_s -end - -def rubyforge_project - name + JekyllImport::VERSION end def gemspec_file @@ -44,10 +35,6 @@ def gem_file "#{name}-#{version}.gem" end -def replace_header(head, header_name) - head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"} -end - def normalize_bullets(markdown) markdown.gsub(/\s{2}\*{1}/, "-") end @@ -222,37 +209,8 @@ task :release => :build do end desc "Build #{gem_file} into the pkg directory" -task :build => :gemspec do +task :build do sh "mkdir -p pkg" sh "gem build #{gemspec_file}" sh "mv #{gem_file} pkg" end - -desc "Generate #{gemspec_file}" -task :gemspec do - # read spec file and split out manifest section - spec = File.read(gemspec_file) - head, manifest, tail = spec.split(" # = MANIFEST =\n") - - # replace name version and date - replace_header(head, :name) - replace_header(head, :version) - replace_header(head, :date) - #comment this out if your rubyforge_project has a different name - replace_header(head, :rubyforge_project) - - # determine file list from git ls-files - files = `git ls-files`. - split("\n"). - sort. - reject { |file| file =~ /^\./ }. - reject { |file| file =~ /^(rdoc|pkg)/ }. - map { |file| " #{file}" }. - join("\n") - - # piece file back together and write - manifest = " s.files = %w[\n#{files}\n ]\n" - spec = [head, manifest, tail].join(" # = MANIFEST =\n") - File.open(gemspec_file, 'w') { |io| io.write(spec) } - puts "Updated #{gemspec_file}" -end diff --git a/jekyll-import.gemspec b/jekyll-import.gemspec index be7b91b6..faf24e8c 100644 --- a/jekyll-import.gemspec +++ b/jekyll-import.gemspec @@ -1,13 +1,17 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'jekyll-import/version' + Gem::Specification.new do |s| s.specification_version = 2 if s.respond_to? :specification_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.rubygems_version = '1.3.5' - s.required_ruby_version = '>= 1.9.2' + s.rubygems_version = '2.2.2' + s.required_ruby_version = '>= 1.9.3' - s.name = 'jekyll-import' - s.version = '0.1.0' - s.date = '2013-12-18' - s.rubyforge_project = 'jekyll-import' + s.name = 'jekyll-import' + s.version = JekyllImport::VERSION + s.license = 'MIT' s.summary = "Import command for Jekyll (static site generator)." s.description = "Provides the Import command for Jekyll." @@ -15,17 +19,19 @@ Gem::Specification.new do |s| s.authors = ["Tom Preston-Werner"] s.email = 'tom@mojombo.com' s.homepage = 'http://github.com/jekyll/jekyll-import' - s.license = 'MIT' + s.files = `git ls-files`.split($/) + s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } + s.test_files = s.files.grep(%r{^(test|spec|features)/}) s.require_paths = %w[lib] s.rdoc_options = ["--charset=UTF-8"] s.extra_rdoc_files = %w[README.markdown LICENSE] - s.add_runtime_dependency('jekyll', '~> 1.3') + # runtime dependencies + s.add_runtime_dependency('jekyll', '~> 1.4') s.add_runtime_dependency('fastercsv') s.add_runtime_dependency('nokogiri') - s.add_runtime_dependency('safe_yaml', '~> 0.9.7') # development dependencies s.add_development_dependency('rake', "~> 10.1.0") @@ -46,118 +52,8 @@ Gem::Specification.new do |s| s.add_development_dependency('mysql', "~> 2.8") s.add_development_dependency('pg', "~> 0.12") s.add_development_dependency('mysql2', "~> 0.3") - s.add_development_dependency('behance', "~> 0.3.0") + s.add_development_dependency('behance', "~> 0.3") # site dependencies: s.add_development_dependency('launchy', '~> 2.4') - - # = MANIFEST = - s.files = %w[ - Gemfile - History.markdown - LICENSE - README.markdown - Rakefile - jekyll-import.gemspec - lib/jekyll-import.rb - lib/jekyll-import/importer.rb - lib/jekyll-import/importers.rb - lib/jekyll-import/importers/behance.rb - lib/jekyll-import/importers/csv.rb - lib/jekyll-import/importers/drupal6.rb - lib/jekyll-import/importers/drupal7.rb - lib/jekyll-import/importers/enki.rb - lib/jekyll-import/importers/ghost.rb - lib/jekyll-import/importers/google_reader.rb - lib/jekyll-import/importers/joomla.rb - lib/jekyll-import/importers/jrnl.rb - lib/jekyll-import/importers/marley.rb - lib/jekyll-import/importers/mephisto.rb - lib/jekyll-import/importers/mt.rb - lib/jekyll-import/importers/posterous.rb - lib/jekyll-import/importers/rss.rb - lib/jekyll-import/importers/s9y.rb - lib/jekyll-import/importers/textpattern.rb - lib/jekyll-import/importers/tumblr.rb - lib/jekyll-import/importers/typo.rb - lib/jekyll-import/importers/wordpress.rb - lib/jekyll-import/importers/wordpressdotcom.rb - lib/jekyll/commands/import.rb - site/.gitignore - site/CNAME - site/README - site/_config.yml - site/_includes/analytics.html - site/_includes/docs_contents.html - site/_includes/docs_contents_mobile.html - site/_includes/docs_option.html - site/_includes/docs_ul.html - site/_includes/footer.html - site/_includes/header.html - site/_includes/news_contents.html - site/_includes/news_contents_mobile.html - site/_includes/news_item.html - site/_includes/primary-nav-items.html - site/_includes/section_nav.html - site/_includes/top.html - site/_layouts/default.html - site/_layouts/docs.html - site/_layouts/news.html - site/_layouts/news_item.html - site/_posts/2013-11-09-jekyll-import-0-1-0-beta4-release.markdown - site/_posts/2013-11-18-jekyll-import-0-1-0-rc1-released.markdown - site/_posts/2013-12-17-jekyll-import-0-1-0-released.markdown - site/css/gridism.css - site/css/normalize.css - site/css/pygments.css - site/css/style.css - site/docs/behance.md - site/docs/contributing.md - site/docs/csv.md - site/docs/drupal6.md - site/docs/drupal7.md - site/docs/enki.md - site/docs/ghost.md - site/docs/google_reader.md - site/docs/history.md - site/docs/index.md - site/docs/installation.md - site/docs/joomla.md - site/docs/jrnl.md - site/docs/marley.md - site/docs/mephisto.md - site/docs/mt.md - site/docs/posterous.md - site/docs/rss.md - site/docs/s9y.md - site/docs/textpattern.md - site/docs/third-party.md - site/docs/tumblr.md - site/docs/typo.md - site/docs/usage.md - site/docs/wordpress.md - site/docs/wordpressdotcom.md - site/favicon.png - site/feed.xml - site/img/article-footer.png - site/img/footer-arrow.png - site/img/footer-logo.png - site/img/logo-2x.png - site/img/octojekyll.png - site/img/tube.png - site/img/tube1x.png - site/index.html - site/js/modernizr-2.5.3.min.js - site/news/index.html - site/news/releases/index.html - test/helper.rb - test/test_jrnl_importer.rb - test/test_mt_importer.rb - test/test_tumblr_importer.rb - test/test_wordpress_importer.rb - test/test_wordpressdotcom_importer.rb - ] - # = MANIFEST = - - s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ } end diff --git a/lib/jekyll-import.rb b/lib/jekyll-import.rb index ad410d75..24238f76 100644 --- a/lib/jekyll-import.rb +++ b/lib/jekyll-import.rb @@ -9,8 +9,6 @@ require 'jekyll-import/util' module JekyllImport - VERSION = '0.1.0' - def self.logger @logger ||= Jekyll::Stevenson.new end @@ -26,7 +24,7 @@ def self.add_importer_commands(cmd) name = importer.to_s.split("::").last.downcase commands << name cmd.command(name.to_sym) do |c| - c.syntax "jekyll import #{name} [options]" + c.syntax "#{name} [options]" importer.specify_options(c) c.action do |_, options| importer.run(options) diff --git a/lib/jekyll-import/version.rb b/lib/jekyll-import/version.rb new file mode 100644 index 00000000..e6d449c2 --- /dev/null +++ b/lib/jekyll-import/version.rb @@ -0,0 +1,3 @@ +module JekyllImport + VERSION = '0.1.0' +end diff --git a/lib/jekyll/commands/import.rb b/lib/jekyll/commands/import.rb index 901691fa..62936a8c 100644 --- a/lib/jekyll/commands/import.rb +++ b/lib/jekyll/commands/import.rb @@ -5,6 +5,7 @@ module Jekyll module Commands class Import < Command + IMPORTERS = { :behance => 'Behance', :csv => 'CSV', @@ -28,26 +29,47 @@ class Import < Command :wordpressdotcom => 'WordpressDotCom' } - def self.abort_on_invalid_migrator(migrator) - msg = "Sorry, '#{migrator}' isn't a valid migrator. Valid choices:\n" - IMPORTERS.keys.each do |k, v| - msg += "* #{k}\n" + class << self + + def init_with_program(prog) + prog.command(:import) do |c| + c.syntax 'import [options]' + c.description 'Import your old blog to Jekyll' + importers = JekyllImport.add_importer_commands(c) + + c.action do |args, options| + if args.empty? + Jekyll.logger.warn "You must specify an importer." + Jekyll.logger.info "Valid options are:" + importers.each { |i| Jekyll.logger.info "*", "#{i}" } + end + end + end end - abort msg - end - def self.process(migrator, options) - migrator = migrator.to_s.downcase + def process(migrator, options) + migrator = migrator.to_s.downcase - if IMPORTERS.keys.include?(migrator.to_sym) - if JekyllImport::Importers.const_defined?(IMPORTERS[migrator.to_sym]) - klass = JekyllImport::Importers.const_get(IMPORTERS[migrator.to_sym]) - klass.run(options.__hash__) + if IMPORTERS.keys.include?(migrator.to_sym) + if JekyllImport::Importers.const_defined?(IMPORTERS[migrator.to_sym]) + klass = JekyllImport::Importers.const_get(IMPORTERS[migrator.to_sym]) + klass.run(options.__hash__) + end + else + abort_on_invalid_migrator(migrator) end - else - abort_on_invalid_migrator(migrator) end + + def abort_on_invalid_migrator(migrator) + msg = "Sorry, '#{migrator}' isn't a valid migrator. Valid choices:\n" + IMPORTERS.keys.each do |k, v| + msg += "* #{k}\n" + end + abort msg + end + end + end end end