ore 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,23 @@
1
+ ### 0.9.3 / 2012-05-28
2
+
3
+ * Added the following template variables to {Ore::Generator}:
4
+ * `@scm_user` - The username used by the SCM.
5
+ * `@scm_email` - The email address used by the SCM.
6
+ * `@uri` - The URI parsed from the `@homepage` variable.
7
+ * `@markup_ext` - The file-extension used by the markup.
8
+ * Support autodetecting the user name by invoking `git config user.name` or
9
+ `hg showconfig ui.username`.
10
+ * Support autodetecting the email address by invoking `git config user.email` or
11
+ `hg showconfig ui.username`.
12
+
13
+ #### Templates
14
+
15
+ * Further simplified the `[name].gemspec` file in the [gemspec_yml]
16
+ template.
17
+ * Also fixed a small typo that set `gemspec.required_rubygems_version` to
18
+ the value of `required_ruby_version` from the `gemspec.yml` file.
19
+ * Fixed the `ChangeLog` entry in the `.document` file, from the [yard] template.
20
+
1
21
  ### 0.9.2 / 2012-05-21
2
22
 
3
23
  #### Templates
@@ -11,8 +11,7 @@ The name of the project can be listed like so:
11
11
 
12
12
  name: foo
13
13
 
14
- If the name is not listed, Ore will use the base-name of the project
15
- directory.
14
+ The name of the project must be specified.
16
15
 
17
16
  ## version
18
17
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  <%- if @email -%>
13
13
  gem.email = <%= @email.inspect %>
14
14
  <%- end -%>
15
- gem.homepage = <%= @homepage.to_s.inspect %>
15
+ gem.homepage = <%= @homepage.inspect %>
16
16
 
17
17
  <%- if git? -%>
18
18
  gem.files = `git ls-files`.split($/)
@@ -25,23 +25,23 @@ Gem::Specification.new do |gem|
25
25
  <%- end -%>
26
26
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
27
27
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
28
- gem.require_paths = ["lib"]
28
+ gem.require_paths = ['lib']
29
29
  <%- unless @dependencies.empty? -%>
30
30
 
31
31
  <%- @dependencies.each do |name,version| -%>
32
- gem.add_dependency <%= name.inspect %>, <%= version.inspect %>
32
+ gem.add_dependency '<%= name %>', '<%= version %>'
33
33
  <%- end -%>
34
34
  <%- end -%>
35
35
 
36
36
  <%- if bundler? -%>
37
- gem.add_development_dependency "bundler", <%= @development_dependencies['bundler'].inspect %>
37
+ gem.add_development_dependency 'bundler', '<%= @development_dependencies['bundler'] %>'
38
38
  <%- if yard? -%>
39
- gem.add_development_dependency "yard", <%= @development_dependencies['yard'].inspect %>
39
+ gem.add_development_dependency 'yard', '<%= @development_dependencies['yard'] %>'
40
40
  <%- end -%>
41
41
  <%- else -%>
42
42
  <%- unless @development_dependencies.empty? -%>
43
43
  <%- @development_dependencies.each do |name,version| -%>
44
- gem.add_development_dependency <%= name.inspect %>, <%= version.inspect %>
44
+ gem.add_development_dependency '<%= name%>', '<%= version %>'
45
45
  <%- end -%>
46
46
  <%- end -%>
47
47
  <%- end -%>end
@@ -2,111 +2,71 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
- Gem::Specification.new do |gemspec|
6
- root = File.dirname(__FILE__)
7
- lib_dir = File.join(root,'lib')
8
- <%- if git? -%>
9
- files = `git ls-files`.split($/)
10
- <%- elsif hg? -%>
11
- files = `hg manifest`.split($/)
12
- <%- elsif svn? -%>
13
- files = `svn ls -R`.split($/).select { |path| File.file?(path) }
14
- <%- else -%>
15
- files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
- <%- end -%>
17
-
18
- filter_files = lambda { |paths|
19
- files & case paths
20
- when Array
21
- paths
22
- when String
23
- Dir[paths]
24
- end
25
- }
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
26
7
 
