ore 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/.document +0 -1
  2. data/ChangeLog.md +28 -18
  3. data/README.md +8 -6
  4. data/Rakefile +10 -0
  5. data/data/ore/templates/base/[name].gemspec.erb +1 -1
  6. data/data/ore/templates/base/_gemfile.erb +1 -1
  7. data/data/ore/templates/base/gemspec.yml.erb +2 -2
  8. data/data/ore/templates/base/template.yml +1 -1
  9. data/data/ore/templates/ore_tasks/template.yml +1 -1
  10. data/gemspec.yml +4 -2
  11. data/lib/ore/generator.rb +1 -1
  12. data/lib/ore/template/helpers.rb +24 -0
  13. data/ore.gemspec +9 -5
  14. data/spec/generator_spec.rb +9 -1
  15. data/spec/spec_helper.rb +2 -0
  16. metadata +43 -80
  17. data/GemspecYML.md +0 -272
  18. data/lib/ore.rb +0 -3
  19. data/lib/ore/checks.rb +0 -88
  20. data/lib/ore/defaults.rb +0 -141
  21. data/lib/ore/dependency.rb +0 -65
  22. data/lib/ore/document_file.rb +0 -118
  23. data/lib/ore/exceptions.rb +0 -3
  24. data/lib/ore/exceptions/exception.rb +0 -4
  25. data/lib/ore/exceptions/invalid_metadata.rb +0 -6
  26. data/lib/ore/exceptions/project_not_found.rb +0 -6
  27. data/lib/ore/naming.rb +0 -113
  28. data/lib/ore/paths.rb +0 -146
  29. data/lib/ore/project.rb +0 -591
  30. data/lib/ore/settings.rb +0 -262
  31. data/lib/ore/specification.rb +0 -29
  32. data/lib/ore/versions.rb +0 -3
  33. data/lib/ore/versions/exceptions.rb +0 -1
  34. data/lib/ore/versions/exceptions/invalid_version.rb +0 -8
  35. data/lib/ore/versions/version.rb +0 -75
  36. data/lib/ore/versions/version_constant.rb +0 -126
  37. data/lib/ore/versions/version_file.rb +0 -66
  38. data/lib/rubygems_plugin.rb +0 -40
  39. data/spec/dependency_spec.rb +0 -36
  40. data/spec/document_file_spec.rb +0 -29
  41. data/spec/helpers/files.rb +0 -7
  42. data/spec/helpers/files/.document +0 -5
  43. data/spec/helpers/files/VERSION +0 -1
  44. data/spec/helpers/files/VERSION.yml +0 -5
  45. data/spec/helpers/projects.rb +0 -13
  46. data/spec/helpers/projects/dm-is-plugin/Gemfile +0 -3
  47. data/spec/helpers/projects/dm-is-plugin/VERSION +0 -1
  48. data/spec/helpers/projects/dm-is-plugin/dm-is-plugin.gemspec +0 -10
  49. data/spec/helpers/projects/dm-is-plugin/gemspec.yml +0 -7
  50. data/spec/helpers/projects/dm-is-plugin/lib/dm-is-plugin.rb +0 -4
  51. data/spec/helpers/projects/dm-is-plugin/lib/dm-is-plugin/is/plugin.rb +0 -6
  52. data/spec/helpers/projects/explicit/gemspec.yml +0 -10
  53. data/spec/helpers/projects/explicit/lib/explicit/version.rb +0 -15
  54. data/spec/helpers/projects/ffi-binding/gemspec.yml +0 -9
  55. data/spec/helpers/projects/ffi-binding/lib/ffi/binding/version.rb +0 -5
  56. data/spec/helpers/projects/jewelery/VERSION +0 -1
  57. data/spec/helpers/projects/jewelery/bin/jewelery +0 -3
  58. data/spec/helpers/projects/jewelery/gemspec.yml +0 -4
  59. data/spec/helpers/projects/jewelery/jewelery.gemspec +0 -10
  60. data/spec/helpers/projects/jewelery/lib/jewelery.rb +0 -4
  61. data/spec/helpers/projects/jewelery/lib/jewelery/rubies.rb +0 -4
  62. data/spec/helpers/projects/minimal/gemspec.yml +0 -4
  63. data/spec/helpers/projects/minimal/lib/minimal.rb +0 -2
  64. data/spec/naming_spec.rb +0 -56
  65. data/spec/projects/dm_plugin_project_spec.rb +0 -29
  66. data/spec/projects/explicit_project_spec.rb +0 -33
  67. data/spec/projects/ffi_binding_project_spec.rb +0 -25
  68. data/spec/projects/jeweler_project_spec.rb +0 -17
  69. data/spec/projects/minimal_project_spec.rb +0 -17
  70. data/spec/projects/project_examples.rb +0 -34
  71. data/spec/versions/version_file_spec.rb +0 -28
  72. data/spec/versions/version_spec.rb +0 -53
