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
data/gemspec.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
name: ore
|
2
|
+
version: 0.1.2
|
3
|
+
summary: Cut raw RubyGems from YAML
|
4
|
+
description:
|
5
|
+
Ore is a simple RubyGem building solution. Ore handles the
|
6
|
+
creation of Gem::Specification objects as well as building '.gem'
|
7
|
+
files. Ore allows the developer to keep all of the project information
|
8
|
+
in a single YAML file.
|
9
|
+
|
10
|
+
license: MIT
|
11
|
+
authors: Postmodern
|
12
|
+
email: postmodern.mod3@gmail.com
|
13
|
+
homepage: http://github.com/postmodern/ore
|
14
|
+
has_yard: true
|
15
|
+
|
16
|
+
dependencies:
|
17
|
+
thor: ~> 0.14.3
|
18
|
+
|
19
|
+
development_dependencies:
|
20
|
+
yard: ~> 0.6.1
|
21
|
+
rspec: ~> 2.0.0
|
data/lib/ore.rb
ADDED
data/lib/ore/checks.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
module Ore
|
2
|
+
module Checks
|
3
|
+
protected
|
4
|
+
|
5
|
+
#
|
6
|
+
# Checks if the path is readable.
|
7
|
+
#
|
8
|
+
# @yield [path]
|
9
|
+
# The block will be passed the path, if it is readable.
|
10
|
+
# Otherwise a warning will be printed.
|
11
|
+
#
|
12
|
+
# @yieldparam [String] path
|
13
|
+
# A readable path.
|
14
|
+
#
|
15
|
+
def check_readable(path)
|
16
|
+
if File.readable?(path)
|
17
|
+
yield path
|
18
|
+
else
|
19
|
+
warn "#{path} is not readable!"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Checks if the path is a readable directory.
|
25
|
+
#
|
26
|
+
# @yield [path]
|
27
|
+
# The block will be passed the path, if it is a readable directory.
|
28
|
+
# Otherwise a warning will be printed.
|
29
|
+
#
|
30
|
+
# @yieldparam [String] path
|
31
|
+
# The directory path.
|
32
|
+
#
|
33
|
+
def check_directory(path)
|
34
|
+
check_readable(path) do |dir|
|
35
|
+
if File.directory?(dir)
|
36
|
+
yield dir
|
37
|
+
else
|
38
|
+
warn "#{dir} is not a directory!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Checks if the path is a readable file.
|
45
|
+
#
|
46
|
+
# @yield [path]
|
47
|
+
# The block will be passed the path, if it is a readable file.
|
48
|
+
# Otherwise a warning will be printed.
|
49
|
+
#
|
50
|
+
# @yieldparam [String] path
|
51
|
+
# A file path.
|
52
|
+
#
|
53
|
+
def check_file(path)
|
54
|
+
if @project_files.include?(path)
|
55
|
+
check_readable(path) do |file|
|
56
|
+
if File.file?(file)
|
57
|
+
yield file
|
58
|
+
else
|
59
|
+
warn "#{file} is not a file!"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Checks if the path is an executable file.
|
67
|
+
#
|
68
|
+
# @yield [path]
|
69
|
+
# The block will be passed the path, if it is an executable file.
|
70
|
+
# Otherwise a warning will be printed.
|
71
|
+
#
|
72
|
+
# @yieldparam [String] path
|
73
|
+
# An path to an executable file.
|
74
|
+
#
|
75
|
+
def check_executable(path)
|
76
|
+
check_file(path) do |file|
|
77
|
+
if File.executable?(file)
|
78
|
+
yield file
|
79
|
+
else
|
80
|
+
warn "#{file} is not executable!"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/ore/cli.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'ore/config'
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
module Ore
|
8
|
+
class CLI < Thor
|
9
|
+
|
10
|
+
include Config
|
11
|
+
|
12
|
+
default_task :cut
|
13
|
+
|
14
|
+
map '-l' => :list
|
15
|
+
map '-u' => :update
|
16
|
+
map '-r' => :remove
|
17
|
+
|
18
|
+
desc 'list', 'List installed Ore templates'
|
19
|
+
|
20
|
+
#
|
21
|
+
# Lists builtin and installed templates.
|
22
|
+
#
|
23
|
+
def list
|
24
|
+
print_template = lambda { |path|
|
25
|
+
puts " #{File.basename(path)}"
|
26
|
+
}
|
27
|
+
|
28
|
+
say "Builtin templates:", :green
|
29
|
+
Config.builtin_templates(&print_template)
|
30
|
+
|
31
|
+
say "Installed templates:", :green
|
32
|
+
Config.installed_templates(&print_template)
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'install URI', 'Installs an Ore template'
|
36
|
+
|
37
|
+
#
|
38
|
+
# Installs a template into `~/.ore/templates`.
|
39
|
+
#
|
40
|
+
# @param [String] uri
|
41
|
+
# The Git URI to install the template from.
|
42
|
+
#
|
43
|
+
def install(uri)
|
44
|
+
url = URI(uri)
|
45
|
+
|
46
|
+
name = File.basename(url.path)
|
47
|
+
name.gsub!(/\.git$/,'')
|
48
|
+
|
49
|
+
path = File.join(@@templates_dir,name)
|
50
|
+
|
51
|
+
if File.directory?(path)
|
52
|
+
say "Template #{name} already installed.", :red
|
53
|
+
exit -1
|
54
|
+
end
|
55
|
+
|
56
|
+
FileUtils.mkdir_p(path)
|
57
|
+
system('git','clone',uri,path)
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'update', 'Updates all installed templates'
|
61
|
+
|
62
|
+
#
|
63
|
+
# Updates all previously installed templates.
|
64
|
+
#
|
65
|
+
def update
|
66
|
+
Config.installed_templates do |path|
|
67
|
+
say "Updating #{File.basename(path)} ...", :green
|
68
|
+
|
69
|
+
Dir.chdir(path) { system('git','pull','-q') }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'remove NAME', 'Removes an Ore template'
|
74
|
+
|
75
|
+
#
|
76
|
+
# Removes a previously installed template.
|
77
|
+
#
|
78
|
+
# @param [String] name
|
79
|
+
# The name of the template to remove.
|
80
|
+
#
|
81
|
+
def remove(name)
|
82
|
+
name = File.basename(name)
|
83
|
+
path = File.join(@@templates_dir,name)
|
84
|
+
|
85
|
+
unless File.exists?(path)
|
86
|
+
say "Unknown template: #{name}", :red
|
87
|
+
exit -1
|
88
|
+
end
|
89
|
+
|
90
|
+
FileUtils.rm_rf(path)
|
91
|
+
end
|
92
|
+
|
93
|
+
desc 'gemspec', 'Dumps a Ruby gemspec for the project'
|
94
|
+
method_option :ruby, :type => :boolean,
|
95
|
+
:default => true,
|
96
|
+
:aliases => '-R'
|
97
|
+
method_option :yaml, :type => :boolean, :aliases => '-Y'
|
98
|
+
|
99
|
+
def gemspec
|
100
|
+
require 'ore/project'
|
101
|
+
|
102
|
+
gemspec = Project.find.to_gemspec
|
103
|
+
|
104
|
+
if options.yaml?
|
105
|
+
print YAML.dump(gemspec)
|
106
|
+
else
|
107
|
+
print gemspec.to_ruby
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
desc 'cut', 'Cuts a new RubyGem'
|
112
|
+
|
113
|
+
def cut
|
114
|
+
require 'ore/project'
|
115
|
+
|
116
|
+
Project.find.build!
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
data/lib/ore/config.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Ore
|
4
|
+
module Config
|
5
|
+
# The users home directory
|
6
|
+
@@home = File.expand_path(ENV['HOME'] || ENV['HOMEPATH'])
|
7
|
+
|
8
|
+
# Ore config directory
|
9
|
+
@@path = File.join(@@home,'.ore')
|
10
|
+
|
11
|
+
# Default `ore` options file.
|
12
|
+
@@options_file = File.join(@@path,'default.opts')
|
13
|
+
|
14
|
+
# Custom Ore Templates directory
|
15
|
+
@@templates_dir = File.join(@@path,'templates')
|
16
|
+
|
17
|
+
# The `data/` directory for Ore
|
18
|
+
@@data_dir = File.expand_path(File.join('..','..','data'),File.dirname(__FILE__))
|
19
|
+
|
20
|
+
#
|
21
|
+
# The builtin templates.
|
22
|
+
#
|
23
|
+
# @yield [path]
|
24
|
+
# The given block will be passed every builtin template.
|
25
|
+
#
|
26
|
+
# @yieldparam [String] path
|
27
|
+
# The path of a Ore template directory.
|
28
|
+
#
|
29
|
+
def Config.builtin_templates(&block)
|
30
|
+
path = File.join(@@data_dir,'ore','templates')
|
31
|
+
|
32
|
+
if File.directory?(path)
|
33
|
+
Dir.glob("#{path}/*",&block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# The installed templates.
|
39
|
+
#
|
40
|
+
# @yield [path]
|
41
|
+
# The given block will be passed every installed template.
|
42
|
+
#
|
43
|
+
# @yieldparam [String] path
|
44
|
+
# The path of a Ore template directory.
|
45
|
+
#
|
46
|
+
def Config.installed_templates(&block)
|
47
|
+
if File.directory?(@@templates_dir)
|
48
|
+
Dir.glob("#{@@templates_dir}/*",&block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/ore/defaults.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'ore/naming'
|
2
|
+
require 'ore/versions'
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module Ore
|
7
|
+
module Defaults
|
8
|
+
include Naming
|
9
|
+
|
10
|
+
# The default require-paths
|
11
|
+
@@require_paths = [@@lib_dir, @@ext_dir]
|
12
|
+
|
13
|
+
# The glob to find default executables
|
14
|
+
@@executables = "#{@@bin_dir}/*"
|
15
|
+
|
16
|
+
# The globs to find all testing-files
|
17
|
+
@@test_files = [
|
18
|
+
"#{@@test_dir}/{**/}*_test.rb",
|
19
|
+
"#{@@spec_dir}/{**/}*_spec.rb"
|
20
|
+
]
|
21
|
+
|
22
|
+
# The files to always exclude
|
23
|
+
@@exclude_files = %w[
|
24
|
+
.gitignore
|
25
|
+
]
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
#
|
30
|
+
# Sets the project name using the directory name of the project.
|
31
|
+
#
|
32
|
+
def default_name!
|
33
|
+
@name = @root.basename.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Finds and sets the version of the project.
|
38
|
+
#
|
39
|
+
def default_version!
|
40
|
+
@version = (
|
41
|
+
Versions::VersionFile.find(self) ||
|
42
|
+
Versions::VersionConstant.find(self)
|
43
|
+
)
|
44
|
+
|
45
|
+
unless @version
|
46
|
+
#raise(InvalidMetadata,"no version file or constant in #{@root}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Sets the release date of the project.
|
52
|
+
#
|
53
|
+
def default_date!
|
54
|
+
@date = Date.today
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Sets the require-paths of the project.
|
59
|
+
#
|
60
|
+
def default_require_paths!
|
61
|
+
@@require_paths.each do |name|
|
62
|
+
@require_paths << name if @root.join(name).directory?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Sets the executables of the project.
|
68
|
+
#
|
69
|
+
def default_executables!
|
70
|
+
glob(@@executables) do |path|
|
71
|
+
check_executable(path) { |exe| @executables << File.basename(exe) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# sets the default executable of the project.
|
77
|
+
#
|
78
|
+
def default_executable!
|
79
|
+
@default_executable = if @executables.include?(@name)
|
80
|
+
@name
|
81
|
+
else
|
82
|
+
@executables.first
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Sets the default documentation of the project.
|
88
|
+
#
|
89
|
+
def default_documentation!
|
90
|
+
if file?('.yardopts')
|
91
|
+
@documentation = :yard
|
92
|
+
else
|
93
|
+
@documentation = :rdoc
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Sets the extra documentation files of the project.
|
99
|
+
#
|
100
|
+
def default_extra_doc_files!
|
101
|
+
glob('README.*') { |path| add_extra_doc_file(path) }
|
102
|
+
|
103
|
+
if @document
|
104
|
+
@document.each_extra_file { |path| add_extra_doc_file(path) }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Sets the files of the project.
|
110
|
+
#
|
111
|
+
def default_files!
|
112
|
+
@project_files.each do |file|
|
113
|
+
@files << file unless @@exclude_files.include?(file)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Sets the test-files of the project.
|
119
|
+
#
|
120
|
+
def default_test_files!
|
121
|
+
@@test_files.each do |pattern|
|
122
|
+
glob(pattern) { |path| add_test_file(path) }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Defaults the required version of RubyGems to `>= 1.3.6`, if the
|
128
|
+
# project uses Bundler.
|
129
|
+
#
|
130
|
+
def default_required_rubygems_version!
|
131
|
+
if bundler?
|
132
|
+
@required_rubygems_version = '>= 1.3.6'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Ore
|
2
|
+
class Dependency
|
3
|
+
|
4
|
+
# The name of the dependency
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
# The required versions
|
8
|
+
attr_reader :versions
|
9
|
+
|
10
|
+
#
|
11
|
+
# Creates a new dependency.
|
12
|
+
#
|
13
|
+
# @param [String] name
|
14
|
+
# The name of the dependency.
|
15
|
+
#
|
16
|
+
# @param [Array<String>] versions
|
17
|
+
# The required versions.
|
18
|
+
#
|
19
|
+
def initialize(name,*versions)
|
20
|
+
@name = name
|
21
|
+
@versions = versions
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Parses a version string.
|
26
|
+
#
|
27
|
+
# @param [String] name
|
28
|
+
# The name of the dependency.
|
29
|
+
#
|
30
|
+
# @param [String, nil] versions
|
31
|
+
# The version string.
|
32
|
+
#
|
33
|
+
# @return [Dependency]
|
34
|
+
# The parsed dependency.
|
35
|
+
#
|
36
|
+
def self.parse_versions(name,versions)
|
37
|
+
versions = if versions.kind_of?(String)
|
38
|
+
versions.strip.split(/,\s*/)
|
39
|
+
else
|
40
|
+
[]
|
41
|
+
end
|
42
|
+
|
43
|
+
return new(name,*versions)
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Parses a dependencey string.
|
48
|
+
#
|
49
|
+
# @param [String] dependency
|
50
|
+
# The dependencey string.
|
51
|
+
#
|
52
|
+
# @return [Dependency]
|
53
|
+
# The parsed dependency.
|
54
|
+
#
|
55
|
+
def self.parse(dependency)
|
56
|
+
name, versions = dependency.strip.split(/\s+/,2)
|
57
|
+
|
58
|
+
return parse_versions(name,versions)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|