27
- version = {
28
- :file => '<%= @namespace_path %>/version',
29
- :constant => '<%= @namespace %>::VERSION'
30
- }
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
31
12
 
32
- defaults = {
33
- 'name' => File.basename(root),
34
- 'files' => files,
35
- 'require_paths' => ['ext', 'lib'].select { |dir| File.directory?(dir) },
36
- 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
37
- 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
38
- 'doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
39
- 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}']
40
- }
13
+ require '<%= @namespace_path %>/version'
14
+ <%= @namespace %>::VERSION
15
+ end
41
16
 
42
- metadata = defaults.merge(YAML.load_file('gemspec.yml'))
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
43
23
 
44
- gemspec.name = metadata['name']
45
- gemspec.version = if metadata['version']
46
- metadata['version']
47
- else
48
- $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
24
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
49
25
 
50
- require version[:file]
51
- eval(version[:constant])
52
- end
53
-
54
- gemspec.summary = metadata.fetch('summary',metadata['description'])
55
- gemspec.description = metadata.fetch('description',metadata['summary'])
56
-
57
- gemspec.licenses = Array(metadata['license'])
58
- gemspec.authors = Array(metadata['authors'])
59
-
60
- gemspec.email = metadata['email']
61
- gemspec.homepage = metadata['homepage']
62
-
63
- gemspec.require_paths = Array(metadata['require_paths'])
64
- gemspec.files = filter_files[metadata['files']]
65
- gemspec.executables = metadata['executables']
66
- gemspec.extensions = metadata['extensions']
26
+ <%- if git? -%>
27
+ gem.files = `git ls-files`.split($/)
28
+ <%- elsif hg? -%>
29
+ gem.files = `hg manifest`.split($/)
30
+ <%- elsif svn? -%>
31
+ gem.files = `svn ls -R`.split($/).select { |path| File.file?(path) }
32
+ <%- else -%>
33
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
34
+ <%- end -%>
35
+ gem.files = glob[gemspec['files']] if gemspec['files']
67
36
 
68
- if Gem::VERSION < '1.7.'
69
- gemspec.default_executable = gemspec.executables.first
37
+ gem.executables = gemspec.fetch('executables') do
38
+ glob['bin/*'].map { |path| File.basename(path) }
70
39
  end
40
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
71
41
 
72
- gemspec.test_files = filter_files[metadata['test_files']]
73
- gemspec.extra_rdoc_files = Array(metadata['extra_doc_files'])
74
-
75
- gemspec.post_install_message = metadata['post_install_message']
76
- gemspec.requirements = metadata['requirements']
77
-
78
- if gemspec.respond_to?(:required_ruby_version=)
79
- gemspec.required_ruby_version = metadata['required_ruby_version']
80
- end
42
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
43
+ <%- if rspec? -%>
44
+ gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
45
+ <%- elsif test_unit? -%>
46
+ gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb}']
47
+ <%- end -%>
48
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,<%= @markup_ext %>}']
81
49
 
82
- if gemspec.respond_to?(:required_rubygems_version=)
83
- gemspec.required_rubygems_version = metadata['required_ruby_version']
84
- end
50
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
51
+ %w[ext lib].select { |dir| File.directory?(dir) }
52
+ })
85
53
 
86
- parse_versions = lambda { |versions|
87
- case versions
88
- when Array
89
- versions.map { |v| v.to_s }
90
- when String
91
- versions.split(/,\s*/)
92
- end
93
- }
54
+ gem.requirements = gemspec['requirements']
55
+ gem.required_ruby_version = gemspec['required_ruby_version']
56
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
57
+ gem.post_install_message = gemspec['post_install_message']
94
58
 
95
- if metadata['dependencies']
96
- metadata['dependencies'].each do |name,versions|
97
- gemspec.add_dependency(name,parse_versions[versions])
98
- end
99
- end
59
+ split = lambda { |string| string.split(/,\s*/) }
100
60
 
101
- if metadata['runtime_dependencies']
102
- metadata['runtime_dependencies'].each do |name,versions|
103
- gemspec.add_runtime_dependency(name,parse_versions[versions])
61
+ if gemspec['dependencies']
62
+ gemspec['dependencies'].each do |name,versions|
63
+ gem.add_dependency(name,split[versions])
104
64
  end
