Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport of Nanoc::CLI.after_setup functionality #407

Merged
merged 4 commits into from Mar 31, 2014

Conversation

barraq
Copy link
Contributor

@barraq barraq commented Mar 26, 2014

This commit backport the useful Nanoc::CLI.after_setup functionality from Nanoc 4.x to Nanoc 3.x

This backport is really useful to initiate the migration from Nanoc 3.x to Nanoc 4.x since developers can already start packaging their plugins following the Nanoc 4.x packaging style!

For instance, the plugin nanoc-photomator is packaged as follow for Nanoc 3.x

# encoding: utf-8

$LOAD_PATH.unshift(File.expand_path('../lib/', __FILE__))
require 'nanoc/photomator/version'

Gem::Specification.new do |s|
  s.name = 'nanoc-photomator'
  s.version = Nanoc::Photomator::VERSION
  s.homepage = 'https://github.com/barraq/nanoc-photomator'
  s.summary = 'Photo automation tools for Nanoc'
  s.description = 'Provides a set of commands and user interfaces for working with pictures in Nanoc'

  s.author = 'Rémi Barraquand'
  s.email = 'dev@remibarraquand.com'
  s.license = 'MIT'

  s.required_ruby_version = '>= 1.9.3'

  s.files = Dir['[A-Z]*'] +
      Dir['{lib,test}/**/*'] +
      ['nanoc-photomator.gemspec']
  s.require_paths = ['lib']

  s.rdoc_options = ['--main', 'README.md']
  s.extra_rdoc_files = ['LICENSE', 'README.md']

  # For Nanoc 4.x
  #s.add_runtime_dependency('nanoc-core')
  #s.add_runtime_dependency('nanoc-cli')

 # For Nanoc 3.x
  s.add_runtime_dependency('nanoc', '>= 3.6.7', '< 4.0.0')


  # Autoloading
  s.add_development_dependency('bundler', '~> 1.5')
end


# Require
if defined?(Bundler)
Bundler.require(:default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you undo the changes to bin/nanoc? These changes are not required for the after_setup_procs feature to work. I’d like to limit the changes made to nanoc 3.x as much as possible to prevent difficult merges later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddfreyne well I first tried with the original bin/nanoc but the weird thing is that it does not work as expected. I am maybe doing something wrong but when I use the original/nanoc my plugin is not loaded and therefore my custom plugin's command is not showing up in the list of available commands (when doing 'nanoc --help'), also I cannot execute the command neither.

I guess I still need the Bundler.require(:default) after the require 'bundler/setup'? Should not be something like this?

# Try loading bundler if it's possible
begin
  require 'bundler/setup'
  Bundler.require(:default)
rescue LoadError
  # no problem
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@denisdefreyne
Copy link
Member

👍 apart from remarks.

@denisdefreyne
Copy link
Member

Looks good. Will run some tests locally to make sure this doesn’t break anything, but if it doesn’t, I’ll merge.

@barraq
Copy link
Contributor Author

barraq commented Mar 29, 2014

Concerning the test, in nanoc-cli you have one test concerning the after_setup that maybe we should also add to the merge: https://github.com/nanoc/nanoc-cli/blob/8e49e1907741c54bcd053de8b7ae4eb732f82d0d/test/cli/test_cli.rb#L105

@denisdefreyne
Copy link
Member

Yup, would be great if you could move that over too.

@barraq
Copy link
Contributor Author

barraq commented Mar 29, 2014

ok, I'm running the test too before commiting

denisdefreyne added a commit that referenced this pull request Mar 31, 2014
Backport Nanoc::CLI.after_setup functionality from nanoc 4.0
@denisdefreyne denisdefreyne merged commit 70020f3 into nanoc:master Mar 31, 2014
@denisdefreyne
Copy link
Member

Cool stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants