newgem 0.9.4 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,9 +1,20 @@
1
- +++ 0.9.4
1
+ +++ 0.10.0 2007-05-19
2
2
 
3
- + 3 minor enhancement
3
+ + 3 major enhancements
4
+ + can generate rspec default tests (or still test::unit tests) using --with-test=rspec [thx Robby Russell]
5
+ + fetches your full name and email from ~/.rubyforge/user-config.yml (add keys user_name and email)
6
+ + 2 minor enhancements
7
+ + Generated lib/#{gem_name}.rb includes an empty module
8
+ + Generated lib/#{gem_name}.rb does not include "require all", instead you do it manually for each included file
9
+
10
+ +++ 0.9.4 2007-05-18
11
+
12
+ + 5 minor enhancements
13
+ + Pass your full name into the generator to be inserted into License.txt, index.txt, Rakefile etc
4
14
  + 'Licence' => 'License' (thx Peter Burns)
5
15
  + Generates a blank index.html so that 'rake package' works straight away
6
16
  + Includes :local_deploy which does tasks :website_generate and :install_gem
17
+ + License.txt generated + this gem has a License.txt file (MIT license)
7
18
 
8
19
  +++ 0.9.3 20/4/2007
9
20
 
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2007 Dr Nic Williams
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -1,20 +1,25 @@
1
1
  History.txt
2
+ License.txt
2
3
  Manifest.txt
3
4
  README
4
5
  Rakefile
6
+ Todo.txt
5
7
  bin/newgem
6
8
  install.rb
7
9
  lib/newgem.rb
10
+ lib/newgem/rubyforge.rb
8
11
  lib/newgem/version.rb
9
12
  scripts/txt2html
10
13
  scripts/txt2js
11
14
  setup.rb
12
15
  templates/History.txt
16
+ templates/License.txt
13
17
  templates/Manifest.txt
14
18
  templates/Rakefile
15
19
  templates/app.rb
16
20
  templates/scripts/txt2html
17
21
  templates/setup.rb
22
+ templates/spec.rb
18
23
  templates/test.rb
19
24
  templates/website/index.html
20
25
  templates/website/index.txt
data/Todo.txt ADDED
@@ -0,0 +1,2 @@
1
+ + can generate rspec default tests (or still test::unit tests) using --with-test=rspec [thx Robby Russell]
2
+ + website components are now optional (-w/--no-website)
data/bin/newgem CHANGED
@@ -10,12 +10,17 @@ require 'fileutils'
10
10
  require 'active_support'
11
11
  require 'optparse'
12
12
 
13
+ require 'newgem'
14
+
13
15
  templates = File.dirname(__FILE__) + '/../templates/'
14
16
 
15
17
  OPTIONS = {
16
18
  :import_path => nil,
17
19
  :version => '0.0.1',
18
- :bin_name => nil
20
+ :full_name => nil,
21
+ :email => nil,
22
+ :bin_name => nil,
23
+ :test_framework => 'test::unit'
19
24
  }
20
25
  parser = OptionParser.new do |opts|
21
26
  opts.banner = <<BANNER
@@ -33,6 +38,15 @@ BANNER
33
38
  opts.on("-i", "--import_path=PATH", String,
34
39
  "Path where your files could be copied from.",
35
40
  "Default: none") { |OPTIONS[:import_path]| }
41
+ opts.on("-n", "--full_name=PATH", String,
42
+ "Your name to be inserted into generated files.",
43
+ "Default: ~/.rubyforge/user-config.yml[user_name]") { |OPTIONS[:full_name]| }
44
+ opts.on("-e", "--email=PATH", String,
45
+ "Your email to be inserted into generated files.",
46
+ "Default: ~/.rubyforge/user-config.yml[email]") { |OPTIONS[:email]| }
47
+ opts.on("-t", "--test-with=TEST_FRAMEWORK", String,
48
+ "Your preferred testing framework: Options: test::unit (default), rspec.",
49
+ "Default: test::unit") { |OPTIONS[:test_framework]| }
36
50
  opts.on("-v", "--version=YOUR_VERSION", String,
37
51
  "Version of the gem you are creating.",
38
52
  "Default: 0.0.1") { |OPTIONS[:version]| }
@@ -42,6 +56,14 @@ BANNER
42
56
  end
43
57
  OPTIONS[:version] = OPTIONS[:version].to_s.split(/\./)
44
58
  version_str = OPTIONS[:version].join('.')
59
+ author = OPTIONS[:full_name]
60
+ email = OPTIONS[:email]
61
+ unless author && email
62
+ rubyforge_config = Newgem::Rubyforge.new
63
+ author ||= rubyforge_config.full_name
64
+ email ||= rubyforge_config.email
65
+ end
66
+ test_framework = OPTIONS[:test_framework]
45
67
 
46
68
  gem_name = project_name = ARGV[0]
47
69
  parser.parse!(["-h"]) unless gem_name
@@ -52,22 +74,15 @@ lib_project_name = project_name + '/lib/' + project_name
52
74
  version = project_name + "/lib/" + project_name + "/version.rb"
53
75
  readme, setup = %w(README.txt setup.rb).
54
76
  collect {|f| project_name + '/' + f}
55
- template_files = %w(Rakefile Manifest.txt History.txt scripts/txt2html website/index.txt website/index.html website/template.rhtml)
77
+ template_files = %w(Rakefile History.txt License.txt Manifest.txt scripts/txt2html website/index.txt website/index.html website/template.rhtml)
56
78
  copy_files = %w(website/javascripts/rounded_corners_lite.inc.js website/stylesheets/screen.css)
57
79
 
58
-
59
- test = project_name + "/test"
60
80
  main = project_name + "/lib/" + project_name + ".rb"
61
- test_helper = test + "/test_helper.rb"
62
- unit_test = test + "/test_" + project_name + ".rb"
63
81
 
64
82
  examples = project_name + '/examples'
65
83
  bin = project_name + '/bin'
66
84
  folders = %w( scripts website website/javascripts website/stylesheets)
67
85
 
68
- # Rakefile variables
69
- author = ENV['USERNAME'] || ENV['USER'] || 'you'
70
-
71
86
  FileUtils.rm_rf project_name
72
87
 
73
88
  puts "creating: " + project_name
@@ -84,12 +99,12 @@ end
84
99
 
85
100
 
86
101
  puts "creating: " + lib
87
- Dir.mkdir lib
102
+ FileUtils.mkdir_p lib
88
103
 
89
104
  folders.each do |folder|
90
105
  new_folder = project_name + '/' + folder
91
106
  puts "creating: " + new_folder
92
- Dir.mkdir new_folder
107
+ FileUtils.mkdir_p new_folder
93
108
  end
94
109
 
95
110
  if OPTIONS[:import_path]
@@ -99,16 +114,21 @@ if OPTIONS[:import_path]
99
114
  end
100
115
 
101
116
  puts "creating: " + lib_project_name
102
- Dir.mkdir lib_project_name
117
+ FileUtils.mkdir_p lib_project_name
103
118
 
104
119
  puts "creating: " + main
105
120
  File.open(main, 'w') do |file|
106
- file << "Dir[File.join(File.dirname(__FILE__), '#{project_name}/**/*.rb')].sort.each { |lib| require lib }"
121
+ file << <<-EOS
122
+ module #{module_name}
123
+ end
124
+
125
+ require '#{module_name}/version'
126
+ EOS
107
127
  end
108
128
 
109
129
  puts "creating: " + version
110
130
  File.open(version, 'w') do |file|
111
- file << <<-eos
131
+ file << <<-EOS
112
132
  module #{module_name} #:nodoc:
113
133
  module VERSION #:nodoc:
114
134
  MAJOR = #{OPTIONS[:version][0] || '0'}
@@ -118,7 +138,7 @@ module #{module_name} #:nodoc:
118
138
  STRING = [MAJOR, MINOR, TINY].join('.')
119
139
  end
120
140
  end
121
- eos
141
+ EOS
122
142
  end
123
143
 
124
144
  puts "creating: " + bin
@@ -139,20 +159,41 @@ else
139
159
  bin_names_list = []
140
160
  end
141
161
 