105
65
  end
106
66
 
107
- if metadata['development_dependencies']
108
- metadata['development_dependencies'].each do |name,versions|
109
- gemspec.add_development_dependency(name,parse_versions[versions])
67
+ if gemspec['development_dependencies']
68
+ gemspec['development_dependencies'].each do |name,versions|
69
+ gem.add_development_dependency(name,split[versions])
110
70
  end
111
71
  end
112
72
  end
@@ -6,7 +6,7 @@ class Test<%= @namespace %> < Test::Unit::TestCase
6
6
  def test_version
7
7
  version = <%= @namespace %>.const_get('VERSION')
8
8
 
9
- assert(!version.empty?, 'should have a VERSION constant')
9
+ assert !version.empty?, 'should have a VERSION constant'
10
10
  end
11
11
 
12
12
  end
@@ -1,3 +1,3 @@
1
1
  -
2
- ChangeLog.<%= @markup %>
2
+ ChangeLog.<%= @markup_ext || '*' %>
3
3
  LICENSE.txt
@@ -1,5 +1,5 @@
1
1
  name: ore
2
- version: 0.9.2
2
+ version: 0.9.3
3
3
  summary: Mine beautiful RubyGems from Ore
4
4
  description:
5
5
  Ore is a flexible Ruby project generator. Unlike other Ruby project
@@ -207,6 +207,26 @@ module Ore
207
207
  @project_dir = File.basename(@root)
208
208
  @name = (options.name || @project_dir)
209
209
 
210
+ @scm = if File.directory?(File.join(@root,'.git')) then :git
211
+ elsif File.directory?(File.join(@root,'.hg')) then :hg
212
+ elsif File.directory?(File.join(@root,'.svn')) then :svn
213
+ elsif options.hg? then :hg
214
+ elsif options.git? then :git
215
+ end
216
+
217
+ case @scm
218
+ when :git
219
+ @scm_user = `git config user.name`.chomp
220
+ @scm_email = `git config user.email`.chomp
221
+
222
+ @github_user = `git config github.user`.chomp
223
+ when :hg
224
+ user_email = `hg showconfig ui.username`.chomp
225
+ user_email.scan(/([^<]+)\s+<([^>]+)>/) do |(user,email)|
226
+ @scm_user, @scm_email = user, email
227
+ end
228
+ end
229
+
210
230
  @modules = modules_of(@name)
211
231
  @module_depth = @modules.length
212
232
  @module = @modules.last
@@ -220,45 +240,33 @@ module Ore
220
240
  @summary = options.summary
221
241
  @description = options.description
222
242
  @license = options.license
223
- @authors = options.authors
243
+
244
+ @authors = (options.authors || [@scm_user || ENV['USER']])
224
245
  @author = @authors.first
225
- @github_user = if options.git?
226
- `git config github.user`.chomp
227
- end
228
246
 
229
- @email = options.email
247
+ @email = (options.email || @scm_email)
230
248
  @safe_email = @email.sub('@',' at ') if @email
249
+
231
250
  @homepage = if options.homepage
232
- URI(options.homepage)
251
+ options.homepage
233
252
  elsif !(@github_user.nil? || @github_user.empty?)
234
- URI("https://github.com/#{@github_user}/#{@name}#readme")
253
+ "https://github.com/#{@github_user}/#{@name}#readme"
235
254
  else
236
- URI("https://rubygems.org/gems/#{@name}")
255
+ "https://rubygems.org/gems/#{@name}"
237
256
  end
238
- @bug_tracker = case @homepage.host
257
+ @uri = URI(@homepage)
258
+ @bug_tracker = case @uri.host
239
259
  when 'github.com'
240
- "https://#{@homepage.host}#{@homepage.path}/issues"
260
+ "https://#{@uri.host}#{@uri.path}/issues"
241
261
  end
242
262
 
