newgem 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ == 1.0.2 2008-10-30
2
+
3
+ * Lighthouse Project created for tickets/suggestions: http://drnic.lighthouseapp.com/projects/18881-newgem
4
+ * newgem no longer generates a website by default; use -w to create one; or -i website; or script/generate install_website
5
+ * dev dependency on latest cucumber gem
6
+ * no requirement for cucumber gem to be installed [fixes #1]
7
+ * hoe is patched and cached within newgem so that README.* is supported [fixes #5]
8
+ * rake-automated patching of hoe.rb from patches/hoe/*.patch
9
+
1
10
  == 1.0.1 2008-10-28
2
11
 
3
12
  * Fix up readme + post-install notices based on 1.0.0 changes [thx Tomasz Muras]
data/README.rdoc CHANGED
@@ -79,6 +79,10 @@ The <code>newgem</code> application is distributed itself as a RubyGem and is av
79
79
 
80
80
  Alternately, download the gem and install manually.
81
81
 
82
+ == TICKETS:
83
+
84
+ Tickets or suggestions can be raised at http://drnic.lighthouseapp.com/projects/18881-newgem/overview
85
+
82
86
  == TUTORIALS:
83
87
 
84
88
  * Home page is a full tutorial - http://newgem.rubyforge.org
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- %w[rubygems rake rake/clean fileutils hoe rubigen].each { |f| require f }
1
+ %w[rubygems rake rake/clean fileutils rubigen cucumber].each { |f| require f }
2
2
  require File.dirname(__FILE__) + '/lib/newgem'
3
3
 
4
4
  # Generate all the Rake tasks
@@ -14,7 +14,9 @@ $hoe = Hoe.new('newgem', Newgem::VERSION) do |p|
14
14
  ['RedCloth','>= 4.0.0'], # for website generation
15
15
  ['syntax','>= 1.0.0']
16
16
  ]
17
- p.spec_extras['rdoc_options'] = ['--main', Dir['README*'].first] # hopefully fixed in future hoe > 1.8
17
+ p.extra_dev_deps = [
18
+ ['cucumber', ">= #{::Cucumber::VERSION::STRING}"]
19
+ ]
18
20
  p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
21
  path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
22
  p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
@@ -23,3 +25,32 @@ end
23
25
 
24
26
  require 'newgem/tasks' # load /tasks/*.rake
25
27
 
28
+ namespace :hoe do
29
+ desc "Applies patch files to the hoe.rb in latest hoe rubygem and stores in lib/hoe-patched.rb"
30
+ task :patch do
31
+ gem 'hoe'
32
+ hoe_lib = $LOAD_PATH.grep(/hoe.*\/lib/)
33
+ hoe_rb = File.join(hoe_lib, 'hoe.rb')
34
+ FileUtils.cp hoe_rb, File.dirname(__FILE__) + "/lib/hoe.rb"
35
+ patches = Dir[File.dirname(__FILE__) + "/patches/hoe/*.patch"].sort
36
+ patches.each do |patch|
37
+ puts "Applying patch #{File.basename patch}"
38
+ sh %{ cat #{patch} | patch -p1 }
39
+ end
40
+ patched_hoe = File.dirname(__FILE__) + "/lib/hoe-patched.rb"
41
+ FileUtils.mv File.dirname(__FILE__) + "/lib/hoe.rb", patched_hoe
42
+
43
+ help_msg = <<-EOS.gsub(/^\s+/,'')
44
+ # Patched version of Hoe to allow any README.* file
45
+ # Pending acceptance of ticket with this feature
46
+ # File created by 'rake hoe:patch' in newgem
47
+ # from patch files in patches/hoe/*.patch
48
+ EOS
49
+
50
+ contents = File.read(patched_hoe)
51
+ File.open(patched_hoe, "w") do |f|
52
+ f << help_msg + "\n"
53
+ f << contents
54
+ end
55
+ end
56
+ end
@@ -11,7 +11,7 @@ class NewgemGenerator < RubiGen::Base
11
11
  :author => nil,
12
12
  :import_path => nil,
13
13
  :jruby => nil,
14
- :disable_website => nil,
14
+ :enable_website => nil,
15
15
  :test_framework => 'test_unit',
16
16
  :version => '0.0.1'
17
17
 
@@ -22,7 +22,7 @@ class NewgemGenerator < RubiGen::Base
22
22
  # extensions/option
23
23
  attr_reader :test_framework
24
24
  attr_reader :bin_names_list
25
- attr_reader :disable_website
25
+ attr_reader :enable_website
26
26
  attr_reader :manifest
27
27
  attr_reader :is_jruby
28
28
 
@@ -64,7 +64,7 @@ class NewgemGenerator < RubiGen::Base
64
64
 
65
65
  # Website
66
66
  m.dependency "install_website", [gem_name],
67
- :author => author, :email => email, :destination => destination_root, :collision => :force unless disable_website
67
+ :author => author, :email => email, :destination => destination_root, :collision => :force if enable_website
68
68
 
69
69
  # JRuby
70
70
  m.dependency "install_jruby", [gem_name], :destination => destination_root, :collision => :force if is_jruby
@@ -138,8 +138,9 @@ EOS
138
138
  opts.on("-V", "--set-version=YOUR_VERSION", String,
139
139
  "Version of the gem you are creating.",
140
140
  "Default: 0.0.1") { |x| options[:version] = x }
141
- opts.on("-W", "--website-disable",
142
- "Disables the generation of the website for your RubyGem.") { |x| options[:disable_website] = x }
141
+ opts.on("-w", "--enable-website",
142
+ "Enable the generation of the website for your RubyGem.",
143
+ "Same as '-i website'") { |x| options[:enable_website] = x }
143
144
  opts.on("--simple",
144
145
  "Creates a simple RubyGems scaffold.") { |x| }
145
146
  end
@@ -156,7 +157,7 @@ EOS
156
157
  @email ||= rubyforge_config.email
157
158
  end
158
159
  @bin_names_list = (options[:bin_name] || "").split(',')
159
- @disable_website = options[:disable_website]
160
+ @enable_website = options[:enable_website]
160
161
  @test_framework = options[:test_framework] || "test_unit"
161
162
  @is_jruby = options[:jruby]
162
163
  @project_name = options[:project] if options.include?(:project)
@@ -1,4 +1,4 @@
1
- %w[rubygems rake rake/clean fileutils hoe newgem rubigen].each { |f| require f }
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
2
  require File.dirname(__FILE__) + '/lib/<%= gem_name %>'
3
3
 
4
4
  # Generate all the Rake tasks
@@ -17,7 +17,6 @@ $hoe = Hoe.new('<%= gem_name %>', <%= module_name %>::VERSION) do |p|
17
17
  <% if is_jruby -%>
18
18
  p.spec_extras['platform'] = 'jruby' # JRuby gem created, e.g. <%= gem_name %>-X.Y.Z-jruby.gem
19
19
  <% end -%>
20
- p.spec_extras['rdoc_options'] = ['--main', Dir['README*'].first] # hopefully fixed in future hoe > 1.8
21
20
  p.clean_globs |= %w[**/.DS_Store tmp *.log]
22
21
  path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
23
22
  p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
@@ -23,7 +23,7 @@ Feature: Generate an executable/CLI scaffold
23
23
  Given an existing newgem scaffold [called 'my_project']
24
24
  Given 'executable' generator is invoked with arguments 'my_app'
25
25
  When run executable 'bin/my_app' with arguments ''
26
- Then output matches /lib\/my_app\/cli.rb/
26
+ Then output does match /lib\/my_app\/cli.rb/
27
27
 
28
28
  Scenario: Run unit tests after executable generator should all pass
29
29
  Given an existing newgem scaffold [called 'my_project']
@@ -13,22 +13,6 @@
13
13
  create test
14
14
  create test/test_helper.rb
15
15
  create test/test_my_project.rb
16
- dependency install_website
17
- create website/javascripts
18
- create website/stylesheets
19
- create config
20
- exists script
21
- exists tasks
22
- create website/index.txt
23
- create website/index.html
24
- create config/website.yml.sample
25
- create script/txt2html
26
- dependency plain_theme
27
- exists website/javascripts
28
- exists website/stylesheets
29
- create website/template.html.erb
30
- create website/stylesheets/screen.css
31
- create website/javascripts/rounded_corners_lite.inc.js
32
16
  dependency install_rubigen_scripts
33
17
  exists script
34
18
  create script/generate
@@ -10,13 +10,12 @@ Feature: Can run 'newgem' to create RubyGem scaffolds
10
10
  When newgem is executed for project 'my_project' with no options
11
11
  Then file 'Rakefile' is created
12
12
  And does invoke generator 'install_test_unit'
13
- And does invoke generator 'install_website'
14
13
  And does invoke generator 'install_rubigen_scripts'
14
+ And does not invoke generator 'install_website'
15
15
  And does not invoke generator 'install_rspec'
16
16
  And does not invoke generator 'install_shoulda'
17
17
  And does not invoke generator 'install_cucumber'
18
- And file 'config/website.yml.sample' is created
19
- And yaml file 'config/website.yml.sample' contains {"host" => "unknown@rubyforge.org", "remote_dir" => "/var/www/gforge-projects/my_project"}
18
+ And file 'config/website.yml' is not created
20
19
  And output same as contents of 'newgem.out'
21
20
  And Rakefile can display tasks successfully
22
21
 
@@ -26,14 +25,6 @@ Feature: Can run 'newgem' to create RubyGem scaffolds
26
25
  When newgem is executed for project 'my-project' with no options
27
26
  Then Rakefile can display tasks successfully
28
27
 
29
- Scenario: Run newgem without any arguments, with env $RUBYFORGE_USERNAME set
30
- Given a safe folder
31
- Given env variable $RUBYFORGE_USERNAME set to 'nicwilliams'
32
- When newgem is executed for project 'my_project' with no options
33
- Then file 'config/website.yml.sample' is created
34
- And yaml file 'config/website.yml.sample' contains {"host" => "nicwilliams@rubyforge.org", "remote_dir" => "/var/www/gforge-projects/my_project"}
35
- And Rakefile can display tasks successfully
36
-
37
28
  Scenario: Run newgem to include rspec
38
29
  Given a safe folder
39
30
  When newgem is executed for project 'my_rspec_project' with options '-T rspec'
@@ -43,11 +34,20 @@ Feature: Can run 'newgem' to create RubyGem scaffolds
43
34
  And does not invoke generator 'install_cucumber'
44
35
  And Rakefile can display tasks successfully
45
36
 
46
- Scenario: Run newgem to disable website
37
+ Scenario: Run newgem to enable website
47
38
  Given a safe folder
48
- When newgem is executed for project 'my_project' with options '-W'
49
- Then does not invoke generator 'install_website'
50
- And file 'config/website.yml' is not created
39
+ When newgem is executed for project 'my_project' with options '-w'
40
+ Then does invoke generator 'install_website'
41
+ And file 'config/website.yml.sample' is created
42
+ And yaml file 'config/website.yml.sample' contains {"host" => "unknown@rubyforge.org", "remote_dir" => "/var/www/gforge-projects/my_project"}
43
+ And Rakefile can display tasks successfully
44
+
45
+ Scenario: Run newgem to enable website, with env $RUBYFORGE_USERNAME set
46
+ Given a safe folder
47
+ Given env variable $RUBYFORGE_USERNAME set to 'nicwilliams'
48
+ When newgem is executed for project 'my_project' with options '-w'
49
+ Then file 'config/website.yml.sample' is created
50
+ And yaml file 'config/website.yml.sample' contains {"host" => "nicwilliams@rubyforge.org", "remote_dir" => "/var/www/gforge-projects/my_project"}
51
51
  And Rakefile can display tasks successfully
52
52
 
53
53
  Scenario: Run newgem to install misc generators on top of unit test framework
@@ -11,3 +11,9 @@ Feature: Generated RubyGems have various rake tasks to aide their development
11
11
  And file matching 'pkg/my_project-0.0.1.gem' is created
12
12
  And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
13
13
  And gem spec key 'dependencies' contains /newgem \(>= [\d.]+, development\)/
14
+
15
+ Scenario: Hoe does not bitch about README.txt being missing
16
+ Given an existing newgem scaffold [called 'my_project'] that has 'README.rdoc' not 'README.txt'
17
+ When task 'rake -T' is invoked
18
+ Then output does not match /README.txt is missing/
19
+
@@ -1,11 +1,11 @@
1
1
  Given %r{^a safe folder} do
2
2
  FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
3
3
  FileUtils.mkdir_p @tmp_root
4
+ @newgem_lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
4
5
  end
5
6
 
6
7
  Given /^this project is active project folder/ do
7
- FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
8
- FileUtils.mkdir_p @tmp_root
8
+ Given "a safe folder"
9
9
  @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
10
10
  end
11
11
 
@@ -13,26 +13,28 @@ Given /^env variable \$([\w_]+) set to '(.*)'/ do |env_var, value|
13
13
  ENV[env_var] = value
14
14
  end
15
15
 
16
- def force_local_newgem_priority(project_name)
16
+ def force_local_newgem_priority(project_name = @project_name)
17
17
  rakefile = File.read(File.join(project_name, 'Rakefile'))
18
18
  File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
19
- f << "$:.unshift('#{File.expand_path(File.dirname(__FILE__) + '/../../lib')}')\n"
19
+ f << "$:.unshift('#{@newgem_lib_path}')\n"
20
20
  f << rakefile
21
21
  end
22
22
  end
23
23
 
24
- Given %r{^an existing newgem scaffold \[called '(.*)'\]$} do |project_name|
25
- # TODO this is a combo of "a safe folder" and "newgem is executed ..." steps; refactor
26
- FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
27
- FileUtils.mkdir_p @tmp_root
24
+ def setup_active_project_folder project_name
25
+ @active_project_folder = File.join(@tmp_root, project_name)
26
+ @project_name = project_name
27
+ end
28
+
29
+ Given %r{^an existing newgem scaffold \[called '(.*)'\]} do |project_name|
30
+ Given "a safe folder"
28
31
  newgem = File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
32
+ setup_active_project_folder project_name
29
33
  FileUtils.chdir @tmp_root do
30
34
  @stdout = "newgem.out"
31
35
  system "ruby #{newgem} #{project_name} > #{@stdout}"
32
- force_local_newgem_priority project_name
36
+ force_local_newgem_priority
33
37
  end
34
- @active_project_folder = File.join(@tmp_root, project_name)
35
- @project_name = project_name
36
38
  end
37
39
 
38
40
  Given /^project website configuration for safe folder on local machine$/ do
@@ -55,22 +57,21 @@ end
55
57
 
56
58
  When %r{^newgem is executed for project '(.*)' with no options$} do |project_name|
57
59
  newgem = File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
60
+ setup_active_project_folder project_name
58
61
  FileUtils.chdir @tmp_root do
59
62
  @stdout = "newgem.out"
60
63
  system "ruby #{newgem} #{project_name} > #{@stdout}"
61
- force_local_newgem_priority project_name
64
+ force_local_newgem_priority
62
65
  end
63
- @active_project_folder = File.expand_path(File.join(@tmp_root, project_name))
64
- @project_name = project_name
65
66
  end
66
67
 
67
68
  When %r{^newgem is executed for project '(.*)' with options '(.*)'$} do |project_name, arguments|
68
69
  newgem = File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
69
- @project_name = project_name
70
+ setup_active_project_folder project_name
70
71
  FileUtils.chdir @tmp_root do
71
72
  @stdout = "newgem.out"
72
73
  system "ruby #{newgem} #{arguments} #{project_name} > #{@stdout}"
73
- @active_project_folder = File.join(@tmp_root, project_name)
74
+ force_local_newgem_priority
74
75
  end
75
76
  end
76
77
 
@@ -100,9 +101,9 @@ When /^run unit tests for test file '(.*)'$/ do |test_file|
100
101
  end
101
102
 
102
103
  When /^task 'rake (.*)' is invoked$/ do |task|
103
- @raketask_stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
104
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
104
105
  FileUtils.chdir(@active_project_folder) do
105
- system "rake #{task} > #{@raketask_stdout} 2> #{@raketask_stdout}"
106
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
106
107
  end
107
108
  end
108
109
 
@@ -155,9 +156,11 @@ Then /^help options '(.*)' and '(.*)' are displayed$/ do |opt1, opt2|
155
156
  actual_output.should match(/#{opt2}/)
156
157
  end
157
158
 
158
- Then /^output matches \/(.*)\/$/ do |regex|
159
+ Then /^output (does|does not) match \/(.*)\/$/ do |does, regex|
159
160
  actual_output = File.read(@stdout)
160
- actual_output.should match(/#{regex}/)
161
+ (does == 'does') ?
162
+ actual_output.should(match(/#{regex}/)) :
163
+ actual_output.should_not(match(/#{regex}/))
161
164
  end
162
165
 
163
166
  Then /^all (\d+) tests pass$/ do |expected_test_count|
@@ -192,8 +195,8 @@ Then /^Rakefile can display tasks successfully$/ do
192
195
  end
193
196
 
194
197
  Then /^task 'rake (.*)' is executed successfully$/ do |task|
195
- @raketask_stdout.should_not be_nil
196
- actual_output = File.read(@raketask_stdout)
198
+ @stdout.should_not be_nil
199
+ actual_output = File.read(@stdout)
197
200
  actual_output.should_not match(/^Don't know how to build task '#{task}'/)
198
201
  actual_output.should_not match(/Error/i)
199
202
  end
data/lib/newgem.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
+ require "hoe-patched"
5
+
4
6
  module Newgem
5
- VERSION = '1.0.1'
7
+ VERSION = '1.0.2'
6
8
  end
data/tasks/cucumber.rake CHANGED
@@ -1,6 +1,9 @@
1
- gem 'cucumber'
2
- require 'cucumber/rake/task'
1
+ begin
2
+ gem 'cucumber'
3
+ require 'cucumber/rake/task'
3
4
 
4
- Cucumber::Rake::Task.new(:features) do |t|
5
- t.cucumber_opts = "--format pretty"
6
- end
5
+ Cucumber::Rake::Task.new(:features) do |t|
6
+ t.cucumber_opts = "--format pretty"
7
+ end
8
+ rescue LoadError
9
+ end
@@ -1,6 +1,11 @@
1
1
  task :release do
2
- puts "Remember to create tag your release; eg for Git:"
3
- puts " git tag REL-#{$hoe.version}"
2
+ puts <<-EOS.gsub(/^ /,'')
3
+ Remember to create tag your release; eg for Git:
4
+ git tag REL-#{$hoe.version}
5
+
6
+ Announce your release on RubyForge News:
7
+ rake post_news
8
+ EOS
4
9
  end
5
10
 
6
11
  desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
data/website/index.html CHANGED
@@ -39,7 +39,7 @@
39
39
 
40
40
  <div id="version"> <!-- class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return true' -->
41
41
  <p>Get Version</p>
42
- <a href="http://rubyforge.org/projects/newgem" class="numbers">1.0.1</a>
42
+ <a href="http://rubyforge.org/projects/newgem" class="numbers">1.0.2</a>
43
43
  <p>Featured in</p>
44
44
  <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FBeginning-Ruby-Novice-Professional-Experts%2Fdp%2F1590597664%2F&tag=drnic-20&linkCode=ur2&camp=1789&creative=9325" class="book"><img src="images/beginning-ruby.jpg" /></a>
45
45
  </div>
@@ -39,7 +39,7 @@
39
39
 
40
40
  <div id="version"> <!-- class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return true' -->
41
41
  <p>Get Version</p>
42
- <a href="http://rubyforge.org/projects/newgem" class="numbers">1.0.1</a>
42
+ <a href="http://rubyforge.org/projects/newgem" class="numbers">1.0.2</a>
43
43
  <p>Featured in</p>
44
44
  <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FBeginning-Ruby-Novice-Professional-Experts%2Fdp%2F1590597664%2F&tag=drnic-20&linkCode=ur2&camp=1789&creative=9325" class="book"><img src="images/beginning-ruby.jpg" /></a>
45
45
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-28 00:00:00 +10:00
12
+ date: 2008-10-30 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,16 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: 1.0.0
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: cucumber
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 0.1.9
74
+ version:
65
75
  - !ruby/object:Gem::Dependency
66
76
  name: hoe
67
77
  type: :development
@@ -252,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
262
  requirements: []
253
263
 
254
264
  rubyforge_project: newgem
255
- rubygems_version: 1.3.0
265
+ rubygems_version: 1.3.1
256
266
  signing_key:
257
267
  specification_version: 2
258
268
  summary: Quickly bundle any Ruby libraries into a RubyGem and share it with the world, your colleagues, or perhaps just with yourself amongst your projects