162
+ # Setup spec/test::unit environments
163
+ # Would like to refactor this...
164
+ if test_framework == 'rspec'
165
+ test = project_name + "/spec"
166
+ test_helper = test + "/spec_helper.rb"
167
+ test_template = 'spec.rb'
168
+ unit_test = test + "/" + project_name + "_spec.rb"
169
+ test_file_prefix = 'spec/NAME_spec'
170
+ unit_test_template = <<-eos
171
+ require 'spec'
172
+ require File.dirname(__FILE__) + '/../lib/#{project_name}'
173
+ eos
174
+ else
175
+ test = project_name + "/test"
176
+ test_helper = test + "/test_helper.rb"
177
+ test_template = 'test.rb'
178
+ unit_test = test + "/test_" + project_name + ".rb"
179
+ test_file_prefix = 'test/test_NAME'
180
+ unit_test_template = <<-eos
181
+ require 'test/unit'
182
+ require File.dirname(__FILE__) + '/../lib/#{project_name}'
183
+ eos
184
+ end
142
185
 
143
186
  puts "creating: " + test
144
187
  Dir.mkdir test
145
188
 
146
189
  puts "creating: " + test_helper
147
190
  File.open(test_helper, 'w') do |file|
148
- file << <<-eos
149
- require 'test/unit'
150
- require File.dirname(__FILE__) + '/../lib/#{project_name}'
151
- eos
191
+ file << unit_test_template
152
192
  end
153
193
 
154
194
  puts "creating: " + unit_test
155
- template = File.open(templates + 'test.rb','r') {|f| f.readlines.join}
195
+
196
+ template = File.open(templates + test_template,'r') {|f| f.readlines.join}
156
197
  File.open(unit_test, 'w') do |file|
