newgem 0.29.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/History.txt +15 -1
  2. data/Manifest.txt +7 -22
  3. data/README.rdoc +55 -33
  4. data/Rakefile +22 -7
  5. data/app_generators/newgem/newgem_generator.rb +23 -23
  6. data/app_generators/newgem/templates/Rakefile +27 -3
  7. data/app_generators/newgem/templates/lib/module.rb +1 -1
  8. data/bin/newgem +12 -2
  9. data/config/website.yml +2 -0
  10. data/features/development.feature +22 -0
  11. data/features/executable_generator.feature +6 -6
  12. data/features/expected_outputs/newgem.out +2 -9
  13. data/features/install_cucumber.feature +11 -0
  14. data/features/install_website.feature +13 -0
  15. data/features/newgem_cli.feature +60 -0
  16. data/features/steps/cli.rb +125 -36
  17. data/features/steps/env.rb +4 -2
  18. data/lib/newgem/support/tasks.rb +10 -0
  19. data/lib/newgem/tasks.rb +1 -0
  20. data/lib/newgem.rb +5 -5
  21. data/newgem_generators/install_website/install_website_generator.rb +12 -9
  22. data/newgem_generators/install_website/templates/config/website.yml.sample.erb +2 -0
  23. data/newgem_generators/install_website/templates/script/txt2html +5 -16
  24. data/newgem_generators/install_website/templates/tasks/website.rake +34 -4
  25. data/rubygems_generators/executable/templates/test/test_cli.rb.erb +1 -1
  26. data/script/txt2html +5 -16
  27. data/tasks/deployment.rake +5 -6
  28. data/tasks/website.rake +34 -6
  29. data/test/test_install_website_generator.rb +1 -0
  30. data/test/test_newgem_generator.rb +0 -10
  31. data/website/index.html +27 -22
  32. data/website/index.txt +30 -19
  33. data/website/rubyforge.html +2 -2
  34. data/website/version.js +0 -4
  35. metadata +35 -67
  36. data/Todo.txt +0 -4
  37. data/app_generators/newgem/templates/config/hoe.rb +0 -82
  38. data/app_generators/newgem/templates/config/requirements.rb +0 -15
  39. data/app_generators/newgem/templates/lib/version.rb +0 -10
  40. data/app_generators/newgem/templates/setup.rb +0 -1585
  41. data/app_generators/newgem/templates/tasks/deployment.rake +0 -34
  42. data/app_generators/newgem/templates/tasks/environment.rake +0 -7
  43. data/app_generators/newgem/templates/tasks/website.rake +0 -9
  44. data/config/hoe.rb +0 -62
  45. data/features/cli.feature +0 -28
  46. data/features/steps/executable_generator.rb +0 -0
  47. data/lib/newgem/version.rb +0 -9
  48. data/rubygems_generators/install_rspec_stories/USAGE +0 -5
  49. data/rubygems_generators/install_rspec_stories/install_rspec_stories_generator.rb +0 -54
  50. data/rubygems_generators/install_rspec_stories/templates/all.rb +0 -8
  51. data/rubygems_generators/install_rspec_stories/templates/steps.rb +0 -13
  52. data/rubygems_generators/install_rspec_stories/templates/story.story +0 -9
  53. data/script/txt2html.rb +0 -70
  54. data/script/txt2js +0 -59
  55. data/setup.rb +0 -1585
  56. data/tasks/generator_report.rake +0 -19
  57. data/test/test_install_rspec_stories_generator.rb +0 -45
@@ -1,40 +1,82 @@
1
- Given %r{^a safe folder$} do
2
- $tmp_root = File.dirname(__FILE__) + "/../../tmp"
3
- FileUtils.rm_rf $tmp_root
1
+ Given %r{^a safe folder} do
2
+ FileUtils.rm_rf $tmp_root = File.dirname(__FILE__) + "/../../tmp"
4
3
  FileUtils.mkdir_p $tmp_root
5
4
  end
6
5
 
6
+ Given /^this project is active project folder/ do
7
+ FileUtils.rm_rf $tmp_root = File.dirname(__FILE__) + "/../../tmp"
8
+ FileUtils.mkdir_p $tmp_root
9
+ $active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
10
+ end
11
+
12
+ Given /^env variable \$([\w_]+) set to '(.*)'/ do |env_var, value|
13
+ ENV[env_var] = value
14
+ end
15
+
16
+ def force_local_newgem_priority(project_name)
17
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
18
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
19
+ f << "$:.unshift('#{File.expand_path(File.dirname(__FILE__) + '/../../lib')}')\n"
20
+ f << rakefile
21
+ end
22
+ end
23
+
7
24
  Given %r{^an existing newgem scaffold \[called '(.*)'\]$} do |project_name|
