ore 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -5
- data/.gitmodules +54 -0
- data/ChangeLog.md +90 -21
- data/Gemfile +12 -0
- data/LICENSE.txt +1 -1
- data/README.md +61 -27
- data/Rakefile +23 -24
- data/data/ore/abbreviations.txt +47 -0
- data/data/ore/common_namespaces.yml +13 -0
- data/data/ore/templates/apache/LICENSE.txt +202 -0
- data/data/ore/templates/apache/NOTICE.txt.erb +5 -0
- data/data/ore/templates/apache/lib/[namespace_path]/_copyright.erb +18 -0
- data/data/ore/templates/apache/template.yml +3 -0
- data/data/ore/templates/bsd/LICENSE.txt.erb +23 -0
- data/data/ore/templates/bsd/template.yml +6 -0
- data/data/ore/templates/bundler/Gemfile.erb +1 -1
- data/data/ore/templates/bundler/_tasks.erb +3 -0
- data/data/ore/templates/bundler/template.yml +5 -4
- data/data/ore/templates/code_climate/_badges.erb +1 -0
- data/data/ore/templates/code_climate/template.yml +2 -0
- data/data/ore/templates/{base → gem}/ChangeLog.md.erb +0 -0
- data/data/ore/templates/{base → gem}/ChangeLog.rdoc.erb +0 -0
- data/data/ore/templates/{base → gem}/ChangeLog.tt.erb +0 -0
- data/data/ore/templates/{base → gem}/README.md.erb +10 -4
- data/data/ore/templates/{base → gem}/README.rdoc.erb +12 -2
- data/data/ore/templates/{base → gem}/README.tt.erb +10 -4
- data/data/ore/templates/gem/Rakefile.erb +15 -0
- data/data/ore/templates/{gemspec → gem}/[name].gemspec.erb +21 -1
- data/data/ore/templates/{base → gem}/lib/[namespace_path].rb.erb +0 -0
- data/data/ore/templates/{base → gem}/lib/[namespace_path]/version.rb.erb +4 -0
- data/data/ore/templates/gem/template.yml +5 -0
- data/data/ore/templates/gem_package_task/template.yml +3 -0
- data/data/ore/templates/gemspec_yml/[name].gemspec.erb +1 -1
- data/data/ore/templates/gpl/COPYING.txt +674 -0
- data/data/ore/templates/gpl/lib/[namespace_path]/_copyright.erb +20 -0
- data/data/ore/templates/gpl/template.yml +7 -0
- data/data/ore/templates/lgpl/COPYING.txt +165 -0
- data/data/ore/templates/lgpl/lib/[namespace_path]/_copyright.erb +20 -0
- data/data/ore/templates/lgpl/template.yml +6 -0
- data/data/ore/templates/minitest/_tasks.erb +7 -0
- data/data/ore/templates/minitest/template.yml +6 -0
- data/data/ore/templates/minitest/test/helper.rb.erb +11 -0
- data/data/ore/templates/{mini_test → minitest}/test/test_[name].rb.erb +1 -1
- data/data/ore/templates/{base → mit}/LICENSE.txt.erb +0 -0
- data/data/ore/templates/mit/template.yml +8 -0
- data/data/ore/templates/rdoc/.document.erb +6 -0
- data/data/ore/templates/rdoc/.rdoc_options.erb +16 -0
- data/data/ore/templates/rdoc/_tasks.erb +5 -9
- data/data/ore/templates/rdoc/template.yml +2 -5
- data/data/ore/templates/rspec/_tasks.erb +1 -2
- data/data/ore/templates/rspec/spec/[namespace_dir]_spec.rb.erb +1 -1
- data/data/ore/templates/rspec/spec/spec_helper.rb.erb +0 -3
- data/data/ore/templates/rspec/template.yml +2 -2
- data/data/ore/templates/rubygems_tasks/_tasks.erb +0 -1
- data/data/ore/templates/rubygems_tasks/template.yml +3 -0
- data/data/ore/templates/test_unit/template.yml +1 -1
- data/data/ore/templates/test_unit/test/helper.rb.erb +3 -13
- data/data/ore/templates/travis/.travis.yml +6 -0
- data/data/ore/templates/travis/_badges.erb +1 -0
- data/data/ore/templates/yard/.document.erb +3 -1
- data/data/ore/templates/yard/_tasks.erb +2 -3
- data/data/ore/templates/yard/template.yml +2 -1
- data/gemspec.yml +6 -7
- data/lib/ore/actions.rb +1 -1
- data/lib/ore/cli.rb +1 -0
- data/lib/ore/config.rb +33 -41
- data/lib/ore/generator.rb +104 -66
- data/lib/ore/naming.rb +12 -19
- data/lib/ore/options.rb +71 -40
- data/lib/ore/template/directory.rb +3 -9
- data/lib/ore/template/helpers.rb +26 -2
- data/lib/ore/template/helpers/markdown.rb +96 -0
- data/lib/ore/template/helpers/rdoc.rb +96 -0
- data/lib/ore/template/helpers/textile.rb +106 -0
- data/lib/ore/template/markup.rb +19 -0
- data/lib/ore/version.rb +1 -1
- data/ore.gemspec +11 -0
- data/spec/gemspec_examples.rb +8 -8
- data/spec/generator_spec.rb +231 -181
- data/spec/helpers/generator.rb +5 -1
- data/spec/naming_spec.rb +11 -11
- data/spec/spec_helper.rb +0 -1
- data/spec/template/helpers/markdown_spec.rb +84 -0
- data/spec/template/helpers/rdoc_spec.rb +84 -0
- data/spec/template/helpers/textile_spec.rb +92 -0
- metadata +84 -85
- data/.gemtest +0 -0
- data/data/ore/templates/base/Rakefile.erb +0 -25
- data/data/ore/templates/base/template.yml +0 -2
- data/data/ore/templates/bundler_tasks/_tasks.erb +0 -1
- data/data/ore/templates/bundler_tasks/template.yml +0 -6
- data/data/ore/templates/gemspec/template.yml +0 -2
- data/data/ore/templates/gemspec_yml/template.yml +0 -2
- data/data/ore/templates/mini_test/template.yml +0 -3
- data/data/ore/templates/mini_test/test/helper.rb.erb +0 -26
- data/data/ore/templates/rdoc/.document +0 -4
data/lib/ore/options.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
require 'ore/template'
|
1
|
+
require 'yaml'
|
3
2
|
|
4
3
|
module Ore
|
5
4
|
#
|
6
|
-
#
|
5
|
+
# Value object to contain `~/.ore/options.yml` data.
|
7
6
|
#
|
8
|
-
# @since 0.
|
7
|
+
# @since 0.11.0
|
9
8
|
#
|
10
|
-
|
9
|
+
class Options
|
10
|
+
|
11
|
+
# Default markup
|
12
|
+
DEFAULT_MARKUP = 'markdown'
|
13
|
+
|
11
14
|
# Default version
|
12
15
|
DEFAULT_VERSION = '0.1.0'
|
13
16
|
|
@@ -17,47 +20,75 @@ module Ore
|
|
17
20
|
# Default description
|
18
21
|
DEFAULT_DESCRIPTION = %q{TODO: Description}
|
19
22
|
|
20
|
-
# Default
|
21
|
-
|
23
|
+
# Default templates
|
24
|
+
DEFAULT_TEMPLATES = [
|
25
|
+
:git,
|
26
|
+
:mit,
|
27
|
+
:bundler,
|
28
|
+
:rubygems_tasks,
|
29
|
+
:rdoc,
|
30
|
+
:rspec
|
31
|
+
]
|
22
32
|
|
23
|
-
|
24
|
-
|
25
|
-
|
33
|
+
# Default options
|
34
|
+
DEFAULTS = {
|
35
|
+
markup: DEFAULT_MARKUP,
|
36
|
+
version: DEFAULT_VERSION,
|
37
|
+
summary: DEFAULT_SUMMARY,
|
38
|
+
description: DEFAULT_DESCRIPTION
|
39
|
+
}
|
40
|
+
DEFAULT_TEMPLATES.each { |name| DEFAULTS[name] = true }
|
26
41
|
|
27
42
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# @
|
31
|
-
# The
|
32
|
-
#
|
33
|
-
def
|
34
|
-
|
35
|
-
:templates => [],
|
36
|
-
:version => DEFAULT_VERSION,
|
37
|
-
:summary => DEFAULT_SUMMARY,
|
38
|
-
:description => DEFAULT_DESCRIPTION,
|
39
|
-
:license => DEFAULT_LICENSE,
|
40
|
-
:gemspec => true,
|
41
|
-
:rubygems_tasks => true,
|
42
|
-
:rdoc => true,
|
43
|
-
:rspec => true,
|
44
|
-
:git => true
|
45
|
-
}.merge(Config.options)
|
43
|
+
# Initializes the options.
|
44
|
+
#
|
45
|
+
# @param [Hash{Symbol => Object}] options
|
46
|
+
# The options hash.
|
47
|
+
#
|
48
|
+
def initialize(options={})
|
49
|
+
@options = DEFAULTS.merge(options)
|
46
50
|
end
|
47
51
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
#
|
53
|
+
# Loads the options from a YAML file.
|
54
|
+
#
|
55
|
+
# @param [String] path
|
56
|
+
# Path to the options file.
|
57
|
+
#
|
58
|
+
# @return [Options]
|
59
|
+
# The loaded options.
|
60
|
+
#
|
61
|
+
# @raise [RuntimeError]
|
62
|
+
# The file contained malformed YAML.
|
63
|
+
#
|
64
|
+
def self.load(path)
|
65
|
+
data = YAML.load_file(path)
|
66
|
+
|
67
|
+
unless data.kind_of?(Hash)
|
68
|
+
raise("#{path} must contain a YAML encoded Hash")
|
60
69
|
end
|
70
|
+
|
71
|
+
options = {}
|
72
|
+
|
73
|
+
data.each do |key,value|
|
74
|
+
options[key.to_sym] = value
|
75
|
+
end
|
76
|
+
|
77
|
+
return new(options)
|
61
78
|
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Accesses an option.
|
82
|
+
#
|
83
|
+
# @param [Symbol] key
|
84
|
+
# The option name.
|
85
|
+
#
|
86
|
+
# @return [Object]
|
87
|
+
# The option value.
|
88
|
+
#
|
89
|
+
def [](key)
|
90
|
+
@options[key]
|
91
|
+
end
|
92
|
+
|
62
93
|
end
|
63
94
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ore/template/exceptions/invalid_template'
|
2
|
+
require 'ore/template/markup'
|
2
3
|
|
3
4
|
require 'yaml'
|
4
5
|
require 'find'
|
@@ -17,13 +18,6 @@ module Ore
|
|
17
18
|
# Files or directory names to ignore
|
18
19
|
IGNORE = ['.git', CONFIG_FILE]
|
19
20
|
|
20
|
-
# The known markup languages and file extensions
|
21
|
-
MARKUPS = {
|
22
|
-
:markdown => %w[.md .markdown],
|
23
|
-
:textile => %w[.tt .textile],
|
24
|
-
:rdoc => %w[.rdoc]
|
25
|
-
}
|
26
|
-
|
27
21
|
# The path of the template directory
|
28
22
|
attr_reader :path
|
29
23
|
|
@@ -247,7 +241,7 @@ module Ore
|
|
247
241
|
# Specifies whether the file is formatting.
|
248
242
|
#
|
249
243
|
def formatted?(path)
|
250
|
-
|
244
|
+
Markup::EXTS.values.any? { |exts| exts.include?(File.extname(path)) }
|
251
245
|
end
|
252
246
|
|
253
247
|
#
|
@@ -263,7 +257,7 @@ module Ore
|
|
263
257
|
# Specifies whether the file contains the given formatting.
|
264
258
|
#
|
265
259
|
def formatted_like?(path,markup)
|
266
|
-
|
260
|
+
Markup::EXTS[markup].include?(File.extname(path))
|
267
261
|
end
|
268
262
|
|
269
263
|
end
|
data/lib/ore/template/helpers.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
+
require 'ore/template/helpers/markdown'
|
2
|
+
require 'ore/template/helpers/textile'
|
3
|
+
require 'ore/template/helpers/rdoc'
|
4
|
+
|
1
5
|
module Ore
|
2
6
|
module Template
|
3
7
|
#
|
4
8
|
# Helper methods that can be used within ERb templates.
|
5
9
|
#
|
6
10
|
module Helpers
|
7
|
-
|
11
|
+
# Markup helpers
|
12
|
+
MARKUP = {
|
13
|
+
markdown: Markdown,
|
14
|
+
textile: Textile,
|
15
|
+
rdoc: RDoc
|
16
|
+
}
|
8
17
|
|
9
18
|
#
|
10
19
|
# Renders all include files with the given name.
|
@@ -219,11 +228,26 @@ module Ore
|
|
219
228
|
# @param [Integer] spaces
|
220
229
|
# The number of spaces to indent by.
|
221
230
|
#
|
231
|
+
# @yield []
|
232
|
+
# The given block will be used as the text.
|
233
|
+
#
|
222
234
|
# @return [String]
|
223
235
|
# The indentation string.
|
224
236
|
#
|
225
237
|
def indent(n,spaces=2)
|
226
|
-
|
238
|
+
@indent ||= 0
|
239
|
+
@indent += (spaces * n)
|
240
|
+
|
241
|
+
margin = ' ' * @indent
|
242
|
+
|
243
|
+
text = if block_given?
|
244
|
+
yield.each_line.map { |line| margin + line }.join
|
245
|
+
else
|
246
|
+
margin
|
247
|
+
end
|
248
|
+
|
249
|
+
@indent -= (spaces * n)
|
250
|
+
return text
|
227
251
|
end
|
228
252
|
|
229
253
|
#
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Ore
|
2
|
+
module Template
|
3
|
+
module Helpers
|
4
|
+
#
|
5
|
+
# @api semipublic
|
6
|
+
#
|
7
|
+
# @since 0.10.0
|
8
|
+
#
|
9
|
+
module Markdown
|
10
|
+
#
|
11
|
+
# Emits a markdown link.
|
12
|
+
#
|
13
|
+
# @param [String, nil] text
|
14
|
+
#
|
15
|
+
# @param [String] url
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
#
|
19
|
+
def link_to(text,url)
|
20
|
+
"[#{text}](#{url})"
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Emits a markdown image.
|
25
|
+
#
|
26
|
+
# @param [String] url
|
27
|
+
#
|
28
|
+
# @param [String, nil] alt
|
29
|
+
#
|
30
|
+
# @return [String]
|
31
|
+
#
|
32
|
+
def image(url,alt=nil)
|
33
|
+
"![#{alt}](#{url})"
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Emits a markdown h1 heading.
|
38
|
+
#
|
39
|
+
# @param [String] title
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
#
|
43
|
+
def h1(title)
|
44
|
+
"# #{title}"
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Emits a markdown h2 heading.
|
49
|
+
#
|
50
|
+
# @param [String] title
|
51
|
+
#
|
52
|
+
# @return [String]
|
53
|
+
#
|
54
|
+
def h2(title)
|
55
|
+
"## #{title}"
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Emits a markdown h3 heading.
|
60
|
+
#
|
61
|
+
# @param [String] title
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
#
|
65
|
+
def h3(title)
|
66
|
+
"### #{title}"
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Emits a markdown h4 heading.
|
71
|
+
#
|
72
|
+
# @param [String] title
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
def h4(title)
|
77
|
+
"#### #{title}"
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Emits a markdown code block.
|
82
|
+
#
|
83
|
+
# @param [String] code
|
84
|
+
#
|
85
|
+
# @yield []
|
86
|
+
# The return value of the given block will be used as the code.
|
87
|
+
#
|
88
|
+
# @return [String]
|
89
|
+
#
|
90
|
+
def pre(code)
|
91
|
+
code.each_line.map { |line| " #{line}" }.join
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Ore
|
2
|
+
module Template
|
3
|
+
module Helpers
|
4
|
+
#
|
5
|
+
# @api semipublic
|
6
|
+
#
|
7
|
+
# @since 0.10.0
|
8
|
+
#
|
9
|
+
module RDoc
|
10
|
+
#
|
11
|
+
# Emits a RDoc link.
|
12
|
+
#
|
13
|
+
# @param [String, nil] text
|
14
|
+
#
|
15
|
+
# @param [String] url
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
#
|
19
|
+
def link_to(text,url)
|
20
|
+
"{#{text}}[#{url}]"
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Emits a RDoc image.
|
25
|
+
#
|
26
|
+
# @param [String] url
|
27
|
+
#
|
28
|
+
# @param [String, nil] alt
|
29
|
+
#
|
30
|
+
# @return [String]
|
31
|
+
#
|
32
|
+
def image(url,alt=nil)
|
33
|
+
"{#{alt}}[rdoc-image:#{url}]"
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Emits a RDoc h1 heading.
|
38
|
+
#
|
39
|
+
# @param [String] title
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
#
|
43
|
+
def h1(title)
|
44
|
+
"= #{title}"
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Emits a RDoc h2 heading.
|
49
|
+
#
|
50
|
+
# @param [String] title
|
51
|
+
#
|
52
|
+
# @return [String]
|
53
|
+
#
|
54
|
+
def h2(title)
|
55
|
+
"== #{title}"
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Emits a RDoc h3 heading.
|
60
|
+
#
|
61
|
+
# @param [String] title
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
#
|
65
|
+
def h3(title)
|
66
|
+
"=== #{title}"
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Emits a RDoc h4 heading.
|
71
|
+
#
|
72
|
+
# @param [String] title
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
def h4(title)
|
77
|
+
"==== #{title}"
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Emits a RDoc code block.
|
82
|
+
#
|
83
|
+
# @param [String] code
|
84
|
+
#
|
85
|
+
# @yield []
|
86
|
+
# The return value of the given block will be used as the code.
|
87
|
+
#
|
88
|
+
# @return [String]
|
89
|
+
#
|
90
|
+
def pre(code)
|
91
|
+
code.each_line.map { |line| " #{line}" }.join
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Ore
|
2
|
+
module Template
|
3
|
+
module Helpers
|
4
|
+
#
|
5
|
+
# @api semipublic
|
6
|
+
#
|
7
|
+
# @since 0.10.0
|
8
|
+
#
|
9
|
+
module Textile
|
10
|
+
#
|
11
|
+
# Emits a Textile link.
|
12
|
+
#
|
13
|
+
# @param [String, nil] text
|
14
|
+
#
|
15
|
+
# @param [String] url
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
#
|
19
|
+
def link_to(text,url)
|
20
|
+
if text
|
21
|
+
"#{text.dump}:#{url}"
|
22
|
+
else
|
23
|
+
url
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# Emits a Textile image tag.
|
29
|
+
#
|
30
|
+
# @param [String] url
|
31
|
+
#
|
32
|
+
# @param [String, nil] alt
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
#
|
36
|
+
def image(url,alt=nil)
|
37
|
+
if alt then "!#{url}(#{alt})!"
|
38
|
+
else "!#{url}!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Emits a Textile h1 heading.
|
44
|
+
#
|
45
|
+
# @param [String] title
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
#
|
49
|
+
def h1(title)
|
50
|
+
"h1. #{title}"
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Emits a Textile h2 heading.
|
55
|
+
#
|
56
|
+
# @param [String] title
|
57
|
+
#
|
58
|
+
# @return [String]
|
59
|
+
#
|
60
|
+
def h2(title)
|
61
|
+
"h2. #{title}"
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Emits a Textile h3 heading.
|
66
|
+
#
|
67
|
+
# @param [String] title
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
#
|
71
|
+
def h3(title)
|
72
|
+
"h3. #{title}"
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Emits a Textile h4 heading.
|
77
|
+
#
|
78
|
+
# @param [String] title
|
79
|
+
#
|
80
|
+
# @return [String]
|
81
|
+
#
|
82
|
+
def h4(title)
|
83
|
+
"h4. #{title}"
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Emits a Textile code block.
|
88
|
+
#
|
89
|
+
# @param [String] code
|
90
|
+
#
|
91
|
+
# @yield []
|
92
|
+
# The return value of the given block will be used as the code.
|
93
|
+
#
|
94
|
+
# @return [String]
|
95
|
+
#
|
96
|
+
def pre(code)
|
97
|
+
if code =~ /#{$/}\s*#{$/}/
|
98
|
+
"bc.. #{code}"
|
99
|
+
else
|
100
|
+
"bc. #{code}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|