Skip to content

Commit

Permalink
Merge pull request #130 from jekyll/fix-up-gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Mar 16, 2014
2 parents a1e1b68 + fb029af commit 74a3186
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 181 deletions.
46 changes: 2 additions & 44 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
136 changes: 16 additions & 120 deletions jekyll-import.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# 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."

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")
Expand All @@ -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
4 changes: 1 addition & 3 deletions lib/jekyll-import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
require 'jekyll-import/util'

module JekyllImport
VERSION = '0.1.0'

def self.logger
@logger ||= Jekyll::Stevenson.new
end
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions lib/jekyll-import/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module JekyllImport
VERSION = '0.1.0'
end
50 changes: 36 additions & 14 deletions lib/jekyll/commands/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module Jekyll
module Commands
class Import < Command

IMPORTERS = {
:behance => 'Behance',
:csv => 'CSV',
Expand All @@ -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 <platform> [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

0 comments on commit 74a3186

Please sign in to comment.