ore 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/.gitignore +10 -0
  2. data/ChangeLog.md +70 -7
  3. data/LICENSE.txt +1 -1
  4. data/README.md +93 -88
  5. data/Rakefile +5 -5
  6. data/data/ore/templates/base/README.md.erb +3 -0
  7. data/data/ore/templates/base/README.rdoc.erb +3 -0
  8. data/data/ore/templates/base/README.tt.erb +3 -0
  9. data/data/ore/templates/base/template.yml +2 -2
  10. data/data/ore/templates/bin/bin/[name].erb +1 -1
  11. data/data/ore/templates/bundler/Gemfile.erb +14 -3
  12. data/data/ore/templates/bundler/template.yml +7 -2
  13. data/data/ore/templates/bundler_tasks/_tasks.erb +1 -0
  14. data/data/ore/templates/bundler_tasks/template.yml +6 -0
  15. data/data/ore/templates/gem_package_task/_tasks.erb +5 -0
  16. data/data/ore/templates/gem_package_task/template.yml +4 -0
  17. data/data/ore/templates/gemspec/[name].gemspec.erb +45 -0
  18. data/data/ore/templates/gemspec/template.yml +2 -0
  19. data/data/ore/templates/{base → gemspec_yml}/[name].gemspec.erb +36 -55
  20. data/data/ore/templates/gemspec_yml/gemspec.yml.erb +41 -0
  21. data/data/ore/templates/gemspec_yml/template.yml +2 -0
  22. data/data/ore/templates/git/.gitignore.erb +3 -0
  23. data/data/ore/templates/git/template.yml +2 -0
  24. data/data/ore/templates/hg/.hgignore.erb +3 -0
  25. data/data/ore/templates/hg/template.yml +2 -0
  26. data/data/ore/templates/jeweler_tasks/_tasks.erb +3 -12
  27. data/data/ore/templates/jeweler_tasks/template.yml +4 -3
  28. data/data/ore/templates/rdoc/_tasks.erb +1 -1
  29. data/data/ore/templates/rdoc/template.yml +3 -0
  30. data/data/ore/templates/rspec/_tasks.erb +1 -1
  31. data/data/ore/templates/rspec/spec/spec_helper.rb.erb +1 -1
  32. data/data/ore/templates/rspec/template.yml +2 -2
  33. data/data/ore/templates/rubygems_tasks/_tasks.erb +14 -0
  34. data/data/ore/templates/rubygems_tasks/template.yml +7 -0
  35. data/data/ore/templates/rvmrc/.rvmrc.erb +9 -15
  36. data/data/ore/templates/yard/_gemfile_development.erb +0 -1
  37. data/data/ore/templates/yard/_tasks.erb +1 -1
  38. data/data/ore/templates/yard/template.yml +5 -2
  39. data/gemspec.yml +5 -7
  40. data/lib/ore.rb +0 -2
  41. data/lib/ore/actions.rb +85 -0
  42. data/lib/ore/cli.rb +2 -32
  43. data/lib/ore/config.rb +20 -20
  44. data/lib/ore/generator.rb +101 -203
  45. data/lib/ore/naming.rb +160 -0
  46. data/lib/ore/options.rb +67 -0
  47. data/lib/ore/template.rb +8 -0
  48. data/lib/ore/template/directory.rb +60 -41
  49. data/lib/ore/template/helpers.rb +55 -7
  50. data/lib/ore/template/template.rb +61 -0
  51. data/ore.gemspec +35 -55
  52. data/spec/gemspec_examples.rb +33 -0
  53. data/spec/generator_spec.rb +188 -70
  54. data/spec/helpers/generator.rb +4 -2
  55. data/spec/helpers/matchers.rb +33 -0
  56. data/spec/naming_spec.rb +56 -0
  57. data/spec/spec_helper.rb +1 -1
  58. metadata +104 -117
  59. data/data/ore/templates/base/.gitignore.erb +0 -3
  60. data/data/ore/templates/base/_gemfile_development.erb +0 -3
  61. data/data/ore/templates/base/gemspec.yml.erb +0 -30
  62. data/data/ore/templates/bundler/_development_dependencies.erb +0 -1
  63. data/data/ore/templates/bundler/_gitignore.erb +0 -2
  64. data/data/ore/templates/bundler/_tasks.erb +0 -3
  65. data/data/ore/templates/jeweler_tasks/_development_dependencies.erb +0 -3
  66. data/data/ore/templates/jeweler_tasks/_gemfile_development.erb +0 -1
  67. data/data/ore/templates/ore_tasks/_development_dependencies.erb +0 -3
  68. data/data/ore/templates/ore_tasks/_gemfile_development.erb +0 -1
  69. data/data/ore/templates/ore_tasks/_tasks.erb +0 -14
  70. data/data/ore/templates/ore_tasks/template.yml +0 -5
  71. data/data/ore/templates/rdoc/_gitignore.erb +0 -1
  72. data/data/ore/templates/rspec/_development_dependencies.erb +0 -3
  73. data/data/ore/templates/rspec/_gemfile_development.erb +0 -1
  74. data/data/ore/templates/yard/_development_dependencies.erb +0 -1
