ore 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/ChangeLog.md +17 -0
  2. data/GemspecYML.md +12 -0
  3. data/README.md +3 -2
  4. data/Rakefile +20 -4
  5. data/data/ore/templates/base/Rakefile.erb +1 -1
  6. data/data/ore/templates/base/_gemfile.erb +1 -0
  7. data/data/ore/templates/base/gemspec.yml.erb +4 -2
  8. data/data/ore/templates/base/template.yml +2 -0
  9. data/data/ore/templates/bundler/Gemfile.erb +1 -13
  10. data/data/ore/templates/bundler/_dependencies.erb +1 -1
  11. data/data/ore/templates/bundler/template.yml +2 -0
  12. data/data/ore/templates/jeweler_tasks/_dependencies.erb +1 -1
  13. data/data/ore/templates/jeweler_tasks/_gemfile.erb +1 -0
  14. data/data/ore/templates/jeweler_tasks/_tasks.erb +8 -3
  15. data/data/ore/templates/jeweler_tasks/template.yml +2 -0
  16. data/data/ore/templates/ore_tasks/_dependencies.erb +1 -1
  17. data/data/ore/templates/ore_tasks/_gemfile.erb +1 -0
  18. data/data/ore/templates/ore_tasks/_tasks.erb +2 -0
  19. data/data/ore/templates/ore_tasks/template.yml +2 -0
  20. data/data/ore/templates/rspec/_dependencies.erb +1 -1
  21. data/data/ore/templates/rspec/_gemfile.erb +1 -0
  22. data/data/ore/templates/rspec/_tasks.erb +2 -0
  23. data/data/ore/templates/rspec/spec/spec_helper.rb.erb +1 -1
  24. data/data/ore/templates/rspec/template.yml +2 -0
  25. data/data/ore/templates/yard/_dependencies.erb +1 -1
  26. data/data/ore/templates/yard/_gemfile.erb +12 -0
  27. data/data/ore/templates/yard/{_gem.erb → _gemspec.erb} +0 -0
  28. data/data/ore/templates/yard/_tasks.erb +2 -0
  29. data/data/ore/templates/yard/template.yml +2 -0
  30. data/gemspec.yml +2 -2
  31. data/lib/ore/generator.rb +7 -3
  32. data/lib/ore/project.rb +16 -0
  33. data/lib/ore/settings.rb +16 -0
  34. data/lib/ore/template/directory.rb +46 -1
  35. data/lib/ore/template/exceptions.rb +1 -0
  36. data/lib/ore/template/exceptions/invalid_template.rb +9 -0
  37. data/spec/helpers/projects/ffi-binding/gemspec.yml +2 -0
  38. data/spec/projects/ffi_binding_project_spec.rb +4 -0
  39. metadata +20 -7