243
- @markup = if options.markdown?
244
- :markdown
245
- elsif options.textile?
246
- :textile
247
- else
248
- :rdoc
249
- end
250
-
251
- @scm = if File.directory?(File.join(@root,'.git'))
252
- :git
253
- elsif File.directory?(File.join(@root,'.hg'))
254
- :hg
255
- elsif File.directory?(File.join(@root,'.svn'))
256
- :svn
257
- elsif options.hg?
258
- :hg
259
- elsif options.git?
260
- :git
261
- end
263
+ @markup, @markup_ext = if options.markdown?
264
+ [:markdown, 'md']
265
+ elsif options.textile?
266
+ [:textile, 'tt']
267
+ else
268
+ [:rdoc, 'rdoc']
269
+ end
262
270
 
263
271
  @date = Date.today
264
272
  @year = @date.year
@@ -271,6 +279,7 @@ module Ore
271
279
 
272
280
  @templates.each do |template|
273
281
  @ignore.merge(template.ignore)
282
+
274
283
  @dependencies.merge!(template.dependencies)
275
284
  @development_dependencies.merge!(template.development_dependencies)
276
285
 
@@ -20,9 +20,6 @@ module Ore
20
20
  # Default License
21
21
  DEFAULT_LICENSE = 'MIT'
22
22
 
23
- # Default authors
24
- DEFAULT_AUTHORS = [ENV['USER']]
25
-
26
23
  def self.included(base)
27
24
  base.extend ClassMethods
28
25
  end
@@ -40,7 +37,6 @@ module Ore
40
37
  :summary => DEFAULT_SUMMARY,
41
38
  :description => DEFAULT_DESCRIPTION,
42
39
  :license => DEFAULT_LICENSE,
43
- :authors => DEFAULT_AUTHORS,
44
40
  :gemspec => true,
45
41
  :rubygems_tasks => true,
46
42
  :rdoc => true,
@@ -2,110 +2,59 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
- Gem::Specification.new do |gemspec|
6
- root = File.dirname(__FILE__)
7
- lib_dir = File.join(root,'lib')
8
- files = if File.directory?('.git')
9
- `git ls-files`.split($/)
10
- elsif File.directory?('.hg')
11
- `hg manifest`.split($/)
12
- elsif File.directory?('.svn')
13
- `svn ls -R`.split($/).select { |path| File.file?(path) }
14
- else
15
- Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
- end
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
17
7
 
18
- filter_files = lambda { |paths|
19
- files & case paths
20
- when Array
21
- paths
22
- when String
23
- Dir[paths]
24
- end
25
- }
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
26
12
 
27
- version = {
28
- :file => 'ore/version.rb',
29
- :constant => 'Ore::VERSION'
30
- }
13
+ require 'ore/version'
14
+ Ore::VERSION
15
+ end
31
16
 
32
- defaults = {
33
- 'name' => File.basename(File.dirname(__FILE__)),
34
- 'files' => files,
35
- 'require_paths' => ['ext', 'lib'].select { |dir| File.directory?(dir) },
36
- 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
37
- 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
38
- 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}']
39
- }
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
40
23
 
41
- metadata = defaults.merge(YAML.load_file('gemspec.yml'))
24
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
42
25
 
43
- gemspec.name = metadata['name']
44
- gemspec.version = if metadata['version']
45
- metadata['version']
46
- else
47
- $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
26
+ gem.files = `git ls-files`.split($/)
27
+ gem.files = glob[gemspec['files']] if gemspec['files']
48
28
 
49
- require version[:file]
50
- eval(version[:constant])
51
- end
52
-
53
- gemspec.summary = metadata.fetch('summary',metadata['description'])
54
- gemspec.description = metadata.fetch('description',metadata['summary'])
55
-
56
- gemspec.licenses = Array(metadata['license'])
57
- gemspec.authors = Array(metadata['authors'])
58
-
59
- gemspec.email = metadata['email']
60
- gemspec.homepage = metadata['homepage']
61
-
62
- gemspec.require_paths = Array(metadata['require_paths'])
63
- gemspec.files = filter_files[metadata['files']]
64
- gemspec.executables = metadata['executables']
65
- gemspec.extensions = metadata['extensions']
66
-
67
- if Gem::VERSION < '1.7.'
68
- gemspec.default_executable = gemspec.executables.first
29
+ gem.executables = gemspec.fetch('executables') do
30
+ glob['bin/*'].map { |path| File.basename(path) }
69
31
  end