8
25
  # TODO this is a combo of "a safe folder" and "newgem is executed ..." steps; refactor
9
- $tmp_root = File.dirname(__FILE__) + "/../../tmp"
10
- FileUtils.rm_rf $tmp_root
26
+ FileUtils.rm_rf $tmp_root = File.dirname(__FILE__) + "/../../tmp"
11
27
  FileUtils.mkdir_p $tmp_root
12
28
  newgem = File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
13
29
  FileUtils.chdir $tmp_root do
14
- newgem_stdout = "newgem.out"
15
- system "ruby #{newgem} #{project_name} > #{newgem_stdout}"
30
+ @stdout = "newgem.out"
31
+ system "ruby #{newgem} #{project_name} > #{@stdout}"
32
+ force_local_newgem_priority project_name
33
+ end
34
+ $active_project_folder = File.join($tmp_root, project_name)
35
+ $project_name = project_name
36
+ end
37
+
38
+ Given /^project website configuration for safe folder on local machine$/ do
39
+ $remote_folder = File.expand_path(File.join($tmp_root, 'website'))
40
+ FileUtils.rm_rf $remote_folder
41
+ FileUtils.mkdir_p $remote_folder
42
+ FileUtils.chdir $active_project_folder do
43
+ FileUtils.mkdir_p 'config'
44
+ # config_yml = { "host" => "localhost", "remote_dir" => $remote_folder }.to_yaml
45
+ config_yml = { "remote_dir" => $remote_folder }.to_yaml
46
+ config_path = File.join('config', 'website.yml')
47
+ File.open(config_path, "w") { |io| io << config_yml }
48
+ end
49
+ end
50
+
51
+ Given /^'(.*)' folder is deleted/ do |folder|
52
+ FileUtils.chdir $active_project_folder do
53
+ FileUtils.rm_rf folder
16
54
  end
17
- @project_name = project_name
18
55
  end
19
56
 
20
57
  When %r{^newgem is executed for project '(.*)' with no options$} do |project_name|
21
58
  newgem = File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
59
+ $active_project_folder = File.expand_path(File.join($tmp_root, project_name))
60
+ $project_name = project_name
22
61
  FileUtils.chdir $tmp_root do
23
- @newgem_stdout = "newgem.out"
24
- system "ruby #{newgem} #{project_name} > #{@newgem_stdout}"
62
+ @stdout = "newgem.out"
63
+ system "ruby #{newgem} #{project_name} > #{@stdout}"
64
+ force_local_newgem_priority project_name
25
65
  end
26
66
  end
27
67
 
28
68
  When %r{^newgem is executed for project '(.*)' with options '(.*)'$} do |project_name, arguments|
29
69
  newgem = File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
70
+ $project_name = project_name
30
71
  FileUtils.chdir $tmp_root do
31
- @newgem_stdout = "newgem.out"
32
- system "ruby #{newgem} #{arguments} #{project_name} > #{@newgem_stdout}"
72
+ @stdout = "newgem.out"
73
+ system "ruby #{newgem} #{arguments} #{project_name} > #{@stdout}"
74
+ $active_project_folder = File.join($tmp_root, project_name)
33
75
  end
34
76
  end
35
77
 
36
78
  When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
37
- FileUtils.chdir(File.join($tmp_root, @project_name)) do
79
+ FileUtils.chdir($active_project_folder) do
38
80
  if Object.const_defined?("APP_ROOT")
39
81
  APP_ROOT.replace(FileUtils.pwd)
40
82
  else
@@ -45,60 +87,107 @@ When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, argu
45
87
  end
46
88
 
47
89
  When /^run executable '(.*)' with arguments '(.*)'$/ do |executable, arguments|
48
- FileUtils.chdir($tmp_root) do
49
- @stdout = "#{File.basename(executable)}.out"
90
+ @stdout = File.expand_path(File.join($tmp_root, "executable.out"))
91
+ FileUtils.chdir($active_project_folder) do
50
92
  system "ruby #{executable} #{arguments} > #{@stdout}"
51
93
  end
52
94
  end
53
95
 
54
96
  When /^run unit tests for test file '(.*)'$/ do |test_file|