157
198
  file << eval('"' + template.gsub(/"/, '\"') + '"')
158
199
  end
@@ -168,7 +209,7 @@ end
168
209
 
169
210
  bin_names_list = bin_names_list.collect {|name| 'bin/' + name }.join("\n")
170
211
  bin_names_list += "\n" if bin_names_list.size > 0
171
- test_names_list = ['helper.rb',"#{project_name}.rb"].sort.collect {|name| 'test/test_' + name }.join("\n")
212
+ test_names_list = ['helper.rb',"#{project_name}.rb"].sort.collect {|name| test_file_prefix.gsub('NAME', name) + name }.join("\n")
172
213
 
173
214
  template_files.each do |template_file|
174
215
  puts "creating: " + project_name + '/' + template_file
data/lib/newgem.rb CHANGED
@@ -1 +1,5 @@
1
- Dir['newgem/**/*.rb'].each { |lib| require lib }
1
+ module Newgem #:nodoc:
2
+ end
3
+
4
+ require 'newgem/rubyforge'
5
+ require 'newgem/version'
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'rubyforge'
3
+
4
+ module Newgem
5
+ class Rubyforge
6
+ attr_reader :full_name, :email
7
+
8
+ def initialize
9
+ @full_name = rubyforge.userconfig['full_name'] || ENV['NAME'] || 'FIXME full name'
10
+ @email = rubyforge.userconfig['email'] || ENV['EMAIL'] || 'FIXME email'
11
+ end
12
+
13
+ def rubyforge
14
+ @rubyforge ||= RubyForge.new(::RubyForge::CONFIG_F)
15
+ end
16
+
17
+ end
18
+ end
@@ -1,8 +1,8 @@
1
1
  module Newgem #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 9
5
- TINY = 4
4
+ MINOR = 10
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,20 @@
1
+ Copyright (c) #{Time.now.year} #{author}
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/templates/Rakefile CHANGED
@@ -12,7 +12,7 @@ include FileUtils
12
12
  require File.join(File.dirname(__FILE__), 'lib', '#{gem_name}', 'version')
13
13
 
14
14
  AUTHOR = '#{author}' # can also be an array of Authors
15
- EMAIL = "your contact email for bug fixes and info"
15
+ EMAIL = "#{email}"
16
16
  DESCRIPTION = "description of gem"
17
17
  GEM_NAME = '#{gem_name}' # what ppl will type to install your gem
18
18
  RUBYFORGE_PROJECT = '#{gem_name}' # The unix name for your project
data/templates/spec.rb ADDED
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.rubyforge.org/
@@ -21,10 +21,12 @@ h2. Forum
21
21
 
22
22
  "http://groups.google.com/group/#{gem_name}":http://groups.google.com/group/#{gem_name}
23
23
 
24
+ TODO - create Google Group - #{gem_name}
25
+
24
26
  h2. License
25
27
 
26
28
  This code is free to use under the terms of the MIT license.
27
29
 
28
30
  h2. Contact
29
31
 
30
- Comments are welcome. Send an email to "Dr Nic Williams":mailto:drnicwilliams@gmail.com.
32
+ Comments are welcome. Send an email to "#{author}":mailto:#{email}.
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>New Gem Generator</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return false'>
35
35
  Get Version
36
- <a href="http://rubyforge.org/projects/newgem" class="numbers">0.9.4</a>
36
+ <a href="http://rubyforge.org/projects/newgem" class="numbers">0.10.0</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;newgem&#8217;</h1>
39
39
 
@@ -98,6 +98,9 @@ copying: wizzo/website/stylesheets/screen.css
98
98
  NOW - update wizzo/Rakefile with gem description, etc
99
99
  </pre>
100
100
 
101
+ <p>As of 0.10.0 &#8211; you can generate test::unit or rspec test stubs via the -t,&#8212;test-with options</p>
102
+
103
+
101
104
  <h3>Setup</h3>
102
105
 
103
106
 
@@ -287,7 +290,7 @@ other stories and things.</p>
287
290
 
288
291
  <p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a>.</p>
289
292
  <p class="coda">
290
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 10th May 2007<br>
293
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 19th May 2007<br>
291
294
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
292
295
  </p>
293
296
  </div>
data/website/index.txt CHANGED
@@ -52,6 +52,8 @@ copying: wizzo/website/stylesheets/screen.css
52
52
  NOW - update wizzo/Rakefile with gem description, etc
53
53
  </pre>
54
54
 
55
+ As of 0.10.0 - you can generate test::unit or rspec test stubs via the -t, --test-with options
56
+
55
57
  h3. Setup
56
58
 
57
59
  Now modify the constants at the top of *Rakefile*, with your name, email and the location where you'll host your website for the gem. The defaults are tied to RubyForge for uploading the gems and the website (see below).
@@ -33,7 +33,7 @@
33
33
  <h1>New Gem Generator</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return false'>
35
35
  Get Version
36
- <a href="http://rubyforge.org/projects/newgem" class="numbers">0.9.4</a>
36
+ <a href="http://rubyforge.org/projects/newgem" class="numbers">0.10.0</a>
37
37
  </div>
38
38
  <h1>&#x2192; using &#8216;rubyforge&#8217;</h1>
39
39
 
@@ -1,3 +1,3 @@
1
1
  // Announcement JS file
2
- var version = "0.9.4";
2
+ var version = "0.10.0";
3
3
  MagicAnnouncement.show('compositekeys', version);
data/website/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Version JS file
2
- var version = "0.9.4";
2
+ var version = "0.10.0";
3
3
 
4
4
  document.write(" - " + version);
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: newgem
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.4
7
- date: 2007-05-10 00:00:00 +02:00
6
+ version: 0.10.0
7
+ date: 2007-05-19 00:00:00 -07:00
8
8
  summary: Make your own gems at home
9
9
  require_paths:
10
10
  - lib
@@ -30,22 +30,27 @@ authors:
30
30
  - Dr Nic Williams
31
31
  files:
32
32
  - History.txt
33
+ - License.txt
33
34
  - Manifest.txt
34
35
  - README
35
36
  - Rakefile
37
+ - Todo.txt
36
38
  - bin/newgem
37
39
  - install.rb
38
40
  - lib/newgem.rb
41
+ - lib/newgem/rubyforge.rb
39
42
  - lib/newgem/version.rb
40
43
  - scripts/txt2html
41
44
  - scripts/txt2js
42
45
  - setup.rb
43
46
  - templates/History.txt
47
+ - templates/License.txt
44
48
  - templates/Manifest.txt
45
49
  - templates/Rakefile
46
50
  - templates/app.rb
47
51
  - templates/scripts/txt2html
48
52
  - templates/setup.rb
53
+ - templates/spec.rb
49
54
  - templates/test.rb
50
55
  - templates/website/index.html
51
56
  - templates/website/index.txt