32
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
70
33
 
71
- gemspec.test_files = filter_files[metadata['test_files']]
72
- gemspec.extra_rdoc_files = Array(metadata['extra_doc_files'])
73
-
74
- gemspec.post_install_message = metadata['post_install_message']
75
- gemspec.requirements = metadata['requirements']
34
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
35
+ gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
36
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
76
37
 
77
- if gemspec.respond_to?(:required_ruby_version=)
78
- gemspec.required_ruby_version = metadata['required_ruby_version']
79
- end
80
-
81
- if gemspec.respond_to?(:required_rubygems_version=)
82
- gemspec.required_rubygems_version = metadata['required_ruby_version']
83
- end
38
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
39
+ %w[ext lib].select { |dir| File.directory?(dir) }
40
+ })
84
41
 
85
- parse_versions = lambda { |versions|
86
- case versions
87
- when Array
88
- versions.map { |v| v.to_s }
89
- when String
90
- versions.split(/,\s*/)
91
- end
92
- }
42
+ gem.requirements = gemspec['requirements']
43
+ gem.required_ruby_version = gemspec['required_ruby_version']
44
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
45
+ gem.post_install_message = gemspec['post_install_message']
93
46
 
94
- if metadata['dependencies']
95
- metadata['dependencies'].each do |name,versions|
96
- gemspec.add_dependency(name,parse_versions[versions])
97
- end
98
- end
47
+ split = lambda { |string| string.split(/,\s*/) }
99
48
 
100
- if metadata['runtime_dependencies']
101
- metadata['runtime_dependencies'].each do |name,versions|
102
- gemspec.add_runtime_dependency(name,parse_versions[versions])
49
+ if gemspec['dependencies']
50
+ gemspec['dependencies'].each do |name,versions|
51
+ gem.add_dependency(name,split[versions])
103
52
  end
104
53
  end
105
54
 
106
- if metadata['development_dependencies']
107
- metadata['development_dependencies'].each do |name,versions|
108
- gemspec.add_development_dependency(name,parse_versions[versions])
55
+ if gemspec['development_dependencies']
56
+ gemspec['development_dependencies'].each do |name,versions|
57
+ gem.add_development_dependency(name,split[versions])
109
58
  end
110
59
  end
111
60
  end
@@ -24,7 +24,7 @@ shared_examples "a gemspec" do
24
24
  end
25
25
 
26
26
  it "should have authors" do
27
- subject.authors.should == Ore::Options::DEFAULT_AUTHORS
27
+ subject.authors.should_not be_empty
28
28
  end
29
29
 
30
30
  it "should have a dummy homepage" do
@@ -101,7 +101,7 @@ describe Generator do
101
101
  end
102
102
 
103
103
  it "should have authors" do
104
- subject['authors'].should == Ore::Options::DEFAULT_AUTHORS[0]
104
+ subject['authors'].should_not be_empty
105
105
  end
106
106
 
107
107
  it "should have a dummy homepage" do
@@ -345,6 +345,12 @@ describe Generator do
345
345
  it "should set --markup to markdown in .yardopts" do
346
346
  yard_opts.should include('--markup markdown')
347
347
  end
348
+
349
+ context ".document" do
350
+ it "should include 'ChangeLog.md'" do
351
+ document.should include('ChangeLog.md')
352
+ end
353
+ end
348
354
  end
349
355
 
350
356
  context "yard with textile" do
@@ -365,6 +371,12 @@ describe Generator do
365
371
  it "should set --markup to textile in .yardopts" do
366
372
  yard_opts.should include('--markup textile')
367
373
  end
374
+
375
+ context ".document" do
376
+ it "should include 'ChangeLog.tt'" do
377
+ document.should include('ChangeLog.tt')
378
+ end
379
+ end
368
380
  end
369
381
 
370
382
  context "yard with bundler" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -200,6 +200,4 @@ rubygems_version: 1.8.24
200
200
  signing_key:
201
201
  specification_version: 3
202
202
  summary: Mine beautiful RubyGems from Ore
203
- test_files:
204
- - spec/generator_spec.rb
205
- - spec/naming_spec.rb
203
+ test_files: []