ore 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,21 @@
1
+ ### 0.5.0 / 2011-01-19
2
+
3
+ * Require ore-core ~> 0.1.1.
4
+ * Require rspec ~> 2.4.0.
5
+ * Load default options from `~/.ore/options.yml`.
6
+ * Added the `gem_test` template and `--gem-test` to {Ore::Generator}.
7
+ This opts-in projects to be tested via the `gem test` command.
8
+ * Auto-define options in {Ore::Generator} for builtin templates.
9
+ * Added `lib/ore.rb`.
10
+ * Added {Ore::Config.enable!}.
11
+ * Added {Ore::Config.disable!}.
12
+ * Added {Ore::Config.default_options}.
13
+ * Added {Ore::Generator.defaults}.
14
+ * Added {Ore::Generator.generator_option}.
15
+ * Added `vendor/cache/*.gem` to `.gitignore` if `--bundler` is specified.
16
+ * Attempt to auto-load `ore/specification` in the generated `*.gemspec`
17
+ files.
18
+
1
19
  ### 0.4.1 / 2010-12-17
2
20
 
3
21
  * Added a post-install message.
data/README.md CHANGED
@@ -33,7 +33,7 @@ the developer to keep all of the project information in a single YAML file.
33
33
 
34
34
  ## Requirements
35
35
 