@@ -1,3 +1,20 @@
1
+ ### 0.2.0 / 2010-10-27
2
+
3
+ * Added {Ore::Project#requirements}.
4
+ * Added {Ore::Settings#set_requirements!}.
5
+ * Added {Ore::Template::InvalidTemplate}.
6
+ * Added {Ore::Template::Directory#load!}.
7
+ * Suppress `no rubyforge_project specified` warnings by setting the
8
+ `rubyforge_project` to the project name in {Ore::Project#to_gemspec}.
9
+ * Do not add extra dependencies to the `gemspec.yml` file when generating
10
+ a Bundler enabled project. Extra dependencies will be added to the
11
+ `Gemfile` and controlled by Bundler.
12
+ * Allow Ore template directories to contain `template.yml` which may list
13
+ template variables:
14
+
15
+ data:
16
+ variable: Value
17
+
1
18
  ### 0.1.4 / 2010-10-26
2
19
 
3
20
  * Increased documentation coverage.
@@ -200,6 +200,18 @@ More than one test-file pattern can be supplied:
200
200
  If `test_files` is not listed, Ore will default `files` to
201
201
  `test/{**/}test_*.rb` and `spec/{**/}*_spec.rb`.
202
202
 
203
+ ## requirements
204
+
205
+ The external requirements of the project can be listed like so:
206
+
207
+ requirements: libcairo >= 1.8
208
+
209
+ Multiple external requirements can also be listed:
210
+
211
+ requirements:
212
+ - libcairo >= 1.8.0
213
+ - libclutter >= 1.2.0
214
+
203
215
  ## required_ruby_version
204
216
 
205
217
  The version of Ruby required by the project can be listed like so:
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  * [Source](http://github.com/ruby-ore/ore)
4
4
  * [Issues](http://github.com/ruby-ore/ore/issues)
5
+ * [Documentation](http://rubydoc.info/gems/ore/file/README.md)
5
6
  * IRC: irc.freenode.net #ruby-ore
6
7
  * Postmodern (postmodern.mod3 at gmail.com)
7
8
 
@@ -44,8 +45,8 @@ the developer to keep all of the project information in a single YAML file.
44
45
  The `gemspec.yml` file used to build Ore:
45
46
 
46
47
  name: ore
47
- version: 0.1.2
48
- summary: Cut raw RubyGems from YAML.
48
+ version: 0.2.0
49
+ summary: Mine raw RubyGems from YAML.
49
50
  description:
50
51
  Ore is a simple RubyGem building solution. Ore handles the
51
52
  creation of Gem::Specification objects as well as building '.gem'
data/Rakefile CHANGED
@@ -1,9 +1,25 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new
4
+ begin
5
+ gem 'rspec', '~> 2.0.0'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RSpec::Core::RakeTask.new
9
+ rescue LoadError
10
+ task :spec do
11
+ abort "Please run `gem install rspec` to install RSpec."
12
+ end
13
+ end
6
14
  task :default => :spec
7
15
 
8
- require 'yard'
9
- YARD::Rake::YardocTask.new
16
+ begin
17
+ gem 'yard', '~> 0.6.0'
18
+ require 'yard'
19
+
20
+ YARD::Rake::YardocTask.new
21
+ rescue LoadError
22
+ task :yard do
23
+ abort "Please run `gem install yard` to install YARD."
24
+ end
25
+ end
@@ -10,7 +10,7 @@ rescue LoadError => e
10
10
  end
11
11
 
12
12
  begin
13
- Bundler.setup(:development, :doc)
13
+ Bundler.setup(:development)
14
14
  rescue Bundler::BundlerError => e
15
15
  STDERR.puts e.message
16
16
  STDERR.puts "Run `bundle install` to install missing gems."
@@ -0,0 +1 @@
1
+ gem 'ore', '<%= @ore_dependency %>'
@@ -16,8 +16,10 @@ authors: <%= @authors.first %>
16
16
  email: <%= @email %>
17
17
  <%- end -%>
18
18
  homepage: <%= @homepage %>
19
- <%= includes :gem, '' -%>
19
+ <%= includes :gemspec, '' -%>
20
20
 
21
21
  development_dependencies:
22
- ore: ~> <%= @ore_version %>
22
+ <%- unless bundler? -%>
23
+ ore: <%= @ore_dependency %>
24
+ <%- end -%>
23
25
  <%= includes :dependencies, '' -%>
@@ -0,0 +1,2 @@
1
+ data:
2
+ ore_dependency: ~> 0.2.0
@@ -4,17 +4,5 @@ gemspec
4
4
 
5
5
  group :development do
6
6
  gem 'rake', '~> 0.8.7'
7
- <%- if yard?
8
- case @markup
9
- when :markdown -%>
10
- case RUBY_PLATFORM
11
- when 'java'
12
- gem 'maruku'
13
- else
14
- gem 'bluecloth', '>= 2.0.0'
15
- end
16
- <%- when :textile -%>
17
- gem 'RedCloth'
18
- <%- end
19
- end -%>
7
+ <%= includes :gemfile, '' -%>
20
8
  end
@@ -1 +1 @@
1
- bundler: ~> 1.0.0
1
+ bundler: <%= @bundler_dependency %>
@@ -0,0 +1,2 @@
1
+ data:
2
+ bundler_dependency: ~> 1.0.0
@@ -1,3 +1,3 @@
1
1
  <%- unless bundler? -%>
2
- jeweler: ~> 1.4
2
+ jeweler: <%= @jeweler_dependency %>
3
3
  <%- end -%>
@@ -0,0 +1 @@
1
+ gem 'jeweler', '<%= @jeweler_dependency %>'
@@ -4,10 +4,15 @@ require 'jeweler'
4
4
  Jeweler::Tasks.new(Ore::Specification.new)
5
5
  <%- else -%>
6
6
  begin
7
- gem 'ore', '~> <%= @ore_version %>'
8
- gem 'jeweler', '~> 1.4'
9
-
7
+ gem 'ore', '<%= @ore_dependency %>'
10
8
  require 'ore/specification'
9
+ rescue LoadError
10
+ STDERR.puts e.message
11
+ STDERR.puts "Run `gem install ore` to install Ore."
12
+ end
13
+
14
+ begin
15
+ gem 'jeweler', '<%= @jeweler_dependency %>'
11
16
  require 'jeweler'
12
17
 
13
18
  Jeweler::Tasks.new(Ore::Specification.new)
@@ -0,0 +1,2 @@
1
+ data:
2
+ jeweler_dependency: ~> 1.4
@@ -1 +1 @@
1
- ore-tasks: ~> 0.1.0
1
+ ore-tasks: <%= @ore_tasks_dependency %>
@@ -0,0 +1 @@
1
+ gem 'ore-tasks', '<%= @ore_tasks_dependency %>'
@@ -3,7 +3,9 @@ require 'ore/tasks'
3
3
  Ore::Tasks.new
4
4
  <%- else -%>
5
5
  begin
6
+ gem 'ore-tasks', '<%= @ore_tasks_dependency %>'
6
7
  require 'ore/tasks'
8
+
7
9
  Ore::Tasks.new
8
10
  rescue LoadError => e
9
11
  STDERR.puts e.message
@@ -0,0 +1,2 @@
1
+ data:
2
+ ore_tasks_dependency: ~> 0.1.0
@@ -1,3 +1,3 @@
1
1
  <%- unless bundler? -%>
2
- rspec: ~> 2.0.0
2
+ rspec: <%= @rspec_dependency %>
3
3
  <%- end -%>
@@ -0,0 +1 @@
1
+ gem 'rspec', '<%= @rspec_dependency %>'
@@ -3,7 +3,9 @@ require 'rspec/core/rake_task'
3
3
  RSpec::Core::RakeTask.new
4
4
  <%- else -%>
5
5
  begin
6
+ gem 'rspec', '<%= @rspec_dependency %>'
6
7
  require 'rspec/core/rake_task'
8
+
7
9
  RSpec::Core::RakeTask.new
8
10
  rescue LoadError => e
9
11
  task :spec do
@@ -1,5 +1,5 @@
1
1
  <%- unless bundler? -%>
2
- gem 'rspec', '~> 2.0.0'
2
+ gem 'rspec', '<%= @rspec_dependency %>'
3
3
  <%- end -%>
4
4
  require 'rspec'
5
5
  require '<%= @namespace_dir %>/version'
@@ -0,0 +1,2 @@
1
+ data:
2
+ rspec_dependency: ~> 2.0.0
@@ -1 +1 @@
1
- yard: ~> 0.6.0
1
+ yard: <%= @yard_dependency %>
@@ -0,0 +1,12 @@
1
+ <%- case @markup
2
+ when :markdown -%>
3
+ case RUBY_PLATFORM
4
+ when 'java'
5
+ gem 'maruku'
6
+ else
7
+ gem 'bluecloth', '>= 2.0.0'
8
+ end
9
+ <%- when :textile -%>
10
+ gem 'RedCloth'
11
+ <%- end -%>
12
+ gem 'yard', '<%= @yard_dependency %>'
@@ -3,7 +3,9 @@ require 'yard'
3
3
  YARD::Rake::YardocTask.new
4
4
  <%- else -%>
5
5
  begin
6
+ gem 'yard', '<%= @yard_dependency %>'
6
7
  require 'yard'
8
+
7
9
  YARD::Rake::YardocTask.new
8
10
  rescue LoadError => e
9
11
  task :yard do
@@ -0,0 +1,2 @@
1
+ data:
2
+ yard_dependency: ~> 0.6.0
@@ -1,6 +1,6 @@
1
1
  name: ore
2
- version: 0.1.4
3
- summary: Cut raw RubyGems from YAML
2
+ version: 0.2.0
3
+ summary: Mine raw RubyGems from YAML
4
4
  description:
5
5
  Ore is a simple RubyGem building solution. Ore handles the
6
6
  creation of Gem::Specification objects as well as building '.gem'
@@ -145,8 +145,8 @@ module Ore
145
145
  exit -1
146
146
  end
147
147
 
148
- self.source_paths << template_dir
149
148
  @templates << Template::Directory.new(template_dir)
149
+ self.source_paths << template_dir
150
150
  end
151
151
  end
152
152
 
@@ -154,8 +154,6 @@ module Ore
154
154
  # Initializes variables for the templates.
155
155
  #
156
156
  def initialize_variables!
157
- @ore_version = '0.1.0'
158
-
159
157
  @project_dir = File.basename(destination_root)
160
158
  @name = (options.name || @project_dir)
161
159
 
@@ -193,6 +191,12 @@ module Ore
193
191
  @year = @date.year
194
192
  @month = @date.month
195
193
  @day = @date.day
194
+
195
+ @templates.each do |template|
196
+ template.data.each do |name,value|
197
+ instance_variable_set("@#{name}",value)
198
+ end
199
+ end
196
200
  end
197
201
 
198
202
  #
@@ -94,6 +94,9 @@ module Ore
94
94
  # The test files for the project
95
95
  attr_reader :test_files
96
96
 
97
+ # Any external requirements needed by the project
98
+ attr_reader :requirements
99
+
97
100
  # The version of Ruby required by the project
98
101
  attr_reader :required_ruby_version
99
102
 
@@ -236,6 +239,12 @@ module Ore
236
239
  default_test_files!
237
240
  end
238
241
 
242
+ @requirements = []
243
+
244
+ if metadata['requirements']
245
+ set_requirements! metadata['requirements']
246
+ end
247
+
239
248
  if metadata['required_ruby_version']
240
249
  set_required_ruby_version! metadata['required_ruby_version']
241
250
  end
@@ -404,6 +413,8 @@ module Ore
404
413
  gemspec.files = @files
405
414
  gemspec.test_files = @test_files
406
415
 
416
+ gemspec.requirements = @requirements
417
+
407
418
  if gemspec.respond_to?(:required_ruby_version=)
408
419
  gemspec.required_ruby_version = @required_ruby_version
409
420
  end
@@ -436,6 +447,11 @@ module Ore
436
447
  end
437
448
  end
438
449
 
450
+ # legacy information
451
+ if gemspec.respond_to?(:rubyforge_project=)
452
+ gemspec.rubyforge_project = gemspec.name
453
+ end
454
+
439
455
  yield gemspec if block_given?
440
456
  end
441
457
  end
@@ -158,6 +158,22 @@ module Ore
158
158
  end
159
159
  end
160
160
 
161
+ #
162
+ # Sets the external requirements of the project.
163
+ #
164
+ # @param [Array, String] requirements
165
+ # The external requirements.
166
+ #
167
+ # @since 0.2.0
168
+ #
169
+ def set_requirements!(requirements)
170
+ if requirements.kind_of?(Array)
171
+ @requirements += requirements
172
+ else
173
+ @requirements << requirements
174
+ end
175
+ end
176
+
161
177
  #
162
178
  # Sets the Ruby version required by the project.
163
179
  #
@@ -1,3 +1,6 @@
1
+ require 'ore/template/exceptions/invalid_template'
2
+
3
+ require 'yaml'
1
4
  require 'find'
2
5
 
3
6
  module Ore
@@ -8,8 +11,11 @@ module Ore
8
11
  #
9
12
  class Directory
10
13
 
14
+ # The template configuration file
15
+ @@config_file = 'template.yml'
16
+
11
17
  # Files or directory names to ignore
12
- @@ignore = %w[.git]
18
+ @@ignore = ['.git', @@config_file]
13
19
 
14
20
  # The known markup languages and file extensions
15
21
  @@markups = {
@@ -33,6 +39,9 @@ module Ore
33
39
  # The include templates in the template directory
34
40
  attr_reader :includes
35
41
 
42
+ # The data to use when rendering the template files
43
+ attr_reader :data
44
+
36
45
  #
37
46
  # Initializes a new template directory.
38
47
  #
@@ -47,6 +56,9 @@ module Ore
47
56
  @templates = {}
48
57
  @includes = Hash.new { |hash,key| hash[key] = {} }
49
58
 
59
+ @data = {}
60
+
61
+ load!
50
62
  scan!
51
63
  end
52
64
 
@@ -105,6 +117,39 @@ module Ore
105
117
 
106
118
  protected
107
119
 
120
+ #
121
+ # Loads template configuration information from `template.yml`.
122
+ #
123
+ # @raise [InvalidTemplate]
124
+ # The `template.yml` file did not contain a YAML Hash.
125
+ #
126
+ # @since 0.2.0
127
+ #
128
+ def load!
129
+ config_path = File.join(@path,@@config_file)
130
+ return false unless File.file?(config_path)
131
+
132
+ config = YAML.load_file(config_path)
133
+
134
+ unless config.kind_of?(Hash)
135
+ raise(InvalidTemplate,"invalid configuration in #{config_path.dump}")
136
+ end
137
+
138
+ if (data = config['data'])
139
+ # data must be a Hash
140
+ unless data.kind_of?(Hash)
141
+ raise(InvalidTemplate,"data must be a Hash: #{config_path.dump}")
142
+ end
143
+
144
+ # load the template data
145
+ data.each do |name,value|
146
+ @data[name.to_sym] = value
147
+ end
148
+ end
149
+
150
+ return true
151
+ end
152
+
108
153
  #
109
154
  # Scans the template directory recursively recording the directories,
110
155
  # files and partial templates.
@@ -0,0 +1 @@
1
+ require 'ore/template/exceptions/invalid_template'
@@ -0,0 +1,9 @@
1
+ module Ore
2
+ module Template
3
+ #
4
+ # @since 0.2.0
5
+ #
6
+ class InvalidTemplate < RuntimeError
7
+ end
8
+ end
9
+ end
@@ -3,5 +3,7 @@ summary: FFI Binding
3
3
  description: FFI Binding for some C library
4
4
  authors: Wayne Meissner
5
5
 
6
+ requirements: libstuff >= 1.0
7
+
6
8
  dependencies:
7
9
  ffi: ~> 0.6.0
@@ -18,4 +18,8 @@ describe "FFI Bindings project" do
18
18
  it "should have a namespace directory" do
19
19
  @project.namespace_dir.should == 'ffi/binding'
20
20
  end
21
+
22
+ it "should have external requirements" do
23
+ @project.requirements.should == ['libstuff >= 1.0']
24
+ end
21
25
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
7
+ - 2
8
+ - 0
9
+ version: 0.2.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-10-26 00:00:00 -07:00
17
+ date: 2010-10-27 00:00:00 -07:00
18
18
  default_executable: ore
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -96,27 +96,38 @@ files:
96
96
  - data/ore/templates/base/README.rdoc.erb
97
97
  - data/ore/templates/base/README.tt.erb
98
98
  - data/ore/templates/base/Rakefile.erb
99
+ - data/ore/templates/base/_gemfile.erb
99
100
  - data/ore/templates/base/gemspec.yml.erb
100
101
  - data/ore/templates/base/lib/:namespace_dir:.rb.erb
101
102
  - data/ore/templates/base/lib/:namespace_dir:/version.rb.erb
103
+ - data/ore/templates/base/template.yml
102
104
  - data/ore/templates/bundler/Gemfile.erb
103
105
  - data/ore/templates/bundler/_dependencies.erb
106
+ - data/ore/templates/bundler/template.yml
104
107
  - data/ore/templates/jeweler_tasks/_dependencies.erb
108
+ - data/ore/templates/jeweler_tasks/_gemfile.erb
105
109
  - data/ore/templates/jeweler_tasks/_tasks.erb
110
+ - data/ore/templates/jeweler_tasks/template.yml
106
111
  - data/ore/templates/ore_tasks/_dependencies.erb
112
+ - data/ore/templates/ore_tasks/_gemfile.erb
107
113
  - data/ore/templates/ore_tasks/_tasks.erb
114
+ - data/ore/templates/ore_tasks/template.yml
108
115
  - data/ore/templates/rdoc/_tasks.erb
109
116
  - data/ore/templates/rspec/.rspec
110
117
  - data/ore/templates/rspec/_dependencies.erb
118
+ - data/ore/templates/rspec/_gemfile.erb
111
119
  - data/ore/templates/rspec/_tasks.erb
112
120
  - data/ore/templates/rspec/spec/:namespace_dir:_spec.rb.erb
113
121
  - data/ore/templates/rspec/spec/spec_helper.rb.erb
122
+ - data/ore/templates/rspec/template.yml
114
123
  - data/ore/templates/test_unit/test/helper.rb.erb
115
124
  - data/ore/templates/test_unit/test/test_:name:.rb.erb
116
125
  - data/ore/templates/yard/.yardopts.erb
117
126
  - data/ore/templates/yard/_dependencies.erb
118
- - data/ore/templates/yard/_gem.erb
127
+ - data/ore/templates/yard/_gemfile.erb
128
+ - data/ore/templates/yard/_gemspec.erb
119
129
  - data/ore/templates/yard/_tasks.erb
130
+ - data/ore/templates/yard/template.yml
120
131
  - gemspec.yml
121
132
  - lib/ore.rb
122
133
  - lib/ore/checks.rb
@@ -137,6 +148,8 @@ files:
137
148
  - lib/ore/specification.rb
138
149
  - lib/ore/template.rb
139
150
  - lib/ore/template/directory.rb
151
+ - lib/ore/template/exceptions.rb
152
+ - lib/ore/template/exceptions/invalid_template.rb
140
153
  - lib/ore/template/helpers.rb
141
154
  - lib/ore/template/interpolations.rb
142
155
  - lib/ore/versions.rb
@@ -208,11 +221,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
221
  version: "0"
209
222
  requirements: []
210
223
 
211
- rubyforge_project:
224
+ rubyforge_project: ore
212
225
  rubygems_version: 1.3.7
213
226
  signing_key:
214
227
  specification_version: 3
215
- summary: Cut raw RubyGems from YAML
228
+ summary: Mine raw RubyGems from YAML
216
229
  test_files:
217
230
  - spec/dependency_spec.rb
218
231
  - spec/naming_spec.rb