data/lib/ore/settings.rb DELETED
@@ -1,262 +0,0 @@
1
- require 'ore/exceptions/invalid_metadata'
2
- require 'ore/versions/version'
3
- require 'ore/dependency'
4
-
5
- module Ore
6
- #
7
- # A mixin for {Project} which provides methods for normalizing and
8
- # setting project attributes.
9
- #
10
- module Settings
11
- protected
12
-
13
- #
14
- # Sets the version of the project.
15
- #
16
- # @param [Hash<Integer>, String] version
17
- # The version from the metadata file.
18
- #
19
- # @raise [InvalidVersion]
20
- # The version must either be a `String` or a `Hash`.
21
- #
22
- def set_version!(version)
23
- case version
24
- when Hash
25
- major = version['major']
26
- minor = version['minor']
27
- patch = version['patch']
28
- build = version['build']
29
-
30
- @version = Versions::Version.new(major,minor,patch,build)
31
- when String
32
- @version = Versions::Version.parse(version.to_s)
33
- else
34
- raise(InvalidMetadata,"version must be a Hash or a String")
35
- end
36
- end
37
-
38
- #
39
- # Sets the license(s) of the project.
40
- #
41
- # @param [Array, String] license
42
- # The license(s) of the project.
43
- #
44
- def set_license!(license)
45
- if license.kind_of?(Array)
46
- @licenses += license
47
- else
48
- @licenses << license
49
- end
50
- end
51
-
52
- #
53
- # Sets the authors of the project.
54
- #
55
- # @param [Array<String>, String] authors
56
- # The authors listed in the metadata file.
57
- #
58
- def set_authors!(authors)
59
- if authors.kind_of?(Array)
60
- @authors += authors
61
- else
62
- @authors << authors
63
- end
64
- end
65
-
66
- #
67
- # Sets the release date of the project.
68
- #
69
- # @param [String] date
70
- # The release date from the metadata file.
71
- #
72
- def set_date!(date)
73
- @date = Date.parse(date)
74
- end
75
-
76
- #
77
- # Sets the require-paths of the project.
78
- #
79
- # @param [Array<String>, String] paths
80
- # The require-paths or the glob-pattern listed in the metadata file.
81
- #
82
- def set_require_paths!(paths)
83
- if paths.kind_of?(Array)
84
- paths.each { |path| add_require_path(path) }
85
- else
86
- glob(paths) { |path| add_require_path(path) }
87
- end
88
- end
89
-
90
- #
91
- # Sets the executables of the project.
92
- #
93
- # @param [Array<String>, String]
94
- # The executable names or the glob-pattern listed in the metadata
95
- # file.
96
- #
97
- def set_executables!(paths)
98
- if paths.kind_of?(Array)
99
- paths.each { |path| add_executable(path) }
100
- else
101
- glob(paths) { |path| add_executable(path) }
102
- end
103
- end
104
-
105
- #
106
- # Sets the default executable of the project.
107
- #
108
- # @param [String] name
109
- # The default executable name listed in the metadata file.
110
- #
111
- def set_default_executable!(name)
112
- if @executables.include?(name)
113
- @default_executable = name
114
- else
115
- warn "#{name} is not in the executables list"
116
- end
117
- end
118
-
119
- #
120
- # Sets the extra documentation files of the project.
121
- #
122
- # @param [Array<String>, String] paths
123
- # The file paths or the glob-pattern listed in the metadata file.
124
- #
125
- def set_extra_doc_files!(paths)
126
- if paths.kind_of?(Array)
127
- paths.each { |path| add_extra_doc_file(path) }
128
- else
129
- glob(paths) { |path| add_extra_doc_file(path) }
130
- end
131
- end
132
-
133
- #
134
- # Sets the files of the project.
135
- #
136
- # @param [Array<String>, String] paths
137
- # The files or the glob-pattern listed in the metadata file.
138
- #
139
- def set_files!(paths)
140
- if paths.kind_of?(Array)
141
- paths.each { |path| add_file(path) }
142
- else
143
- glob(paths) { |path| add_file(path) }
144
- end
145
- end
146
-
147
- #
148
- # Sets the test-files of the project.
149
- #
150
- # @param [Array<String>, String] paths
151
- # The test-files of the glob-pattern listed in the metadata file.
152
- #
153
- def set_test_files!(paths)
154
- if paths.kind_of?(Array)
155
- paths.each { |path| add_test_file(path) }
156
- else
157
- glob(paths) { |path| add_test_file(path) }
158
- end
159
- end
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
-
177
- #
178
- # Sets the Ruby version required by the project.
179
- #
180
- # @param [String] version
181
- # The version requirement.
182
- #
183
- def set_required_ruby_version!(version)
184
- @required_ruby_version = version.to_s
185
- end
186
-
187
- #
188
- # Sets the RubyGems version required by the project.
189
- #
190
- # @param [String] version
191
- # The version requirement.
192
- #
193
- def set_required_rubygems_version!(version)
194
- @required_rubygems_version = version.to_s
195
- end
196
-
197
- #
198
- # Sets the dependencies of the project.
199
- #
200
- # @param [Hash{String => String}] dependencies
201
- # The dependencey names and versions listed in the metadata file.
202
- #
203
- # @raise [InvalidMetadata]
204
- # The dependencies must be a `Hash`.
205
- #
206
- def set_dependencies!(dependencies)
207
- unless dependencies.kind_of?(Hash)
208
- raise(InvalidMetadata,"dependencies must be a Hash")
209
- end
210
-
211
- dependencies.each do |name,versions|
212
- versions = versions.to_s
213
-
214
- @dependencies << Dependency.parse_versions(name,versions)
215
- end
216
- end
217
-
218
- #
219
- # Sets the runtime-dependencies of the project.
220
- #
221
- # @param [Hash{String => String}] dependencies
222
- # The runtime-dependencey names and versions listed in the metadata
223
- # file.
224
- #
225
- # @raise [InvalidMetadata]
226
- # The runtime-dependencies must be a `Hash`.
227
- #
228
- def set_runtime_dependencies!(dependencies)
229
- unless dependencies.kind_of?(Hash)
230
- raise(InvalidMetadata,"runtime_dependencies must be a Hash")
231
- end
232
-
233
- dependencies.each do |name,versions|
234
- versions = versions.to_s
235
-
236
- @runtime_dependencies << Dependency.parse_versions(name,versions)
237
- end
238
- end
239
-
240
- #
241
- # Sets the development-dependencies of the project.
242
- #
243
- # @param [Hash{String => String}] dependencies
244
- # The development-dependencey names and versions listed in the
245
- # metadata file.
246
- #
247
- # @raise [InvalidMetadata]
248
- # The development-dependencies must be a `Hash`.
249
- #
250
- def set_development_dependencies!(dependencies)
251
- unless dependencies.kind_of?(Hash)
252
- raise(InvalidMetadata,"development_dependencies must be a Hash")
253
- end
254
-
255
- dependencies.each do |name,versions|
256
- versions = versions.to_s
257
-
258
- @development_dependencies << Dependency.parse_versions(name,versions)
259
- end
260
- end
261
- end
262
- end
@@ -1,29 +0,0 @@
1
- require 'ore/project'
2
-
3
- module Ore
4
- #
5
- # Acts as a drop-in replacement for calling `Gem::Specification.new`
6
- # in a projects gemspec file.
7
- #
8
- module Specification
9
- #
10
- # Creates a new Gem Specification, and automatically populates it
11
- # using the metadata file.
12
- #
13
- # @yield [gemspec]
14
- # The given block will be passed the populated Gem Specification
15
- # object.
16
- #
17
- # @yieldparam [Gem::Specification] gemspec
18
- # The newly created Gem Specification.
19
- #
20
- # @return [Gem::Specification]
21
- # The Gem Specification.
22
- #
23
- # @see Project#to_gemspec
24
- #
25
- def Specification.new(&block)
26
- Project.find.to_gemspec(&block)
27
- end
28
- end
29
- end
data/lib/ore/versions.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'ore/versions/version'
2
- require 'ore/versions/version_file'
3
- require 'ore/versions/version_constant'
@@ -1 +0,0 @@
1
- require 'ore/versions/exceptions/invalid_version'
@@ -1,8 +0,0 @@
1
- require 'ore/exceptions/exception'
2
-
3
- module Ore
4
- module Versions
5
- class InvalidVersion < Exception
6
- end
7
- end
8
- end
@@ -1,75 +0,0 @@
1
- require 'ore/versions/exceptions/invalid_version'
2
-
3
- require 'rubygems/version'
4
-
5
- module Ore
6
- module Versions
7
- #
8
- # Represents a standard three-number version.
9
- #
10
- # @see http://semver.org/
11
- #
12
- class Version < Gem::Version
13
-
14
- # Major version number
15
- attr_reader :major
16
-
17
- # Minor version number
18
- attr_reader :minor
19
-
20
- # Patch version number
21
- attr_reader :patch
22
-
23
- # The build string
24
- attr_reader :build
25
-
26
- #
27
- # Creates a new version.
28
- #
29
- # @param [Integer, nil] major
30
- # The major version number.
31
- #
32
- # @param [Integer, nil] minor
33
- # The minor version number.
34
- #
35
- # @param [Integer, nil] patch
36
- # The patch version number.
37
- #
38
- # @param [Integer, nil] build (nil)
39
- # The build version number.
40
- #
41
- def initialize(major,minor,patch,build=nil)
42
- @major = (major || 0)
43
- @minor = (minor || 0)
44
- @patch = (patch || 0)
45
- @build = build
46
-
47
- numbers = [@major,@minor,@patch]
48
- numbers << @build if @build
49
-
50
- super(numbers.join('.'))
51
- end
52
-
53
- #
54
- # Parses a version string.
55
- #
56
- # @param [String] string
57
- # The version string.
58
- #
59
- # @return [Version]
60
- # The parsed version.
61
- #
62
- def self.parse(string)
63
- major, minor, patch, build = string.split('.',4)
64
-
65
- return self.new(
66
- (major || 0).to_i,
67
- (minor || 0).to_i,
68
- (patch || 0).to_i,
69
- build
70
- )
71
- end
72
-
73
- end
74
- end
75
- end
@@ -1,126 +0,0 @@
1
- require 'ore/versions/version'
2
- require 'ore/naming'
3
-
4
- module Ore
5
- module Versions
6
- #
7
- # Represents a version loaded from a Ruby `VERSION` constant or
8
- # `Version` module.
9
- #
10
- class VersionConstant < Version
11
-
12
- include Naming
13
-
14
- # Common file-name that the `VERSION` constant or `Version` module
15
- # is defined within.
16
- @@file_name = 'version.rb'
17
-
18
- #
19
- # Finds the `version.rb` file.
20
- #
21
- # @param [Project] project
22
- # The project.
23
- #
24
- # @return [VersionConstant, nil]
25
- # The loaded version constant.
26
- #
27
- def self.find(project)
28
- if project.namespace_dir
29
- path = File.join(project.namespace_dir,@@file_name)
30
-
31
- self.load(project.lib_path(path)) if project.lib_file?(path)
32
- end
33
- end
34
-
35
- #
36
- # Extracts the `VERSION` constant or the major / minor / patch / build
37
- # version numbers from the `Version` module.
38
- #
39
- # @param [String] path
40
- # The path to the `version.rb` file.
41
- #
42
- # @return [VersionConstant, nil]
43
- # The loaded version constant.
44
- #
45
- def self.load(path)
46
- major = nil
47
- minor = nil
48
- patch = nil
49
- build = nil
50
-
51
- File.open(path) do |file|
52
- file.each_line do |line|
53
- unless line =~ /^\s*#/ # skip commented lines
54
- if line =~ /(VERSION|Version)\s*=\s*/
55
- version = extract_version(line)
56
-
57
- return self.parse(version) if version
58
- elsif line =~ /(MAJOR|Major)\s*=\s*/
59
- major ||= extract_number(line)
60
- elsif line =~ /(MINOR|Minor)\s*=\s*/
61
- minor ||= extract_number(line)
62
- elsif line =~ /(PATCH|Patch)\s*=\s*/
63
- patch ||= extract_number(line)
64
- elsif line =~ /(BUILD|Build)\s*=\s*/
65
- build ||= extract_string(line)
66
- end
67
-
68
- break if (major && minor && patch && build)
69
- end
70
- end
71
- end
72
-
73
- return self.new(major,minor,patch,build)
74
- end
75
-
76
- protected
77
-
78
- #
79
- # Extracts the version string from a `VERSION` constant declaration.
80
- #
81
- # @param [String] line
82
- # The line of Ruby code where the `VERSION` constant was defined.
83
- #
84
- # @return [String, nil]
85
- # The extracted version string.
86
- #
87
- def self.extract_version(line)
88
- if (match = line.match(/=\s*['"](\d+\.\d+\.\d+(\.\w+)?)['"]/))
89
- match[1]
90
- end
91
- end
92
-
93
- #
94
- # Extracts a number from a `BUILD` constant declaration.
95
- #
96
- # @param [String] line
97
- # The line of Ruby code where the constant was defined.
98
- #
99
- # @return [String, nil]
100
- # The extracted string.
101
- #
102
- def self.extract_string(line)
103
- if (match = line.match(/=\s*['"]?(\w+)['"]?/))
104
- match[1]
105
- end
106
- end
107
-
108
- #
109
- # Extracts a version number from a `MAJOR`, `MINOR`, `PATCH` or
110
- # `BUILD` constant declaration.
111
- #
112
- # @param [String] line
113
- # The line of Ruby code where the constant was defined.
114
- #
115
- # @return [Integer, nil]
116
- # The extracted version number.
117
- #
118
- def self.extract_number(line)
119
- if (match = line.match(/=\s*['"]?(\d+)['"]?/))
120
- match[1].to_i
121
- end
122
- end
123
-
124
- end
125
- end
126
- end