55
- @test_stdout = File.expand_path(File.join($tmp_root, "tests.out"))
56
- FileUtils.chdir(File.join($tmp_root, @project_name)) do
57
- system "ruby #{test_file} > #{@test_stdout}"
97
+ @stdout = File.expand_path(File.join($tmp_root, "tests.out"))
98
+ FileUtils.chdir($active_project_folder) do
99
+ system "ruby #{test_file} > #{@stdout}"
58
100
  end
59
101
  end
60
102
 
61
- Then %r{^folder '(.*)' is created$} do |folder|
62
- FileUtils.chdir $tmp_root do
103
+ When /^task 'rake (.*)' is invoked$/ do |task|
104
+ @stdout = File.expand_path(File.join($tmp_root, "tests.out"))
105
+ FileUtils.chdir($active_project_folder) do
106
+ system "rake #{task} > #{@stdout} 2> #{@stdout}"
107
+ end
108
+ end
109
+
110
+ Then %r{^folder '(.*)' is created} do |folder|
111
+ FileUtils.chdir $active_project_folder do
63
112
  File.exists?(folder).should be_true
64
113
  end
65
114
  end
66
115
 
67
- Then %r{^file '(.*)' is created$} do |file|
68
- FileUtils.chdir $tmp_root do
69
- File.exists?(file).should be_true
116
+ Then %r{^remote folder '(.*)' is created} do |folder|
117
+ FileUtils.chdir $remote_folder do
118
+ File.exists?(folder).should be_true
70
119
  end
71
120
  end
72
121
 
73
- Then %r{^output matches '(.*)'$} do |file|
74
- expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
75
- actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@newgem_stdout}")
76
- actual_output.should == expected_output
122
+ Then %r{^file '(.*)' (is|is not) created} do |file, is|
123
+ FileUtils.chdir $active_project_folder do
124
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
125
+ end
77
126
  end
78
127
 
