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

Upgrade to Methadone 1.9.1 #4

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f121de0
fix typo
sch0rsch Oct 7, 2013
ce207e5
Merge pull request #68 from sch0rsch/fix-typo
davetron5000 Oct 8, 2013
11cd734
fix the failing bootstrap feature
sch0rsch Oct 26, 2013
b840f0d
Merge pull request #70 from sch0rsch/fix-bootstrap-feature
davetron5000 Oct 28, 2013
33330ae
Added a helpful error message when you forget to set a logger.
jamonholmgren Oct 30, 2013
266479e
Merge pull request #71 from jamonholmgren/patch/warning_when_no_logge…
davetron5000 Oct 30, 2013
98b4945
use better ruby version stuff
davetron5000 Oct 30, 2013
509820b
bump version
davetron5000 Oct 30, 2013
d3403fe
build on 2.1
davetron5000 Dec 26, 2013
9be3b5a
I like green builds more than rbx, sorry :(
davetron5000 Dec 26, 2013
eaa251c
make feature more resilient
davetron5000 Feb 23, 2014
f009486
handle case where string used for log device
davetron5000 Feb 23, 2014
784a9e4
bump version
davetron5000 Feb 23, 2014
ae01c44
add gplv2 and gplv3 to stock licenses and make sure all generated sto…
pskocik May 1, 2014
b4ba34c
ree and 1.8.7 ar edead to me now
davetron5000 May 2, 2014
d422c66
bump version
davetron5000 May 2, 2014
19d8381
added rspec-2.99 with tests so now it works out of the box again
Jul 9, 2014
9428751
Merge pull request #75 from rocknrollMarc/rspec-2.99
davetron5000 Jul 10, 2014
9483eac
bump version
davetron5000 Jul 10, 2014
4747636
Updated to RSpec 3.0 with :should syntax. Removed unnecessary MiniTes…
jamonholmgren Jul 11, 2014
8f0a13b
a few more fixes for RSpec 3
davetron5000 Jul 12, 2014
be8faa7
Merge pull request #77 from davetron5000/rspec-3
davetron5000 Jul 14, 2014
15230d8
Fix personalization of the Apache license template
pskocik Jul 23, 2014
0f5e1fd
ugh JRuby
davetron5000 Jul 29, 2014
e5f328b
bump version
davetron5000 Jul 29, 2014
e894b5a
Failing steps for: when run with no license or --license "NONE", "LIC…
pskocik Aug 16, 2014
d33a438
Remove LICENSE.txt when run with no license specified or with --licen…
pskocik Aug 16, 2014
ba69bc5
Failing test for: The whole initial state of the app has been staged …
pskocik Aug 16, 2014
6d578e7
Stage the whole initial stage of the app with git
pskocik Aug 16, 2014
b76ee95
Failing step for: the gemspec should mention the correct license
pskocik Aug 16, 2014
0f9f077
Make the gemspec use the correct license
pskocik Aug 16, 2014
0c574df
Merge branch 'feature/gemspec_license'
pskocik Aug 16, 2014
71975f8
Merge branch 'feature/git_add'
pskocik Aug 16, 2014
5436dbf
use sh for the external `git add ...` command
pskocik Aug 16, 2014
54396db
replace File::write to make ruby 1.9.2 happy
pskocik Aug 16, 2014
2b13e21
Merge branch 'feature/gemspec_license'
pskocik Aug 16, 2014
8e5cae7
Merge branch 'feature/git_add'
pskocik Aug 16, 2014
812b3ac
Merge pull request #79 from pjump/master
davetron5000 Aug 17, 2014
43eb7e1
use bang method so it dies if git call fails
davetron5000 Aug 17, 2014
c23aa3c
bump version
davetron5000 Aug 17, 2014
a7644f0
allow changing the log level at runtime
sch0rsch Aug 20, 2014
a8312b1
fix typo
sch0rsch Aug 20, 2014
a6b3202
try to fix travis build
sch0rsch Aug 20, 2014
d470415
fix JRuby builds
sch0rsch Aug 20, 2014
8e7f084
refactor runtime toggling of the log level
sch0rsch Aug 21, 2014
2f4e112
fix typo
sch0rsch Aug 21, 2014
2c24e75
Merge pull request #81 from sch0rsch/fix_impelment
davetron5000 Aug 21, 2014
09873f5
update README to current build matrix
sch0rsch Aug 22, 2014
78d7178
remove warning about bundler problems in 2.0.0
sch0rsch Aug 22, 2014
2b10161
Merge pull request #82 from sch0rsch/update-readme
davetron5000 Aug 23, 2014
c1935ce
Merge remote-tracking branch 'sch0rsch/change_log_level_at_runtime'
davetron5000 Aug 23, 2014
8ea0ea4
make new toggle available in scaffolded apps
davetron5000 Aug 23, 2014
21b6583
bump version
davetron5000 Aug 23, 2014
21ff9b5
Remove rake version from gemspec template
chibicode Oct 12, 2014
3d7ac1f
Merge pull request #83 from chibicode/remove-rake-from-gemspec
davetron5000 Oct 22, 2014
870503e
bump version
davetron5000 Oct 22, 2014
d4d37fb
try a specific version of Ruby
davetron5000 Dec 7, 2014
fd0965a
try this
davetron5000 Dec 7, 2014
fc33986
Allow absolute config files (#87)
johnl Feb 20, 2015
8b380f5
lock i18n to a verison that works with older rubies
davetron5000 Feb 20, 2015
cf5d7b4
typo
davetron5000 Feb 20, 2015
e032628
Merge branch 'master' of github.com:davetron5000/methadone into 87-ab…
johnl Feb 20, 2015
532d228
slight update to docs
davetron5000 Feb 21, 2015
8aabb60
Explicitly get path of Tempfile in test
davetron5000 Feb 21, 2015
c1ff592
oops, missed one
davetron5000 Feb 21, 2015
3d89852
do not care about that patch level
davetron5000 Feb 21, 2015
e607d83
bump version
davetron5000 Feb 21, 2015
e2bf946
oy vey
davetron5000 Feb 21, 2015
614183e
situps
davetron5000 Feb 21, 2015
9ce6893
kill me now
davetron5000 Feb 21, 2015
a993333
lots of cleanups for 2.2.2
davetron5000 May 25, 2015
52ab949
latest ruby on travis
davetron5000 May 25, 2015
fd1b98b
deal with test/unit missing on 2.2
davetron5000 May 25, 2015
060234a
remove unsupported Rubies
davetron5000 May 25, 2015
0605c09
Merge pull request #93 from davetron5000/fix-test-unit-issue-for-2.2
davetron5000 Jun 7, 2015
1979bff
bump version
davetron5000 Jun 7, 2015
cfecf1c
Merge tag 'v1.9.1' into feat/upgrade_to_methadone_1_9_1
Jun 22, 2015
a7a3fda
chore (test, features) Fix unit tests and stories.
Jun 22, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-1.9.3-p392
2.2.2
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ notifications:
on_success: always
script: 'bundle exec rake'
rvm:
- 2.0.0
- 1.9.3
- 1.9.2
- 1.8.7
- ree
# - rbx # Removed because travis is choking on rbx and doesn't find rbx-2.0.0-rc1 which was tested locally
- jruby-18mode
- 2.0.0
- 2.1.0
- 2.2.0
- 2.2.2
- jruby-19mode
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'http://www.rubygems.org'

gem 'open4', :platform => :ruby_18
gem 'test-unit'
# Specify your gem's dependencies in methadone.gemspec
gemspec
9 changes: 3 additions & 6 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ http://a1.mzstatic.com/us/r30/Publication/v4/2c/f7/90/2cf7902f-f709-9125-c73d-87
== Platforms

* The build runs on Travis for:
* MRI Ruby 1.8.7
* MRI Ruby 1.9.2
* MRI Ruby 1.9.3
* RBX
* REE
* MRI Ruby 2.0.0
* MRI Ruby 2.1.0
* JRuby in both 1.8 and 1.9 mode

It should work on 2.0.0 but there's a weird bundler issue where some of the aruba tests fail in odd ways.

== Bootstrapping a new CLI App

The +methadone+ command-line app will bootstrap a new command-line app, setting up a proper gem structure, unit tests, and cucumber-based tests with aruba:
Expand Down Expand Up @@ -148,7 +145,7 @@ Methadone::CLILogger is designed to handle this. It's a proper subclass of Ruby
See {CLILogger's rdoc}[http://davetron5000.github.com/methadone/rdoc/classes/Methadone/CLILogger.html] and then {CLILogging's}[http://davetron5000.github.com/methadone/rdoc/classes/Methadone/CLILogging.html] for more.


Currently, there are classes the assist in directing output logger-style to the right place; basically ensuring that errors go to +STDERR+ and everything else goes to +STDOUT+. All of this is, of course, configurable
Currently, there are classes that assist in directing output logger-style to the right place; basically ensuring that errors go to +STDERR+ and everything else goes to +STDOUT+. All of this is, of course, configurable

== Cucumber Steps

Expand Down
38 changes: 32 additions & 6 deletions bin/methadone
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,29 @@ main do |app_name|
copy_file "test/tc_something.rb", :from => :test_unit, :binding => binding
end

gemspec = "#{gemname}.gemspec"
gem_variable = File.open(gemspec) { |x| x.read }.match(/(\w+)\.executables/)[1]

license = options[:license]
warn "warning: your app has no license" unless license
license = nil if license == 'NONE'
copy_file "#{options[:license]}_LICENSE.txt", :as => "LICENSE.txt" if license
if license
copy_file "#{options[:license]}_LICENSE.txt", :as => "LICENSE.txt"
else
#Remove the MIT license generated by `bundle gem`
debug "Making sure no LICENSE.txt file exists at the root of the repo"
FileUtils.rm_f "LICENSE.txt"
end

#Ensure the gemspec file mentions the correct license
gemspec_content = File.read(gemspec)
if gemspec_content =~ /(^\s*#{gem_variable}\.license\s*=\s*).*/
gemspec_content.gsub!(/(^\s*#{gem_variable}\.license\s*=\s*).*/,"\\1#{license.to_s.inspect}")
else
gemspec_content.gsub!(/(^\s*#{gem_variable}\.name\s*=\s*.*)/,"\\1\n #{gem_variable}.license=#{license.to_s.inspect}")
end
File.open(gemspec,'w') {|f| f.write gemspec_content }


# TODO: bundle gem creates README.md regardless of using_readme setting.
copy_file "README.rdoc", :binding => binding if using_readme
Expand All @@ -82,20 +101,27 @@ main do |app_name|
copy_file "features/step_definitions/executable_steps.rb", :as => "#{gemname}_steps.rb"
copy_file "bin/executable", :as => gemname, :executable => true, :binding => binding, :from => (multi ? :multicommand : :full)

gemspec = "#{gemname}.gemspec"
gem_variable = File.open(gemspec) { |x| x.read }.match(/(\w+)\.executables/)[1]
add_to_file gemspec, [
" #{gem_variable}.add_development_dependency('rdoc')",
" #{gem_variable}.add_development_dependency('aruba')",
" #{gem_variable}.add_development_dependency('rake', '~> 0.9.2')",
" #{gem_variable}.add_development_dependency('rake')",
" #{gem_variable}.add_dependency('methadone', '~> #{Methadone::VERSION}')",
], :before => /^end\s*$/
ruby_major,ruby_minor,ruby_patch = RUBY_VERSION.split(/\./).map(&:to_i)

if ruby_major >= 2 && ruby_minor >= 2
add_to_file gemspec, [
" #{gem_variable}.add_development_dependency('test-unit')",
], :before => /^end\s*$/
end

if rspec
add_to_file gemspec, [
" #{gem_variable}.add_development_dependency('rspec')",
" #{gem_variable}.add_development_dependency('rspec', '~> 3')",
], :before => /^end\s*$/
end

sh! %q(git add --all .)
end

options[:readme] = true
Expand All @@ -116,7 +142,7 @@ on "-c cmd1,cmd2,cmdN", "--commands", Array, "Generate framework for a cli app t
end
end

licenses = %w(mit apache custom NONE)
licenses = %w(mit apache gplv2 gplv3 custom NONE)
on("-l LICENSE","--license",licenses,"Specify the license for your project",'(' + licenses.join('|') + ')')

use_log_level_option
Expand Down
41 changes: 21 additions & 20 deletions features/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Feature: Bootstrap a new command-line app
And the file "tmp/newgem/.gitignore" should match /.DS_Store/
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('aruba'/
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rdoc'/
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rake', '~> 0.9.2'/
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rake'/
And the file "tmp/newgem/newgem.gemspec" should match /add_dependency\('methadone'/
And the file "tmp/newgem/newgem.gemspec" should include "test-unit" if needed
And the file "tmp/newgem/newgem.gemspec" should use the same block variable throughout
Given I cd to "tmp/newgem"
And my app's name is "newgem"
Expand All @@ -50,16 +51,16 @@ Feature: Bootstrap a new command-line app
|--log-level|
And the banner should document that this app takes no arguments
When I successfully run `rake -T -I../../lib`
Then the output should contain "rake clean # Remove any temporary products"
And the output should contain "rake clobber # Remove any generated file"
And the output should contain "rake clobber_rdoc # Remove RDoc HTML files"
And the output should contain "rake features # Run Cucumber features"
And the output should contain "rake rdoc # Build RDoc HTML files"
And the output should contain "rake release # Create tag v0.0.1 and build and push newgem-0.0.1.gem to Rubygems"
And the output should contain "rake rerdoc # Rebuild RDoc HTML files"
And the output should contain "rake test # Run tests"
And the output should match /rake install # Build and install newgem-0.0.1.gem into system gems/
And the output should match /rake build # Build newgem-0.0.1.gem into the pkg directory/
Then the output should match /rake clean/
And the output should match /rake clobber/
And the output should match /rake clobber_rdoc/
And the output should match /rake features/
And the output should match /rake rdoc/
And the output should match /rake release/
And the output should match /rake rerdoc/
And the output should match /rake test/
And the output should match /rake install/
And the output should match /rake build/
When I run `rake -I../../../../lib`
Then the exit status should be 0
And the output should match /1 tests, 1 assertions, 0 failures, 0 errors/
Expand Down Expand Up @@ -100,22 +101,15 @@ Feature: Bootstrap a new command-line app
And I cd to "tmp/new-gem"
And my app's name is "new-gem"
When I successfully run `bin/new-gem --version` with "lib" in the library path
Then the output should contain:
"""
new-gem version 0.0.1
"""
Then the output should match /new-gem version 0/

@wip
Scenario: Version flag can be used to only show the app version with a custom format
Given I successfully run `methadone tmp/new-gem`
And "bin/new-gem" has configured version to show only the version with a custom format and not help
And I cd to "tmp/new-gem"
And my app's name is "new-gem"
When I successfully run `bin/new-gem --version` with "lib" in the library path
Then the output should contain:
"""
new-gem V0.0.1
"""
Then the output should match /new-gem V0/

Scenario: Won't squash an existing dir
When I successfully run `methadone tmp/newgem`
Expand Down Expand Up @@ -166,3 +160,10 @@ Feature: Bootstrap a new command-line app
And the banner should document that this app's arguments are:
|app_name|which is required|
And there should be a one line summary of what the app does

Scenario: The whole initial state of the app has been staged with git
Given I successfully run `methadone -l custom tmp/newgem`
And I cd to "tmp/newgem"
When I successfully run `git ls-files --others --deleted `
Then the output should match /\A\Z/

26 changes: 16 additions & 10 deletions features/license.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ Feature: Users should get the license included
Then newgem's license should be an empty file
And the README should reference the need for a license

Scenario Outline: Include one of a few stock licenses
When I successfully run `methadone -l <license> tmp/newgem`
Then newgem's license should be the <license> license
And the README should reference this license

Examples:
|license|
|apache|
|mit|

Scenario: We only support a few licenses
When I run `methadone -l foobar tmp/newgem`
Then the exit status should not be 0
Expand All @@ -30,8 +20,24 @@ Feature: Users should get the license included
When I successfully run `methadone tmp/newgem`
Then the stderr should contain "warning: your app has no license"
And the README should not reference a license
And the file "tmp/newgem/LICENSE.txt" should not exist

Scenario: No license specified explicitly
When I successfully run `methadone -l NONE tmp/newgem`
Then the stderr should not contain "warning: your app has no license"
And the README should not reference a license
And the file "tmp/newgem/LICENSE.txt" should not exist

Scenario Outline: Include one of a few stock licenses
When I successfully run `methadone -l <license> tmp/newgem`
Then newgem's license should be the <license> license
And the README should reference this license
And LICENSE.txt should contain user information and program name

Examples:
|license|
|apache|
|mit|
|gplv2|
|gplv3|

2 changes: 1 addition & 1 deletion features/multilevel_commands.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Feature: Support multi-level commands
And the file "tmp/multigem/.gitignore" should match /.DS_Store/
And the file "tmp/multigem/multigem.gemspec" should match /add_development_dependency\('aruba'/
And the file "tmp/multigem/multigem.gemspec" should match /add_development_dependency\('rdoc'/
And the file "tmp/multigem/multigem.gemspec" should match /add_development_dependency\('rake', '~> 0.9.2'/
And the file "tmp/multigem/multigem.gemspec" should match /add_development_dependency "rake", "~> 10.0"/
And the file "tmp/multigem/multigem.gemspec" should match /add_dependency\('methadone'/
And the file "tmp/multigem/multigem.gemspec" should use the same block variable throughout
And the file "tmp/multigem/bin/multigem" should match /command "walk" => Multigem::Commands::Walk/
Expand Down
10 changes: 2 additions & 8 deletions features/rspec_support.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ Feature: Bootstrap a new command-line app using RSpec instead of Test::Unit
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rspec'/
When I cd to "tmp/newgem"
And I successfully run `rake -T -I../../lib`
Then the output should contain:
"""
rake spec # Run RSpec code examples
"""
And the output should not contain:
"""
rake test # Run tests
"""
Then the output should match /rake spec/
And the output should not match /rake test/
When I run `rake spec -I../../lib`
Then the exit status should be 0
And the output should contain:
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/bootstrap_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@
end
end
end

Then /^the file "(.*?)" should include "(.*?)" if needed$/ do |file, gemname|
if RUBY_VERSION =~ /^2\./ && RUBY_VERSION !~ /^2.0/ && RUBY_VERSION !~ /^2.1/
step %{the file "#{file}" should match /add_development_dependency\\('#{gemname}/}
end
end
6 changes: 6 additions & 0 deletions features/step_definitions/license_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Then /^newgem's license should be the (\w+) license/ do |license|
@license = license
step %(a file named "tmp/newgem/LICENSE.txt" should exist)
step %(the file "tmp/newgem/newgem.gemspec" should match /#{@license}/)
end

Then /^the README should reference this license$/ do
Expand All @@ -22,3 +23,8 @@
step %(the file "tmp/newgem/README.rdoc" should match /License:: INSERT LICENSE HERE/)
end

Then(/^LICENSE\.txt should contain user information and program name$/) do
step %(the file "tmp/newgem/LICENSE.txt" should match /#{`git config user.name`}/)
step %(the file "tmp/newgem/LICENSE.txt" should match /newgem/)
step %(the file "tmp/newgem/LICENSE.txt" should match /#{Time.now.year}/)
end
14 changes: 14 additions & 0 deletions lib/methadone/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,19 @@ def normalize_command(cmd)
cmd.tr('A-Z','a-z').gsub(/[^a-z0-9_]/,'_').sub(/^_*/,'')
end

def render_license_partial(partial)
ERB.new(File.read(template_dir('full/'+partial))).result(binding).strip
end

def gemspec
@gemspec || @gemspec=_get_gemspec
end
private
def _get_gemspec
files=Dir.glob("*.gemspec")
raise "Multiple gemspec files" if files.size>1
raise "No gemspec file" if files.size < 1
Gem::Specification::load(files.first)
end
end
end
16 changes: 13 additions & 3 deletions lib/methadone/cli_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ def initialize(log_device=$stdout,error_device=$stderr)
super(log_device)
@stderr_logger = Logger.new(error_device)

@split_logs = log_device.tty? && error_device.tty?
log_device_tty = tty?(log_device)
error_device_tty = tty?(error_device)

@split_logs = log_device_tty && error_device_tty

self.level = Logger::Severity::INFO
@stderr_logger.level = DEFAULT_ERROR_LEVEL

self.formatter = BLANK_FORMAT if log_device.tty?
@stderr_logger.formatter = BLANK_FORMAT if error_device.tty?
self.formatter = BLANK_FORMAT if log_device_tty
@stderr_logger.formatter = BLANK_FORMAT if error_device_tty
end

def level=(level)
Expand Down Expand Up @@ -119,5 +122,12 @@ def error_formatter=(formatter)
@stderr_logger.formatter=formatter
end

private

def tty?(device_or_string)
return device_or_string.tty? if device_or_string.respond_to? :tty?
false
end

end
end
Loading