@@ -1,2 +1,7 @@
1
- variables:
2
- bundler_dependency: ~> 1.0.0
1
+ ignore:
2
+ - Gemfile.lock
3
+ - vendor/cache/*.gem
4
+
5
+ development_dependencies:
6
+ bundler: ~> 1.0
7
+ rake: ~> 0.8
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ enable:
2
+ - bundler
3
+
4
+ disable:
5
+ - rubygems_tasks
6
+ - jeweler_tasks
@@ -0,0 +1,5 @@
1
+ require 'rubygems/package_task'
2
+ Gem::PackageTask.new(Gem::Specification.load('<%= @name %>.gemspec')) do |pkg|
3
+ pkg.need_tar = true
4
+ pkg.need_zip = false
5
+ end
@@ -0,0 +1,4 @@
1
+ disable:
2
+ - rubygems_tasks
3
+ - jeweler_tasks
4
+ - bundler_tasks
@@ -0,0 +1,45 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/<%= @namespace_path %>/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = <%= @name.inspect %>
7
+ gem.version = <%= @namespace %>::VERSION
8
+ gem.summary = %q{<%= @summary %>}
9
+ gem.description = %q{<%= @description %>}
10
+ gem.license = <%= @license.inspect %>
11
+ gem.authors = <%= @authors.inspect %>
12
+ gem.email = [<%= @email.inspect %>]
13
+ gem.homepage = <%= @homepage.inspect %>
14
+
15
+ <%- if git? -%>
16
+ gem.files = `git ls-files`.split($/)
17
+ <%- elsif hg? -%>
18
+ gem.files = `hg manifest`.split($/)
19
+ <%- elsif svn? -%>
20
+ gem.files = `svn ls -R`.split($/).select { |path| File.file?(path) }
21
+ <%- else -%>
22
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
23
+ <%- end -%>
24
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
25
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
+ gem.require_paths = ["lib"]
27
+ <%- unless @dependencies.empty? -%>
28
+
29
+ <%- @dependencies.each do |name,version| -%>
30
+ gem.add_dependency <%= name.inspect %>, <%= version.inspect %>
31
+ <%- end -%>
32
+ <%- end -%>
33
+
34
+ <%- if bundler? -%>
35
+ gem.add_development_dependency "bundler", <%= @development_dependencies['bundler'].inspect %>
36
+ <%- if yard? -%>
37
+ gem.add_development_dependency "yard", <%= @development_dependencies['yard'].inspect %>
38
+ <%- end -%>
39
+ <%- else -%>
40
+ <%- unless @development_dependencies.empty? -%>
41
+ <%- @development_dependencies.each do |name,version| -%>
42
+ gem.add_development_dependency <%= name.inspect %>, <%= version.inspect %>
43
+ <%- end -%>
44
+ <%- end -%>
45
+ <%- end -%>end
@@ -0,0 +1,2 @@
1
+ disable:
2
+ - gemspec_yml
@@ -3,43 +3,45 @@
3
3
  require 'yaml'
4
4
 
5
5
  Gem::Specification.new do |gemspec|
6
- root = File.dirname(__FILE__)
6
+ root = File.dirname(__FILE__)
7
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
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
17
 
18
18
  filter_files = lambda { |paths|
19
- case paths
20
- when Array
21
- (files & paths)
22
- when String
23
- (files & Dir[paths])
24
- end
19
+ files & case paths
20
+ when Array
21
+ paths
22
+ when String
23
+ Dir[paths]
24
+ end
25
25
  }
26
26
 
27
27
  version = {
28
- :file => '<%= @namespace_dir %>/version',
28
+ :file => '<%= @namespace_path %>/version',
29
29
  :constant => '<%= @namespace %>::VERSION'
30
30
  }
31
31
 
32
32
  defaults = {
33
- 'name' => File.basename(root),
34
- 'files' => files,
35
- 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
36
- 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
37
- 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
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}']
38
40
  }
39
41
 
40
42
  metadata = defaults.merge(YAML.load_file('gemspec.yml'))
41
43
 
42
- gemspec.name = metadata['name']
44
+ gemspec.name = metadata['name']
43
45
  gemspec.version = if metadata['version']
44
46
  metadata['version']
45
47
  else
@@ -49,50 +51,29 @@ Gem::Specification.new do |gemspec|
49
51
  eval(version[:constant])
50
52
  end
51
53
 
52
- gemspec.summary = metadata.fetch('summary',metadata['description'])
54
+ gemspec.summary = metadata.fetch('summary',metadata['description'])
53
55
  gemspec.description = metadata.fetch('description',metadata['summary'])
54
56
 
55
- case metadata['license']
56
- when Array
57
- gemspec.licenses = metadata['license']
58
- when String
59
- gemspec.license = metadata['license']
60
- end
61
-
62
- case metadata['authors']
63
- when Array
64
- gemspec.authors = metadata['authors']
65
- when String
66
- gemspec.author = metadata['authors']
67
- end
57
+ gemspec.licenses = Array(metadata['license'])
58
+ gemspec.authors = Array(metadata['authors'])
68
59
 
69
- gemspec.email = metadata['email']
60
+ gemspec.email = metadata['email']
70
61
  gemspec.homepage = metadata['homepage']
71
62
 
72
- case metadata['require_paths']
73
- when Array
74
- gemspec.require_paths = metadata['require_paths']
75
- when String
76
- gemspec.require_path = metadata['require_paths']
77
- end
78
-
79
- gemspec.files = filter_files[metadata['files']]
80
-
81
- gemspec.executables = metadata['executables']
82
- gemspec.extensions = metadata['extensions']
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']
83
67
 
84
68
  if Gem::VERSION < '1.7.'
85
69
  gemspec.default_executable = gemspec.executables.first
86
70
  end
87
71
 
88
- gemspec.test_files = filter_files[metadata['test_files']]
89
-
90
- unless gemspec.files.include?('.document')
91
- gemspec.extra_rdoc_files = metadata['extra_doc_files']
92
- end
72
+ gemspec.test_files = filter_files[metadata['test_files']]
73
+ gemspec.extra_rdoc_files = Array(metadata['extra_doc_files'])
93
74
 
94
75
  gemspec.post_install_message = metadata['post_install_message']
95
- gemspec.requirements = metadata['requirements']
76
+ gemspec.requirements = metadata['requirements']
96
77
 
97
78
  if gemspec.respond_to?(:required_ruby_version=)
98
79
  gemspec.required_ruby_version = metadata['required_ruby_version']
@@ -0,0 +1,41 @@
1
+ name: <%= @name %>
2
+ summary: <%= yaml_escape @summary %>
3
+ description: <%= yaml_escape @description %>
4
+ <%- if @license -%>
5
+ license: <%= @license %>
6
+ <%- end -%>
7
+ <%- if @authors.length > 1 -%>
8
+ authors:
9
+ <%- @authors.each do |name| -%>
10
+ - <%= name %>
11
+ <%- end -%>
12
+ <%- else -%>
13
+ authors: <%= @authors.first %>
14
+ <%- end -%>
15
+ <%- if @email -%>
16
+ email: <%= @email %>
17
+ <%- end -%>
18
+ homepage: <%= @homepage %>
19
+ <%= includes :gemspec, '' -%>
20
+ <%- unless @dependencies.empty? -%>
21
+
22
+ dependencies:
23
+ <%- @dependencies.each do |name,version| -%>
24
+ <%= name %>: <%= version %>
25
+ <%- end -%>
26
+ <%- end -%>
27
+
28
+ <%- if bundler? -%>
29
+ development_dependencies:
30
+ bundler: <%= @development_dependencies['bundler'] %>
31
+ <%- if yard? -%>
32
+ yard: <%= @development_dependencies['yard'] %>
33
+ <%- end -%>
34
+ <%- else -%>
35
+ <%- unless @development_dependencies.empty? -%>
36
+ development_dependencies:
37
+ <%- @development_dependencies.each do |name,version| -%>
38
+ <%= name %>: <%= version %>
39
+ <%- end -%>
40
+ <%- end -%>
41
+ <%- end -%>
@@ -0,0 +1,2 @@
1
+ disable:
2
+ - gemspec
@@ -0,0 +1,3 @@
1
+ <%- @ignore.each do |pattern| -%>
2
+ <%= pattern %>
3
+ <%- end -%>
@@ -0,0 +1,2 @@
1
+ disable:
2
+ - hg
@@ -0,0 +1,3 @@
1
+ <%- @ignore.each do |pattern| -%>
2
+ <%= pattern %>
3
+ <%- end -%>
@@ -0,0 +1,2 @@
1
+ disable:
2
+ - git
@@ -1,21 +1,12 @@
1
1
  <%- if bundler? -%>
2
- require 'ore/specification'
3
2
  require 'jeweler'
4
- Jeweler::Tasks.new(Ore::Specification.new)
3
+ Jeweler::Tasks.new(Gem::Specification.load('<%= @name %>.gemspec'))
5
4
  <%- else -%>
6
5
  begin
7
- gem 'ore', '<%= @ore_core_dependency %>'
8
- require 'ore/specification'
9
- rescue LoadError
10
- warn e.message
11
- warn "Run `gem install ore` to install Ore."
12
- end
13
-
14
- begin
15
- gem 'jeweler', '<%= @jeweler_dependency %>'
6
+ gem 'jeweler', '<%= @development_dependencies['jeweler'] %>'
16
7
  require 'jeweler'
17
8
 
18
- Jeweler::Tasks.new(Ore::Specification.new)
9
+ Jeweler::Tasks.new(Gem::Specification.load('<%= @name %>.gemspec'))
19
10
  rescue LoadError
20
11
  warn 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
21
12
  end
@@ -1,5 +1,6 @@
1
1
  disable:
2
- - ore_tasks
2
+ - rubygems_tasks
3
+ - bundler_tasks
3
4
 
4
- variables:
5
- jeweler_dependency: ~> 1.5.0
5
+ development_dependencies:
6
+ jeweler: ~> 1.5.0
@@ -1,4 +1,4 @@
1
- require 'rake/rdoctask'
1
+ require 'rdoc/task'
2
2
  Rake::RDocTask.new do |rdoc|
3
3
  rdoc.title = <%= @name.dump %>
4
4
  end
@@ -1,5 +1,8 @@
1
1
  disable:
2
2
  - yard
3
3
 
4
+ ignore:
5
+ - html/
6
+
4
7
  variables:
5
8
  markup: :rdoc
@@ -3,7 +3,7 @@ require 'rspec/core/rake_task'
3
3
  RSpec::Core::RakeTask.new
4
4
  <%- else -%>
5
5
  begin
6
- gem 'rspec', '<%= @rspec_dependency %>'
6
+ gem 'rspec', '<%= @development_dependencies['rspec'] %>'
7
7
  require 'rspec/core/rake_task'
8
8
 
9
9
  RSpec::Core::RakeTask.new
@@ -1,5 +1,5 @@
1
1
  <%- unless bundler? -%>
2
- gem 'rspec', '<%= @rspec_dependency %>'
2
+ gem 'rspec', '<%= @development_dependencies['rspec'] %>'
3
3
  <%- end -%>
4
4
  require 'rspec'
5
5
  require '<%= @namespace_path %>/version'
@@ -1,5 +1,5 @@
1
1
  disable:
2
2
  - test_unit
3
3
 
4
- variables:
5
- rspec_dependency: ~> 2.4
4
+ development_dependencies:
5
+ rspec: ~> 2.4
@@ -0,0 +1,14 @@
1
+ <%- if bundler? -%>
2
+ require 'rubygems/tasks'
3
+ Gem::Tasks.new
4
+ <%- else -%>
5
+ begin
6
+ gem 'rubygems-tasks', '<%= @development_dependencies['rubygems-tasks'] %>'
7
+ require 'rubygems/tasks'
8
+
9
+ Gem::Tasks.new
10
+ rescue LoadError => e
11
+ warn e.message
12
+ warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
13
+ end
14
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ disable:
2
+ - gem_package_task
3
+ - jeweler_tasks
4
+ - bundler_tasks
5
+
6
+ development_dependencies:
7
+ rubygems-tasks: ~> 0.2
@@ -5,14 +5,14 @@
5
5
 
6
6
  # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
7
  environment_id="<%= if defined?(::RUBY_ENGINE)
8
- if RUBY_ENGINE == 'ruby'
9
- RUBY_VERSION
10
- else
11
- RUBY_ENGINE
12
- end
13
- else
14
- RUBY_VERSION
15
- end -%>@<%= @name -%>"
8
+ if RUBY_ENGINE == 'ruby'
9
+ RUBY_VERSION
10
+ else
11
+ RUBY_ENGINE
12
+ end
13
+ else
14
+ RUBY_VERSION
15
+ end -%>@<%= @name -%>"
16
16
 
17
17
  #
18
18
  # First we attempt to load the desired environment directly from the environment
@@ -34,16 +34,10 @@ fi
34
34
  # directory you can uncomment the following code.
35
35
  #
36
36
 
37
- # Ensure that ore-core is installed.
38
- if [[ `gem list -i ore-core` -ne "true" ]]; then
39
- printf "The rubygem 'ore-core' is not installed, installing it now.\n"
40
- gem install ore-core --version <%= @ore_core_dependency.dump %>
41
- fi
42
-
43
37
  # Ensure that Bundler is installed, install it if it is not.
44
38
  if ! command -v bundle ; then
45
39
  printf "The rubygem 'bundler' is not installed, installing it now.\n"
46
- gem install bundler --version <%= @bundler_dependency.dump %>
40
+ gem install bundler
47
41
  fi
48
42
 
49
43
  # Bundle while reducing excess noise.
@@ -4,4 +4,3 @@
4
4
  <%- when :textile -%>
5
5
  gem 'RedCloth'
6
6
  <%- end -%>
7
- gem 'yard', '<%= @yard_dependency %>'
@@ -3,7 +3,7 @@ require 'yard'
3
3
  YARD::Rake::YardocTask.new
4
4
  <%- else -%>
5
5
  begin
6
- gem 'yard', '<%= @yard_dependency %>'
6
+ gem 'yard', '<%= @development_dependencies['yard'] %>'
7
7
  require 'yard'
8
8
 
9
9
  YARD::Rake::YardocTask.new