79
- Then %r{^invokes generator '(.*)'$} do |generator|
80
- actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@newgem_stdout}")
81
- actual_output.should match(/dependency\s+#{generator}/)
128
+ Then %r{^remote file '(.*)' (is|is not) created} do |file, is|
129
+ FileUtils.chdir $remote_folder do
130
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
131
+ end
82
132
  end
83
133
 
84
- Then %r{^does not invoke generator '(.*)'$} do |generator|
85
- actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@newgem_stdout}")
86
- actual_output.should_not match(/dependency\s+#{generator}/)
134
+ Then /^file matching '(.*)' is created$/ do |pattern|
135
+ FileUtils.chdir $active_project_folder do
136
+ Dir[pattern].should_not be_empty
137
+ end
87
138
  end
88
139
 
89
- Then /^help options '(.*)' and '(.*)' are displayed$/ do |opt1, opt2|
140
+ Then %r{^output same as contents of '(.*)'$} do |file|
141
+ expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
90
142
  actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
143
+ actual_output.should == expected_output
144
+ end
145
+
146
+ Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
147
+ actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
148
+ does_invoke == "does" ?
149
+ actual_output.should(match(/dependency\s+#{generator}/)) :
150
+ actual_output.should_not(match(/dependency\s+#{generator}/))
151
+ end
152
+
153
+ Then /^help options '(.*)' and '(.*)' are displayed$/ do |opt1, opt2|
154
+ actual_output = File.read(@stdout)
91
155
  actual_output.should match(/#{opt1}/)
92
156
  actual_output.should match(/#{opt2}/)
93
157
  end
94
158
 
95
159
  Then /^output matches \/(.*)\/$/ do |regex|
96
- actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
160
+ actual_output = File.read(@stdout)
97
161
  actual_output.should match(/#{regex}/)
98
162
  end
99
163
 
100
164
  Then /^all (\d+) tests pass$/ do |expected_test_count|
101
165
  expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
102
- actual_output = File.read(@test_stdout)
166
+ actual_output = File.read(@stdout)
103
167
  actual_output.should match(expected)
104
168
  end
169
+
170
+ Then /^yaml file '(.*)' contains (\{.*\})/ do |file, yaml|
171
+ FileUtils.chdir $active_project_folder do
172
+ yaml = eval yaml
173
+ YAML.load(File.read(file)).should == yaml
174
+ end
175
+ end
176
+
177
+ Then /^gem spec key '(.*)' contains \/(.*)\/$/ do |key, regex|
178
+ FileUtils.chdir $active_project_folder do
179
+ gem_file = Dir["pkg/*.gem"].first
180
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
181
+ spec_value = gem_spec.send(key.to_sym)
182
+ spec_value.to_s.should match(/#{regex}/)
183
+ end
184
+ end
185
+
186
+ Then /^Rakefile can display tasks successfully$/ do
187
+ @stdout = File.expand_path(File.join($tmp_root, "rakefile.out"))
188
+ FileUtils.chdir($active_project_folder) do
189
+ system "rake -T > #{@stdout} 2> #{@stdout}"
190
+ end
191
+ actual_output = File.read(@stdout)
192
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
193
+ end
@@ -1,9 +1,11 @@
1
1
  require File.dirname(__FILE__) + "/../../lib/newgem"
2
2
 
3
3
  require 'cucumber'
4
+ require 'spec'
4
5
 
5
- require "fileutils"
6
- require "spec"
6
+ require 'pp'
7
+ require 'fileutils'
8
+ require 'rubygems'
7
9
 
8
10
  # Following lines from original Rails cucumber generator.
9
11
  # Not sure how to translate/reuse etc yet.
@@ -0,0 +1,10 @@
1
+ Rake::TaskManager.class_eval do
2
+ def remove_task(task_name)
3
+ @tasks.delete(task_name.to_s)
4
+ end
5
+ end
6
+
7
+ def remove_task(task_name)
8
+ Rake.application.remove_task(task_name)
9
+ end
10
+
data/lib/newgem/tasks.rb CHANGED
@@ -1 +1,2 @@
1
+ require File.dirname(__FILE__) + '/support/tasks'
1
2
  Dir[File.join(File.dirname(__FILE__), %w[.. .. tasks], '**/*.rake')].each { |rake| load rake }
data/lib/newgem.rb CHANGED
@@ -1,6 +1,6 @@
1
- $:.unshift File.dirname(__FILE__)
2
-
3
- module Newgem #:nodoc:
4
- end
5
-
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
6
3
 
4
+ module Newgem
5
+ VERSION = '1.0.0'
6
+ end
@@ -11,39 +11,42 @@ class InstallWebsiteGenerator < RubiGen::Base
11
11
  :theme => 'plain_theme'
12
12
 
13
13
  attr_reader :gem_name, :module_name
14
- attr_reader :author, :email, :theme
14
+ attr_reader :author, :email, :theme, :rubyforge_username
15
15
 
16
16
  def initialize(runtime_args, runtime_options = {})
17
17
  super
18
- @destination_root = File.expand_path(destination_root)
19
- @gem_name = base_name
20
-
21
- @module_name = @gem_name.camelcase
18
+ @destination_root = File.expand_path(destination_root)
19
+ @gem_name = base_name
20
+ @module_name = @gem_name.camelcase
21
+ @rubyforge_username = ENV['RUBYFORGE_USERNAME'].nil? || ENV['RUBYFORGE_USERNAME'].empty? ? 'unknown' : ENV['RUBYFORGE_USERNAME']
22
22
  extract_options
23
23
  end
24
24
 
25
25
  def manifest
26
- script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
27
26
  windows = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
27
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
28
28
 
29
29
  record do |m|
30
30
  # Ensure appropriate folder(s) exists
31
31
  m.directory 'website/javascripts'
32
32
  m.directory 'website/stylesheets'
33
+ m.directory 'config'
33
34
  m.directory 'script'
34
35
  m.directory 'tasks'
35
36
 
36
37
  # Website
37
38
  m.template_copy_each %w( index.txt index.html ), "website"
38
39
 
40
+ m.template "config/website.yml.sample.erb", "config/website.yml.sample"
41
+
42
+ # m.file_copy_each %w[ website.rake ], "tasks"
43
+
39
44
  %w( txt2html ).each do |file|
40
45
  m.template "script/#{file}", "script/#{file}", script_options
41
46
  m.template "script/win_script.cmd", "script/#{file}.cmd",
42
47
  :assigns => { :filename => file } if windows
43
48
  end
44
49
 
45
- m.file_copy_each %w[ website.rake ], "tasks"
46
-
47
50
  m.dependency theme, [], :destination => destination_root
48
51
  end
49
52
  end
@@ -90,4 +93,4 @@ EOS
90
93
  end
91
94
  end
92
95
 
93
- end
96
+ end
@@ -0,0 +1,2 @@
1
+ host: <%= rubyforge_username %>@rubyforge.org
2
+ remote_dir: /var/www/gforge-projects/<%= gem_name %>
@@ -1,27 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- GEM_NAME = '<%= gem_name %>' # what ppl will type to install your gem
4
- RUBYFORGE_PROJECT = '<%= gem_name %>'
5
-
6
- require 'rubygems'
7
- begin
8
- require 'newgem'
9
- require 'rubyforge'
10
- rescue LoadError
11
- puts "\n\nGenerating the website requires the newgem RubyGem"
12
- puts "Install: gem install newgem\n\n"
13
- exit(1)
14
- end
3
+ load File.dirname(__FILE__) + "/../Rakefile"
4
+ require 'rubyforge'
15
5
  require 'redcloth'
16
6
  require 'syntax/convertors/html'
17
7
  require 'erb'
18
- require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
8
 
20
- version = <%= module_name %>::VERSION::STRING
21
- download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
9
+ download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
10
+ version = $hoe.version
22
11
 
23
12
  def rubyforge_project_id
24
- RubyForge.new.configure.autoconfig["group_ids"][RUBYFORGE_PROJECT]
13
+ RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
25
14
  end
26
15
 
27
16
  class Fixnum
@@ -1,3 +1,21 @@
1
+ require 'yaml'
2
+
3
+ def website_config
4
+ unless @website_config
5
+ begin
6
+ @website_config = YAML.load(File.read("config/website.yml"))
7
+ rescue
8
+ puts <<-EOS
9
+ To upload your website to a host, you need to configure
10
+ config/website.yml. See config/website.yml.sample for
11
+ an example.
12
+ EOS
13
+ exit
14
+ end
15
+ end
16
+ @website_config
17
+ end
18
+
1
19
  desc 'Generate website files'
2
20
  task :website_generate => :ruby_env do
3
21
  (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
@@ -7,10 +25,22 @@ end
7
25
 
8
26
  desc 'Upload website files to rubyforge'
9
27
  task :website_upload do
10
- host = "#{rubyforge_username}@rubyforge.org"
11
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
- local_dir = 'website'
13
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
28
+ local_dir = 'website'
29
+ host = website_config["host"]
30
+ host = host ? "#{host}:" : ""
31
+ remote_dir = website_config["remote_dir"]
32
+ sh %{rsync -aCv #{local_dir}/ #{host}#{remote_dir}}
33
+ end
34
+
35
+ remove_task :publish_docs # recreate hoe's rubyforge specific version
36
+
37
+ desc 'Publish RDoc to RubyForge.'
38
+ task :publish_docs => [:clean, :docs] do
39
+ local_dir = 'doc'
40
+ host = website_config["host"]
41
+ host = host ? "#{host}:" : ""
42
+ remote_dir = File.join(website_config["remote_dir"], "doc")
43
+ sh %{rsync -aCv #{local_dir}/ #{host}#{remote_dir}}
14
44
  end
15
45
 
16
46
  desc 'Generate and upload website files'
@@ -3,6 +3,6 @@ require '<%= bin_name %>/cli'
3
3
 
4
4
  class Test<%= module_name %>Cli < Test::Unit::TestCase
5
5
  def test_execute
6
- # <%= module_name %>::CLI.execute
6
+ <%= module_name %>::CLI.execute
7
7
  end
8
8
  end
data/script/txt2html CHANGED
@@ -1,27 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- GEM_NAME = 'newgem' # what ppl will type to install your gem
4
- RUBYFORGE_PROJECT = 'newgem'
5
-
6
- require 'rubygems'
7
- begin
8
- require 'newgem'
9
- require 'rubyforge'
10
- rescue LoadError
11
- puts "\n\nGenerating the website requires the newgem RubyGem"
12
- puts "Install: gem install newgem\n\n"
13
- exit(1)
14
- end
3
+ load File.dirname(__FILE__) + "/../Rakefile"
4
+ require 'rubyforge'
15
5
  require 'redcloth'
16
6
  require 'syntax/convertors/html'
17
7
  require 'erb'
18
- require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
8
 
20
- version = Newgem::VERSION::STRING
21
- download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
9
+ download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
10
+ version = $hoe.version
22
11
 
23
12
  def rubyforge_project_id
24
- RubyForge.new.configure.autoconfig["group_ids"][RUBYFORGE_PROJECT]
13
+ RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
25
14
  end
26
15
 
27
16
  class Fixnum
@@ -1,7 +1,6 @@
1
- desc 'Release the website and new gem version'
2
- task :deploy => [:check_version, :generator_report, :website, :release] do
3
- puts "Remember to create Git tag:"
4
- puts " git tag REL-#{VERS}"
1
+ task :release do
2
+ puts "Remember to create tag your release; eg for Git:"
3
+ puts " git tag REL-#{$hoe.version}"
5
4
  end
6
5
 
7
6
  desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
@@ -12,8 +11,8 @@ task :check_version do
12
11
  puts 'Must pass a VERSION=x.y.z release version'
13
12
  exit
14
13
  end
15
- unless ENV['VERSION'] == VERS
16
- puts "Please update your version.rb to match the release version, currently #{VERS}"
14
+ unless ENV['VERSION'] == $hoe.version
15
+ puts "Please update your version.rb to match the release version, currently #{$hoe.version}"
17
16
  exit
18
17
  end
19
18
  end
data/tasks/website.rake CHANGED
@@ -1,18 +1,46 @@
1
+ require 'yaml'
2
+
3
+ def website_config
4
+ unless @website_config
5
+ begin
6
+ @website_config = YAML.load(File.read("config/website.yml"))
7
+ rescue
8
+ puts <<-EOS
9
+ To upload your website to a host, you need to configure
10
+ config/website.yml. See config/website.yml.sample for
11
+ an example.
12
+ EOS
13
+ exit
14
+ end
15
+ end
16
+ @website_config
17
+ end
18
+
1
19
  desc 'Generate website files'
2
20
  task :website_generate => :ruby_env do
3
21
  (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
22
  sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
23
  end
6
- sh %{ #{RUBY_APP} script/txt2js website/version.txt > website/version.js }
7
- sh %{ #{RUBY_APP} script/txt2js website/version-raw.txt > website/version-raw.js }
8
24
  end
9
25
 
10
26
  desc 'Upload website files to rubyforge'
11
27
  task :website_upload do
12
- host = "#{rubyforge_username}@rubyforge.org"
13
- remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
14
- local_dir = 'website'
15
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
28
+ local_dir = 'website'
29
+ host = website_config["host"]
30
+ host = host ? "#{host}:" : ""
31
+ remote_dir = website_config["remote_dir"]
32
+ sh %{rsync -aCv #{local_dir}/ #{host}#{remote_dir}}
33
+ end
34
+
35
+ remove_task :publish_docs # recreate hoe's rubyforge specific version
36
+
37
+ desc 'Publish RDoc to RubyForge.'
38
+ task :publish_docs => [:clean, :docs] do
39
+ local_dir = 'doc'
40
+ host = website_config["host"]
41
+ host = host ? "#{host}:" : ""
42
+ remote_dir = File.join(website_config["remote_dir"], "rdoc")
43
+ sh %{rsync -aCv #{local_dir}/ #{host}#{remote_dir}}
16
44
  end
17
45
 
18
46
  desc 'Generate and upload website files'
@@ -18,6 +18,7 @@ class TestInstallWebsiteGenerator < Test::Unit::TestCase
18
18
  %w[index.txt index.html template.html.erb stylesheets/screen.css javascripts/rounded_corners_lite.inc.js].each do |file|
19
19
  assert_generated_file("website/#{file}")
20
20
  end
21
+ assert_generated_file("config/website.yml.sample")
21
22
  assert_generated_file("script/txt2html")
22
23
  assert_generated_file("tasks/website.rake")
23
24
  end
@@ -16,7 +16,6 @@ class TestNewgemGenerator < Test::Unit::TestCase
16
16
  def test_newgem
17
17
  run_generator('newgem', [APP_ROOT], sources)
18
18
 
19
- assert_directory_exists "config"
20
19
  assert_directory_exists "lib"
21
20
  assert_directory_exists "tasks"
22
21
  assert_directory_exists "test"
@@ -25,12 +24,7 @@ class TestNewgemGenerator < Test::Unit::TestCase
25
24
  assert_generated_file(file)
26
25
  end
27
26
 
28
- %w[hoe.rb requirements.rb].each do |file|
29
- assert_generated_file("config/#{file}")
30
- end
31
-
32
27
  assert_generated_file("lib/#{gem_name}.rb")
33
- assert_generated_file("lib/#{gem_name}/version.rb")
34
28
 
35
29
  ["test_helper.rb", "test_#{gem_name}.rb"].each do |file|
36
30
  assert_generated_file("test/#{file}")
@@ -42,10 +36,6 @@ class TestNewgemGenerator < Test::Unit::TestCase
42
36
 
43
37
  assert_generated_module("lib/#{gem_name}")
44
38
 
45
- %w[deployment environment website].each do |file|
46
- assert_generated_file("tasks/#{file}.rake")
47
- end
48
-
49
39
  assert_manifest_complete
50
40
  end
51
41