36
- * [ore-core](http://github.com/ruby-ore/ore-core) ~> 0.1.0
36
+ * [ore-core](http://github.com/ruby-ore/ore-core) ~> 0.1.1
37
37
  * [thor](http://github.com/wycats/thor) ~> 0.14.3
38
38
 
39
39
  ## Install
@@ -45,7 +45,7 @@ the developer to keep all of the project information in a single YAML file.
45
45
  The `gemspec.yml` file used to build Ore:
46
46
 
47
47
  name: ore
48
- version: 0.4.1
48
+ version: 0.5.0
49
49
  summary: Mine raw RubyGems from YAML.
50
50
  description:
51
51
  Ore is a simple RubyGem building solution. Ore handles the
@@ -75,12 +75,12 @@ The `gemspec.yml` file used to build Ore:
75
75
  **************************************************************************
76
76
 
77
77
  dependencies:
78
- ore-core: ~> 0.1.0
78
+ ore-core: ~> 0.1.1
79
79
  thor: ~> 0.14.3
80
80
 
81
81
  development_dependencies:
82
82
  ore-tasks: ~> 0.3.0
83
- rspec: ~> 2.3.0
83
+ rspec: ~> 2.4.0
84
84
  yard: ~> 0.6.1
85
85
 
86
86
  For a complete refrence to the `gemspec.yml` file, please see the
@@ -112,6 +112,16 @@ Generate a new project using previously installed templates:
112
112
 
113
113
  $ mine myproj --bundler --rspec --yard -T awesometest
114
114
 
115
+ Add default generator options to `~/.ore/options.yml`:
116
+
117
+ ore_tasks: true
118
+ rspec: true
119
+ yard: true
120
+ markdown: true
121
+ authors:
122
+ - Alice
123
+ email: alice@example.com
124
+
115
125
  Builds a `.gem` file in the `pkg/` directory of a project:
116
126
 
117
127
  $ ore
@@ -5,6 +5,11 @@ begin
5
5
  # custom logic here
6
6
  end
7
7
  rescue NameError
8
- STDERR.puts "The '<%= @name %>.gemspec' file requires Ore."
9
- STDERR.puts "Run `gem install ore-core` to install Ore."
8
+ begin
9
+ require 'ore/specification'
10
+ retry
11
+ rescue LoadError
12
+ STDERR.puts "The '<%= @name %>.gemspec' file requires Ore."
13
+ STDERR.puts "Run `gem install ore-core` to install Ore."
14
+ end
10
15
  end
@@ -1,3 +1,5 @@
1
+ require 'ore/specification'
2
+
1
3
  source :rubygems
2
4
 
3
5
  gemspec
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ vendor/cache/*.gem
File without changes
@@ -0,0 +1,3 @@
1
+ <%- if rspec? -%>
2
+ task :test => :spec
3
+ <%- end -%>
@@ -3,6 +3,6 @@ require '<%= @namespace_path %>'
3
3
 
4
4
  describe <%= @namespace %> do
5
5
  it "should have a VERSION constant" do
6
- <%= @namespace %>.const_get('VERSION').should_not be_empty
6
+ subject.const_get('VERSION').should_not be_empty
7
7
  end
8
8
  end
@@ -1,4 +1,4 @@
1
1
  disable:
2
2
  - test_unit
3
3
  variables:
4
- rspec_dependency: ~> 2.1.0
4
+ rspec_dependency: ~> 2.4.0
@@ -1,12 +1,6 @@
1
1
  <%- case @markup
2
2
  when :markdown -%>
3
- platforms :jruby do
4
- gem 'maruku'
5
- end
6
-
7
- platforms :ruby do
8
- gem 'bluecloth', '>= 2.0.0'
9
- end
3
+ gem 'kramdown'
10
4
  <%- when :textile -%>
11
5
  gem 'RedCloth'
12
6
  <%- end -%>
@@ -1,5 +1,5 @@
1
1
  name: ore
2
- version: 0.4.1
2
+ version: 0.5.0
3
3
  summary: Mine raw RubyGems from YAML
4
4
  description:
5
5
  Ore is a simple RubyGem building solution. Ore handles the
@@ -29,10 +29,10 @@ post_install_message: |
29
29
  **************************************************************************
30
30
 
31
31
  dependencies:
32
- ore-core: ~> 0.1.0
32
+ ore-core: ~> 0.1.1
33
33
  thor: ~> 0.14.3
34
34
 
35
35
  development_dependencies:
36
36
  ore-tasks: ~> 0.3.0
37
- rspec: ~> 2.3.0
37
+ rspec: ~> 2.4.0
38
38
  yard: ~> 0.6.1
@@ -0,0 +1,5 @@
1
+ require 'ore-core'
2
+
3
+ require 'ore/config'
4
+ require 'ore/generator'
5
+ require 'ore/cli'
@@ -2,14 +2,17 @@ require 'pathname'
2
2
 
3
3
  module Ore
4
4
  module Config
5
+ # Specifies whether user settings will be loaded
6
+ @@enabled = true
7
+
5
8
  # The users home directory
6
9
  @@home = File.expand_path(ENV['HOME'] || ENV['HOMEPATH'])
7
10
 
8
11
  # Ore config directory
9
12
  @@path = File.join(@@home,'.ore')
10
13
 
11
- # Default `ore` options file.
12
- @@options_file = File.join(@@path,'default.opts')
14
+ # Default options file.
15
+ @@options_file = File.join(@@path,'options.yml')
13
16
 
14
17
  # Custom Ore Templates directory
15
18
  @@templates_dir = File.join(@@path,'templates')
@@ -17,6 +20,54 @@ module Ore
17
20
  # The `data/` directory for Ore
18
21
  @@data_dir = File.expand_path(File.join('..','..','data'),File.dirname(__FILE__))
19
22
 
23
+ #
24
+ # Enables access to user settings.
25
+ #
26
+ # @since 0.5.0
27
+ #
28
+ def Config.enable!
29
+ @@enabled = true
30
+ end
31
+
32
+ #
33
+ # Disables access to user settings.
34
+ #
35
+ # @since 0.5.0
36
+ #
37
+ def Config.disable!
38
+ @@enabled = false
39
+ end
40
+
41
+ #
42
+ # Loads the default options from `~/.ore/options.yml`.
43
+ #
44
+ # @return [Hash]
45
+ # The loaded default options.
46
+ #
47
+ # @raise [RuntimeError]
48
+ # The `~/.ore/options.yml` did not contain a YAML encoded Hash.
49
+ #
50
+ # @since 0.5.0
51
+ #
52
+ def Config.default_options
53
+ options = {}
54
+
55
+ if (@@enabled && File.file?(@@options_file))
56
+ new_options = YAML.load_file(@@options_file)
57
+
58
+ # default options must be a Hash
59
+ unless new_options.kind_of?(Hash)
60
+ raise("#{@@options_file} must contain a YAML encoded Hash")
61
+ end
62
+
63
+ new_options.each do |name,value|
64
+ options[name.to_sym] = value
65
+ end
66
+ end
67
+
68
+ return options
69
+ end
70
+
20
71
  #
21
72
  # The builtin templates.
22
73
  #
@@ -46,6 +97,8 @@ module Ore
46
97
  # The path of a Ore template directory.
47
98
  #
48
99
  def Config.installed_templates
100
+ return unless @@enabled
101
+
49
102
  if File.directory?(@@templates_dir)
50
103
  Dir.glob("#{@@templates_dir}/*") do |template|
51
104
  yield template if File.directory?(template)
@@ -16,14 +16,11 @@ module Ore
16
16
  include Template::Interpolations
17
17
  include Template::Helpers
18
18
 
19
- # The base template for all RubyGems
20
- @@base_template = :base
21
-
22
19
  #
23
20
  # The templates registered with the generator.
24
21
  #
25
- def Generator.templates
26
- @templates ||= {}
22
+ def self.templates
23
+ @@templates ||= {}
27
24
  end
28
25
 
29
26
  #
@@ -32,51 +29,63 @@ module Ore
32
29
  # @param [String] path
33
30
  # The path to the template.
34
31
  #
32
+ # @return [Symbol]
33
+ # The name of the registered template.
34
+ #
35
35
  # @raise [StandardError]
36
36
  # The given path was not a directory.
37
37
  #
38
- def Generator.register_template(path)
38
+ def self.register_template(path)
39
39
  unless File.directory?(path)
40
40
  raise(StandardError,"#{path.dump} is must be a directory")
41
41
  end
42
42
 
43
43
  name = File.basename(path).to_sym
44
- Generator.templates[name] = path
45
- end
46
44
 
47
- Config.builtin_templates { |path| Generator.register_template(path) }
48
- Config.installed_templates { |path| Generator.register_template(path) }
45
+ self.templates[name] = path
46
+ return name
47
+ end
49
48
 
50
- namespace ''
49
+ #
50
+ # Default options for the generator.
51
+ #
52
+ # @return [Hash{Symbol => Object}]
53
+ # The option names and default values.
54
+ #
55
+ # @since 0.5.0
56
+ #
57
+ def self.defaults
58
+ @@defaults ||= {
59
+ :templates => [],
60
+ :version => '0.1.0',
61
+ :summary => 'TODO: Summary',
62
+ :description => 'TODO: Description',
63
+ :license => 'MIT',
64
+ :authors => [ENV['USER']],
65
+ :rdoc => true,
66
+ :rspec => true,
67
+ :git => true
68
+ }
69
+ end
51
70
 
52
- class_option :markdown, :type => :boolean, :default => false
53
- class_option :textile, :type => :boolean, :default => false
54
- class_option :templates, :type => :array,
55
- :default => [],
56
- :aliases => '-T'
57
- class_option :name, :type => :string, :aliases => '-n'
58
- class_option :version, :type => :string,
59
- :default => '0.1.0',
60
- :aliases => '-V'
61
- class_option :summary, :default => 'TODO: Summary',
62
- :aliases => '-s'
63
- class_option :description, :default => 'TODO: Description',
64
- :aliases => '-D'
65
- class_option :license, :default => 'MIT', :aliases => '-L'
66
- class_option :homepage, :type => :string, :aliases => '-U'
67
- class_option :email, :type => :string, :aliases => '-e'
68
- class_option :authors, :type => :array,
69
- :default => [ENV['USER']], :aliases => '-a'
70
- class_option :rdoc, :type => :boolean, :default => true
71
- class_option :yard, :type => :boolean, :default => false
72
- class_option :test_unit, :type => :boolean, :default => false
73
- class_option :rspec, :type => :boolean, :default => true
74
- class_option :bundler, :type => :boolean, :default => false
75
- class_option :jeweler_tasks, :type => :boolean, :default => false
76
- class_option :ore_tasks, :type => :boolean, :default => false
77
- class_option :git, :type => :boolean, :default => true
78
- argument :path, :required => true
71
+ #
72
+ # Defines a generator option.
73
+ #
74
+ # @param [Symbol] name
75
+ # The name of the option.
76
+ #
77
+ # @param [Hash{Symbol => Object}] options
78
+ # The Thor options of the option.
79
+ #
80
+ # @since 0.5.0
81
+ #
82
+ def self.generator_option(name,options={})
83
+ class_option(name,options.merge(:default => defaults[name]))
84
+ end
79
85
 
86
+ #
87
+ # Generates a new project.
88
+ #
80
89
  def generate
81
90
  self.destination_root = path
82
91
 
@@ -101,6 +110,48 @@ module Ore
101
110
 
102
111
  protected
103
112
 
113
+ # merge default options
114
+ defaults.merge!(Config.default_options)
115
+
116
+ # register builtin templates
117
+ Config.builtin_templates do |path|
118
+ name = register_template(path)
119
+
120
+ # skip the `base` template
121
+ next if name == :base
122
+
123
+ # define options for builtin templates
124
+ class_option name, :type => :boolean, :default => defaults[name]
125
+ end
126
+
127
+ # register installed templates
128
+ Config.installed_templates do |path|
129
+ register_template(path)
130
+ end
131
+
132
+ # disable the Thor namespace
133
+ namespace ''
134
+
135
+ # define the options
136
+ generator_option :markdown, :type => :boolean
137
+ generator_option :textile, :type => :boolean
138
+ generator_option :templates, :type => :array,
139
+ :aliases => '-T',
140
+ :banner => 'TEMPLATE [...]'
141
+ generator_option :name, :type => :string, :aliases => '-n'
142
+ generator_option :version, :type => :string, :aliases => '-V'
143
+ generator_option :summary, :aliases => '-s'
144
+ generator_option :description, :aliases => '-D'
145
+ generator_option :authors, :type => :array,
146
+ :aliases => '-a',
147
+ :banner => 'NAME [...]'
148
+ generator_option :email, :type => :string, :aliases => '-e'
149
+ generator_option :homepage, :type => :string, :aliases => '-U'
150
+ generator_option :license, :aliases => '-L'
151
+ generator_option :git, :type => :boolean
152
+
153
+ argument :path, :required => true
154
+
104
155
  #
105
156
  # Enables a template, adding it to the generator.
106
157
  #
@@ -154,7 +205,7 @@ module Ore
154
205
  exit -1
155
206
  end
156
207
 
157
- self.source_paths.delete(template_dir)
208
+ source_paths.delete(template_dir)
158
209
 
159
210
  @templates.delete_if { |template| template.path == template_dir }
160
211
  @enabled_templates.delete(name)
@@ -168,17 +219,12 @@ module Ore
168
219
  @templates = []
169
220
  @enabled_templates = []
170
221
 
171
- enable_template(@@base_template)
172
-
173
- enable_template(:bundler) if options.bundler?
174
- enable_template(:jeweler_tasks) if options.jeweler_tasks?
175
- enable_template(:ore_tasks) if options.ore_tasks?
176
-
177
- enable_template(:rspec) if options.rspec?
178
- enable_template(:test_unit) if options.test_unit?
222
+ enable_template :base
179
223
 
180
- enable_template(:yard) if options.yard?
181
- enable_template(:rdoc) if options.rdoc?
224
+ # enable templates specified by options
225
+ self.class.templates.each_key do |name|
226
+ enable_template(name) if options[name]
227
+ end
182
228
 
183
229
  # enable any additionally specified templates
184
230
  options.templates.each { |name| enable_template(name) }
@@ -5,6 +5,11 @@ begin
5
5
  # custom logic here
6
6
  end
7
7
  rescue NameError
8
- STDERR.puts "The 'ore.gemspec' file requires Ore."
9
- STDERR.puts "Run `gem install ore-core` to install Ore."
8
+ begin
9
+ require 'ore/specification'
10
+ retry
11
+ rescue LoadError
12
+ STDERR.puts "The 'ore.gemspec' file requires Ore."
13
+ STDERR.puts "Run `gem install ore-core` to install Ore."
14
+ end
10
15
  end
@@ -105,6 +105,18 @@ describe Generator do
105
105
  end
106
106
  end
107
107
 
108
+ context "gem test" do
109
+ let(:name) { 'gem_test_project' }
110
+
111
+ before(:all) do
112
+ generate!(name, :gem_test => true)
113
+ end
114
+
115
+ it "should add a .gemtest file" do
116
+ @path.join('.gemtest').should be_file
117
+ end
118
+ end
119
+
108
120
  context "bundler" do
109
121
  let(:name) { 'bundled_project' }
110
122
 
@@ -1,7 +1,8 @@
1
- gem 'rspec', '~> 2.3.0'
1
+ gem 'rspec', '~> 2.4.0'
2
2
  require 'rspec'
3
3
 
4
4
  gem 'ore-core', '~> 0.1.0'
5
5
  require 'ore/config'
6
+ Ore::Config.disable!
6
7
 
7
8
  include Ore
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 1
9
- version: 0.4.1
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Postmodern
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-17 00:00:00 -08:00
17
+ date: 2011-01-19 00:00:00 -08:00
18
18
  default_executable: ore
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -28,8 +28,8 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  - 1
31
- - 0
32
- version: 0.1.0
31
+ - 1
32
+ version: 0.1.1
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
@@ -72,9 +72,9 @@ dependencies:
72
72
  - !ruby/object:Gem::Version
73
73
  segments:
74
74
  - 2
75
- - 3
75
+ - 4
76
76
  - 0
77
- version: 2.3.0
77
+ version: 2.4.0
78
78
  type: :development
79
79
  version_requirements: *id004
80
80
  - !ruby/object:Gem::Dependency
@@ -133,6 +133,8 @@ files:
133
133
  - data/ore/templates/bundler/_development_dependencies.erb
134
134
  - data/ore/templates/bundler/_gitignore.erb
135
135
  - data/ore/templates/bundler/template.yml
136
+ - data/ore/templates/gem_test/.gemtest
137
+ - data/ore/templates/gem_test/_tasks.erb
136
138
  - data/ore/templates/jeweler_tasks/_development_dependencies.erb
137
139
  - data/ore/templates/jeweler_tasks/_gemfile.erb
138
140
  - data/ore/templates/jeweler_tasks/_tasks.erb
@@ -158,6 +160,7 @@ files:
158
160
  - data/ore/templates/yard/_tasks.erb
159
161
  - data/ore/templates/yard/template.yml
160
162
  - gemspec.yml
163
+ - lib/ore.rb
161
164
  - lib/ore/cli.rb
162
165
  - lib/ore/config.rb
163
166
  - lib/ore/generator.rb