ore 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +31 -0
- data/GemspecYML.md +252 -0
- data/LICENSE.txt +21 -0
- data/README.md +104 -0
- data/Rakefile +9 -0
- data/bin/mine +12 -0
- data/bin/ore +12 -0
- data/data/ore/templates/base/.document +3 -0
- data/data/ore/templates/base/.gitignore.erb +3 -0
- data/data/ore/templates/base/:name:.gemspec.erb +10 -0
- data/data/ore/templates/base/ChangeLog.md.erb +4 -0
- data/data/ore/templates/base/ChangeLog.rdoc.erb +4 -0
- data/data/ore/templates/base/ChangeLog.tt.erb +4 -0
- data/data/ore/templates/base/LICENSE.txt.erb +20 -0
- data/data/ore/templates/base/README.md.erb +42 -0
- data/data/ore/templates/base/README.rdoc.erb +38 -0
- data/data/ore/templates/base/README.tt.erb +44 -0
- data/data/ore/templates/base/Rakefile.erb +23 -0
- data/data/ore/templates/base/gemspec.yml.erb +23 -0
- data/data/ore/templates/base/lib/:namespace_dir:.rb.erb +1 -0
- data/data/ore/templates/base/lib/:namespace_dir:/version.rb.erb +8 -0
- data/data/ore/templates/bundler/Gemfile.erb +20 -0
- data/data/ore/templates/bundler/_dependencies.erb +1 -0
- data/data/ore/templates/jeweler_tasks/_dependencies.erb +3 -0
- data/data/ore/templates/jeweler_tasks/_tasks.erb +17 -0
- data/data/ore/templates/ore_tasks/_dependencies.erb +1 -0
- data/data/ore/templates/ore_tasks/_tasks.erb +12 -0
- data/data/ore/templates/rdoc/_tasks.erb +6 -0
- data/data/ore/templates/rspec/.rspec +1 -0
- data/data/ore/templates/rspec/_dependencies.erb +3 -0
- data/data/ore/templates/rspec/_tasks.erb +14 -0
- data/data/ore/templates/rspec/spec/:namespace_dir:_spec.rb.erb +8 -0
- data/data/ore/templates/rspec/spec/spec_helper.rb.erb +7 -0
- data/data/ore/templates/test_unit/test/helper.rb.erb +24 -0
- data/data/ore/templates/test_unit/test/test_:name:.rb.erb +5 -0
- data/data/ore/templates/yard/.yardopts.erb +1 -0
- data/data/ore/templates/yard/_dependencies.erb +1 -0
- data/data/ore/templates/yard/_gem.erb +1 -0
- data/data/ore/templates/yard/_tasks.erb +13 -0
- data/gemspec.yml +21 -0
- data/lib/ore.rb +3 -0
- data/lib/ore/checks.rb +85 -0
- data/lib/ore/cli.rb +120 -0
- data/lib/ore/config.rb +52 -0
- data/lib/ore/defaults.rb +137 -0
- data/lib/ore/dependency.rb +62 -0
- data/lib/ore/document_file.rb +118 -0
- data/lib/ore/exceptions.rb +3 -0
- data/lib/ore/exceptions/exception.rb +4 -0
- data/lib/ore/exceptions/invalid_metadata.rb +6 -0
- data/lib/ore/exceptions/project_not_found.rb +6 -0
- data/lib/ore/generator.rb +247 -0
- data/lib/ore/naming.rb +95 -0
- data/lib/ore/paths.rb +143 -0
- data/lib/ore/project.rb +568 -0
- data/lib/ore/settings.rb +236 -0
- data/lib/ore/specification.rb +29 -0
- data/lib/ore/template.rb +3 -0
- data/lib/ore/template/directory.rb +179 -0
- data/lib/ore/template/helpers.rb +144 -0
- data/lib/ore/template/interpolations.rb +31 -0
- data/lib/ore/versions.rb +3 -0
- data/lib/ore/versions/exceptions.rb +1 -0
- data/lib/ore/versions/exceptions/invalid_version.rb +8 -0
- data/lib/ore/versions/version.rb +75 -0
- data/lib/ore/versions/version_constant.rb +126 -0
- data/lib/ore/versions/version_file.rb +66 -0
- data/lib/rubygems_plugin.rb +40 -0
- data/ore.gemspec +6 -0
- data/spec/dependency_spec.rb +36 -0
- data/spec/document_file_spec.rb +29 -0
- data/spec/helpers/files.rb +7 -0
- data/spec/helpers/files/.document +5 -0
- data/spec/helpers/files/VERSION +1 -0
- data/spec/helpers/files/VERSION.yml +5 -0
- data/spec/helpers/projects.rb +13 -0
- data/spec/helpers/projects/dm-plugin/Gemfile +3 -0
- data/spec/helpers/projects/dm-plugin/VERSION +1 -0
- data/spec/helpers/projects/dm-plugin/dm-plugin.gemspec +10 -0
- data/spec/helpers/projects/dm-plugin/gemspec.yml +7 -0
- data/spec/helpers/projects/dm-plugin/lib/dm-plugin.rb +1 -0
- data/spec/helpers/projects/explicit/gemspec.yml +10 -0
- data/spec/helpers/projects/explicit/lib/explicit/version.rb +15 -0
- data/spec/helpers/projects/ffi-binding/gemspec.yml +7 -0
- data/spec/helpers/projects/ffi-binding/lib/ffi/binding/version.rb +5 -0
- data/spec/helpers/projects/jewelery/VERSION +1 -0
- data/spec/helpers/projects/jewelery/bin/jewelery +3 -0
- data/spec/helpers/projects/jewelery/gemspec.yml +4 -0
- data/spec/helpers/projects/jewelery/jewelery.gemspec +10 -0
- data/spec/helpers/projects/jewelery/lib/jewelery.rb +4 -0
- data/spec/helpers/projects/jewelery/lib/jewelery/rubies.rb +4 -0
- data/spec/helpers/projects/minimal/gemspec.yml +4 -0
- data/spec/helpers/projects/minimal/lib/minimal.rb +2 -0
- data/spec/naming_spec.rb +48 -0
- data/spec/projects/dm_plugin_project_spec.rb +29 -0
- data/spec/projects/explicit_project_spec.rb +33 -0
- data/spec/projects/ffi_binding_project_spec.rb +21 -0
- data/spec/projects/jeweler_project_spec.rb +17 -0
- data/spec/projects/minimal_project_spec.rb +17 -0
- data/spec/projects/project_examples.rb +34 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/versions/version_file_spec.rb +28 -0
- data/spec/versions/version_spec.rb +53 -0
- metadata +226 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
module Ore
|
2
|
+
module Template
|
3
|
+
module Helpers
|
4
|
+
protected
|
5
|
+
|
6
|
+
#
|
7
|
+
# Renders all include files with the given name.
|
8
|
+
#
|
9
|
+
# @param [Symbol] name
|
10
|
+
# The name of the include.
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
# The combined result of the rendered include files.
|
14
|
+
#
|
15
|
+
def includes(name,separator=$/)
|
16
|
+
name = name.to_sym
|
17
|
+
output_buffer = []
|
18
|
+
|
19
|
+
if @current_template_dir
|
20
|
+
context = instance_eval('binding')
|
21
|
+
|
22
|
+
@templates.each do |template|
|
23
|
+
if template.includes.has_key?(@current_template_dir)
|
24
|
+
path = template.includes[@current_template_dir][name]
|
25
|
+
|
26
|
+
if path
|
27
|
+
erb = ERB.new(File.read(path),nil,'-')
|
28
|
+
output_buffer << erb.result(context)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
return output_buffer.join(separator)
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Determines if a template was enabled.
|
39
|
+
#
|
40
|
+
# @return [Boolean]
|
41
|
+
# Specifies whether the template was enabled.
|
42
|
+
#
|
43
|
+
def enabled?(name)
|
44
|
+
@enabled_templates.include?(name.to_sym)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Determines if the project will contain RDoc documented.
|
49
|
+
#
|
50
|
+
# @return [Boolean]
|
51
|
+
# Specifies whether the project will contain RDoc documented.
|
52
|
+
#
|
53
|
+
def rdoc?
|
54
|
+
options.rdoc?
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Determines if the project will contain YARD documented.
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
# Specifies whether the project will contain YARD documentation.
|
62
|
+
#
|
63
|
+
def yard?
|
64
|
+
enabled?(:yard)
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Determines if the project is using test-unit.
|
69
|
+
#
|
70
|
+
# @return [Boolean]
|
71
|
+
# Specifies whether the project is using test-unit.
|
72
|
+
#
|
73
|
+
def test_unit?
|
74
|
+
enabled?(:test_unit)
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Determines if the project is using RSpec.
|
79
|
+
#
|
80
|
+
# @return [Boolean]
|
81
|
+
# Specifies whether the project is using RSpec.
|
82
|
+
#
|
83
|
+
def rspec?
|
84
|
+
enabled?(:rspec)
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Determines if the project is using Bundler.
|
89
|
+
#
|
90
|
+
# @return [Boolean]
|
91
|
+
# Specifies whether the project is using Bundler.
|
92
|
+
#
|
93
|
+
def bundler?
|
94
|
+
enabled?(:bundler)
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Creates an indentation string.
|
99
|
+
#
|
100
|
+
# @param [Integer] n
|
101
|
+
# The number of times to indent.
|
102
|
+
#
|
103
|
+
# @param [Integer] spaces
|
104
|
+
# The number of spaces to indent by.
|
105
|
+
#
|
106
|
+
# @return [String]
|
107
|
+
# The indentation string.
|
108
|
+
#
|
109
|
+
def indent(n,spaces=2)
|
110
|
+
(' ' * spaces) * n
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Escapes data for YAML encoding.
|
115
|
+
#
|
116
|
+
# @param [String] data
|
117
|
+
# The data to escape.
|
118
|
+
#
|
119
|
+
# @return [String]
|
120
|
+
# The YAML safe data.
|
121
|
+
#
|
122
|
+
def yaml_escape(data)
|
123
|
+
case data
|
124
|
+
when String
|
125
|
+
if data =~ /:\s/
|
126
|
+
data.dump
|
127
|
+
elsif data.include?($/)
|
128
|
+
lines = ['']
|
129
|
+
|
130
|
+
data.each_line do |line|
|
131
|
+
lines << " #{line.strip}"
|
132
|
+
end
|
133
|
+
|
134
|
+
lines.join($/)
|
135
|
+
else
|
136
|
+
data
|
137
|
+
end
|
138
|
+
else
|
139
|
+
data.to_s
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Ore
|
2
|
+
module Template
|
3
|
+
module Interpolations
|
4
|
+
@@keywords = %w[
|
5
|
+
name
|
6
|
+
project_dir
|
7
|
+
namespace_dir
|
8
|
+
]
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def interpolate(path)
|
13
|
+
dirs = path.split(File::SEPARATOR)
|
14
|
+
|
15
|
+
dirs.each do |dir|
|
16
|
+
dir.gsub!(/(:[a-z_]+:)/) do |capture|
|
17
|
+
keyword = capture[1..-2]
|
18
|
+
|
19
|
+
if @@keywords.include?(keyword)
|
20
|
+
instance_variable_get("@#{keyword}")
|
21
|
+
else
|
22
|
+
capture
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
return File.join(dirs.reject { |dir| dir.empty? })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ore/versions.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ore/versions/exceptions/invalid_version'
|
@@ -0,0 +1,75 @@
|
|
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
|
@@ -0,0 +1,126 @@
|
|
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
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'ore/versions/exceptions/invalid_version'
|
2
|
+
require 'ore/versions/version'
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Ore
|
7
|
+
module Versions
|
8
|
+
#
|
9
|
+
# Represents a version loaded from a `VERSION` file.
|
10
|
+
#
|
11
|
+
class VersionFile < Version
|
12
|
+
|
13
|
+
# Common `VERSION` file-names.
|
14
|
+
@@files = %w[VERSION VERSION.yml]
|
15
|
+
|
16
|
+
#
|
17
|
+
# Finds the `VERSION` file.
|
18
|
+
#
|
19
|
+
# @param [Project] project
|
20
|
+
# The Ore project.
|
21
|
+
#
|
22
|
+
# @return [VersionFile, nil]
|
23
|
+
# The version file of the project.
|
24
|
+
#
|
25
|
+
def self.find(project)
|
26
|
+
@@files.each do |name|
|
27
|
+
return load(project.path(name)) if project.file?(name)
|
28
|
+
end
|
29
|
+
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Loads the version file of the project.
|
35
|
+
#
|
36
|
+
# @param [String] path
|
37
|
+
# The path to the version file.
|
38
|
+
#
|
39
|
+
# @return [VersionFile]
|
40
|
+
# The loaded version file.
|
41
|
+
#
|
42
|
+
# @raise [InvalidVersion]
|
43
|
+
# The `VERSION` file must contain either a `Hash` or a `String`.
|
44
|
+
#
|
45
|
+
def self.load(path)
|
46
|
+
data = YAML.load_file(path)
|
47
|
+
|
48
|
+
case data
|
49
|
+
when Hash
|
50
|
+
self.new(
|
51
|
+
(data[:major] || data['major']),
|
52
|
+
(data[:minor] || data['minor']),
|
53
|
+
(data[:patch] || data['patch']),
|
54
|
+
(data[:build] || data['build'])
|
55
|
+
)
|
56
|
+
when String
|
57
|
+
self.parse(data)
|
58
|
+
else
|
59
|
+
file = File.basename(@path)
|
60
|
+
raise(InvalidVersion,"invalid version data in #{file.dump}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|