bones 3.5.5 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +11 -0
- data/default/Rakefile.bns +1 -1
- data/default/lib/NAME.rb.bns +7 -12
- data/gem-development.txt +1 -0
- data/lib/bones.rb +10 -8
- data/lib/bones/annotation_extractor.rb +3 -3
- data/lib/bones/app.rb +4 -3
- data/lib/bones/app/command.rb +9 -3
- data/lib/bones/app/create.rb +9 -8
- data/lib/bones/app/file_manager.rb +42 -8
- data/lib/bones/app/freeze.rb +1 -0
- data/lib/bones/app/info.rb +3 -3
- data/lib/bones/app/plugins.rb +2 -1
- data/lib/bones/app/unfreeze.rb +1 -0
- data/lib/bones/colors.rb +57 -43
- data/lib/bones/plugins/gem.rb +166 -64
- data/lib/bones/plugins/rdoc.rb +40 -22
- data/spec/bones/app/file_manager_spec.rb +2 -4
- data/spec/bones/app_spec.rb +1 -1
- data/version.txt +1 -1
- metadata +7 -6
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 3.6.0 / 2011-01-21
|
2
|
+
|
3
|
+
Enhancements
|
4
|
+
- Use RDoc::Task if it's available. Otherwise fallback to Rake::RDoctask.
|
5
|
+
- Specify gem sources in the Bones configuration block.
|
6
|
+
- Initialize bones from an external gemspec file.
|
7
|
+
- Colorization of bones command output.
|
8
|
+
|
9
|
+
Bug Fixes
|
10
|
+
- Excluding the "version.txt" file from rdoc processing.
|
11
|
+
|
1
12
|
== 3.5.5 / 2011-01-10
|
2
13
|
|
3
14
|
1 bug fix
|
data/default/Rakefile.bns
CHANGED
data/default/lib/NAME.rb.bns
CHANGED
@@ -4,24 +4,19 @@ module <%= classname %>
|
|
4
4
|
# :stopdoc:
|
5
5
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
6
6
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
7
|
+
VERSION = ::File.read(PATH + 'version.txt').strip
|
7
8
|
# :startdoc:
|
8
9
|
|
9
|
-
# Returns the version string for the library.
|
10
|
-
#
|
11
|
-
def self.version
|
12
|
-
@version ||= File.read(path('version.txt')).strip
|
13
|
-
end
|
14
|
-
|
15
10
|
# Returns the library path for the module. If any arguments are given,
|
16
11
|
# they will be joined to the end of the libray path using
|
17
12
|
# <tt>File.join</tt>.
|
18
13
|
#
|
19
|
-
def self.libpath( *args
|
14
|
+
def self.libpath( *args )
|
20
15
|
rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
21
|
-
if
|
16
|
+
if block_given?
|
22
17
|
begin
|
23
18
|
$LOAD_PATH.unshift LIBPATH
|
24
|
-
rv =
|
19
|
+
rv = yield
|
25
20
|
ensure
|
26
21
|
$LOAD_PATH.shift
|
27
22
|
end
|
@@ -33,12 +28,12 @@ module <%= classname %>
|
|
33
28
|
# they will be joined to the end of the path using
|
34
29
|
# <tt>File.join</tt>.
|
35
30
|
#
|
36
|
-
def self.path( *args
|
31
|
+
def self.path( *args )
|
37
32
|
rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
38
|
-
if
|
33
|
+
if block_given?
|
39
34
|
begin
|
40
35
|
$LOAD_PATH.unshift PATH
|
41
|
-
rv =
|
36
|
+
rv = yield
|
42
37
|
ensure
|
43
38
|
$LOAD_PATH.shift
|
44
39
|
end
|
data/gem-development.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
https://github.com/radar/guides/blob/master/gem-development.md
|
data/lib/bones.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rake'
|
4
4
|
require 'rake/clean'
|
5
|
+
require 'pathname'
|
5
6
|
require 'fileutils'
|
6
7
|
require 'find'
|
7
8
|
require 'rbconfig'
|
@@ -32,12 +33,12 @@ module Bones
|
|
32
33
|
# Returns the path for Mr Bones. If any arguments are given,
|
33
34
|
# they will be joined to the end of the path using <tt>File.join</tt>.
|
34
35
|
#
|
35
|
-
def self.path( *args
|
36
|
+
def self.path( *args )
|
36
37
|
rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
37
|
-
if
|
38
|
+
if block_given?
|
38
39
|
begin
|
39
40
|
$LOAD_PATH.unshift PATH
|
40
|
-
rv =
|
41
|
+
rv = yield
|
41
42
|
ensure
|
42
43
|
$LOAD_PATH.shift
|
43
44
|
end
|
@@ -48,12 +49,12 @@ module Bones
|
|
48
49
|
# Returns the lib path for Mr Bones. If any arguments are given,
|
49
50
|
# they will be joined to the end of the path using <tt>File.join</tt>.
|
50
51
|
#
|
51
|
-
def self.libpath( *args
|
52
|
+
def self.libpath( *args )
|
52
53
|
rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
53
|
-
if
|
54
|
+
if block_given?
|
54
55
|
begin
|
55
56
|
$LOAD_PATH.unshift LIBPATH
|
56
|
-
rv =
|
57
|
+
rv = yield
|
57
58
|
ensure
|
58
59
|
$LOAD_PATH.shift
|
59
60
|
end
|
@@ -87,7 +88,7 @@ Bones.libpath {
|
|
87
88
|
each { |fn| require File.join('bones', fn) }
|
88
89
|
|
89
90
|
Bones.config {}
|
90
|
-
Loquacious.remove :gem, :file, :test
|
91
|
+
Loquacious.remove :gem, :file, :test, :timeout
|
91
92
|
}
|
92
93
|
|
93
94
|
module Kernel
|
@@ -97,13 +98,14 @@ module Kernel
|
|
97
98
|
# Configure Mr Bones using the given _block_ of code. If a block is not
|
98
99
|
# given, the Bones module is returned.
|
99
100
|
#
|
100
|
-
def Bones( &block )
|
101
|
+
def Bones( filename = nil, &block )
|
101
102
|
|
102
103
|
# we absolutely have to have the bones plugin
|
103
104
|
plugin_names = ::Bones.plugin_names
|
104
105
|
::Bones.plugin :bones_plugin unless plugin_names.empty? or plugin_names.include? :bones_plugin
|
105
106
|
|
106
107
|
plugins = ::Bones.initialize_plugins.values
|
108
|
+
::Bones::Plugins::Gem.import_gemspec(filename) if filename
|
107
109
|
return ::Bones unless block
|
108
110
|
|
109
111
|
extend_method = Object.instance_method(:extend).bind(::Bones.config)
|
@@ -10,8 +10,8 @@ class Bones::AnnotationExtractor
|
|
10
10
|
# will be included in the string.
|
11
11
|
#
|
12
12
|
def to_s( opts = {} )
|
13
|
-
s = "[%3d] " % line
|
14
|
-
s << "[#{tag}] " if opts[:tag]
|
13
|
+
s = "[#{Bones::Colors.colorize('%3d', :magenta)}] " % line
|
14
|
+
s << "[#{Bones::Colors.colorize(tag, :cyan)}] " if opts[:tag]
|
15
15
|
s << text
|
16
16
|
end
|
17
17
|
}
|
@@ -74,7 +74,7 @@ class Bones::AnnotationExtractor
|
|
74
74
|
|
75
75
|
text = m[2]
|
76
76
|
if text =~ @id_rgxp
|
77
|
-
text.gsub!(@id_rgxp) {|str|
|
77
|
+
text.gsub!(@id_rgxp) {|str| Bones::Colors.colorize(str, :green)}
|
78
78
|
list << Annotation.new(lineno, m[1], text)
|
79
79
|
end
|
80
80
|
list
|
data/lib/bones/app.rb
CHANGED
@@ -17,6 +17,7 @@ module Bones::App
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Main
|
20
|
+
include Bones::Colors
|
20
21
|
attr_reader :stdout
|
21
22
|
attr_reader :stderr
|
22
23
|
|
@@ -58,11 +59,11 @@ module Bones::App
|
|
58
59
|
end
|
59
60
|
|
60
61
|
rescue Bones::App::Error => err
|
61
|
-
stderr.puts "ERROR: While executing bones ..."
|
62
|
-
stderr.puts " #{err.message}"
|
62
|
+
stderr.puts "#{colorize('ERROR', :white, :on_red)}: While executing bones ..."
|
63
|
+
stderr.puts " #{err.message.split("\n").join("\n ")}"
|
63
64
|
exit 1
|
64
65
|
rescue StandardError => err
|
65
|
-
stderr.puts "ERROR: While executing bones ... (#{err.class})"
|
66
|
+
stderr.puts "#{colorize('ERROR', :white, :on_red)}: While executing bones ... (#{colorize(err.class, :red)})"
|
66
67
|
stderr.puts " #{err.to_s}"
|
67
68
|
exit 1
|
68
69
|
end
|
data/lib/bones/app/command.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
|
2
2
|
class Bones::App::Command
|
3
|
+
include Bones::Colors
|
3
4
|
|
4
5
|
# :stopdoc:
|
5
6
|
DEFAULT_SKELETON = 'default'
|
7
|
+
Bones.config() { colorize = true }
|
6
8
|
# :startdoc:
|
7
9
|
|
8
10
|
attr_reader :stdout
|
@@ -17,7 +19,7 @@ class Bones::App::Command
|
|
17
19
|
:skeleton_dir => File.join(mrbones_dir, DEFAULT_SKELETON),
|
18
20
|
:verbose => false,
|
19
21
|
:name => nil,
|
20
|
-
:output_dir => nil
|
22
|
+
:output_dir => nil,
|
21
23
|
}
|
22
24
|
@config[:skeleton_dir] = ::Bones.path(DEFAULT_SKELETON) unless test(?d, skeleton_dir)
|
23
25
|
end
|
@@ -129,7 +131,8 @@ class Bones::App::Command
|
|
129
131
|
return opts
|
130
132
|
end
|
131
133
|
|
132
|
-
#
|
134
|
+
# Returns a hash of the standard options that can be used for individual
|
135
|
+
# commadns.
|
133
136
|
#
|
134
137
|
def self.standard_options
|
135
138
|
@standard_options ||= {
|
@@ -155,7 +158,10 @@ class Bones::App::Command
|
|
155
158
|
|
156
159
|
:repository => ['-r', '--repository URL', String,
|
157
160
|
'svn or git repository path.',
|
158
|
-
lambda { |value| config[:repository] = value }]
|
161
|
+
lambda { |value| config[:repository] = value }],
|
162
|
+
|
163
|
+
:colorize => ['-c', '--color', '--no-color', 'Colorize output',
|
164
|
+
lambda { |value| Bones.config.colorize = value }]
|
159
165
|
}
|
160
166
|
end
|
161
167
|
|
data/lib/bones/app/create.rb
CHANGED
@@ -17,7 +17,7 @@ be used as the skeleton if the '--repository' flag is given.
|
|
17
17
|
option(standard_options[:directory])
|
18
18
|
option(standard_options[:skeleton])
|
19
19
|
option(standard_options[:repository])
|
20
|
-
option(standard_options[:
|
20
|
+
option(standard_options[:colorize])
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.in_output_directory( *args )
|
@@ -56,22 +56,20 @@ be used as the skeleton if the '--repository' flag is given.
|
|
56
56
|
:destination => output_dir,
|
57
57
|
:stdout => stdout,
|
58
58
|
:stderr => stderr,
|
59
|
-
:verbose =>
|
59
|
+
:verbose => true
|
60
60
|
)
|
61
|
-
|
62
|
-
fm.copy
|
63
|
-
fm.finalize name
|
61
|
+
fm.template name
|
64
62
|
rescue Bones::App::FileManager::Error => err
|
65
63
|
FileUtils.rm_rf output_dir
|
66
64
|
msg = "Could not create '#{name}'"
|
67
65
|
msg << " in directory '#{output_dir}'" if name != output_dir
|
68
|
-
msg << "\n
|
66
|
+
msg << "\n#{err.message}"
|
69
67
|
raise Error, msg
|
70
68
|
rescue Exception => err
|
71
69
|
FileUtils.rm_rf output_dir
|
72
70
|
msg = "Could not create '#{name}'"
|
73
71
|
msg << " in directory '#{output_dir}'" if name != output_dir
|
74
|
-
msg << "\n
|
72
|
+
msg << "\n#{err.inspect}"
|
75
73
|
raise Error, msg
|
76
74
|
end
|
77
75
|
|
@@ -83,11 +81,14 @@ be used as the skeleton if the '--repository' flag is given.
|
|
83
81
|
|
84
82
|
def fixme
|
85
83
|
return unless test ?f, 'Rakefile'
|
84
|
+
|
85
|
+
stdout.puts
|
86
|
+
stdout.puts colorize('-'*31, :yellow)
|
86
87
|
stdout.puts 'Now you need to fix these files'
|
88
|
+
stdout.puts colorize('-'*31, :yellow)
|
87
89
|
system "#{::Bones::RUBY} -S rake notes"
|
88
90
|
end
|
89
91
|
|
90
92
|
end # class Create
|
91
93
|
end # module Bones::App
|
92
94
|
|
93
|
-
# EOF
|
@@ -3,6 +3,7 @@ require 'erb'
|
|
3
3
|
|
4
4
|
module Bones::App
|
5
5
|
class FileManager
|
6
|
+
include Bones::Colors
|
6
7
|
|
7
8
|
Error = Class.new(StandardError)
|
8
9
|
|
@@ -45,7 +46,7 @@ class FileManager
|
|
45
46
|
def archive_destination
|
46
47
|
return false unless test(?e, destination)
|
47
48
|
|
48
|
-
|
49
|
+
archiving(destination)
|
49
50
|
FileUtils.rm_rf(archive)
|
50
51
|
FileUtils.mv(destination, archive)
|
51
52
|
true
|
@@ -59,17 +60,26 @@ class FileManager
|
|
59
60
|
else
|
60
61
|
_files_to_copy.each {|fn| _cp(fn)}
|
61
62
|
end
|
63
|
+
self
|
62
64
|
end
|
63
65
|
|
66
|
+
# Gernate a new destination folder by copying files from the source, rename
|
67
|
+
# files and directories that contain "NAME", and perform ERB templating on
|
68
|
+
# ".bns" files. The _name_ use used for file/folder renaming and ERB
|
69
|
+
# templating.
|
64
70
|
#
|
65
|
-
|
66
|
-
def finalize( name )
|
71
|
+
def template( name )
|
67
72
|
name = name.to_s
|
68
73
|
return if name.empty?
|
69
74
|
|
75
|
+
if repository?
|
76
|
+
_checkout(repository)
|
77
|
+
else
|
78
|
+
_files_to_copy.each {|fn| _cp(fn, false)}
|
79
|
+
end
|
80
|
+
|
70
81
|
self.destination = _rename(destination, name)
|
71
82
|
_erb(name)
|
72
|
-
|
73
83
|
self
|
74
84
|
end
|
75
85
|
|
@@ -108,10 +118,16 @@ class FileManager
|
|
108
118
|
def _erb( name )
|
109
119
|
binding = _erb_binding(name)
|
110
120
|
Dir.glob(File.join(destination, '**', '*'), File::FNM_DOTMATCH).each do |fn|
|
111
|
-
next unless test(?f, fn)
|
121
|
+
next unless test(?f, fn)
|
122
|
+
if File.extname(fn) != '.bns'
|
123
|
+
creating(fn)
|
124
|
+
next
|
125
|
+
end
|
112
126
|
|
113
|
-
txt = ERB.new(File.read(fn), nil, '-').result(binding)
|
114
127
|
new_fn = fn.sub(%r/\.bns$/, '')
|
128
|
+
creating(new_fn)
|
129
|
+
|
130
|
+
txt = ERB.new(File.read(fn), nil, '-').result(binding)
|
115
131
|
File.open(new_fn, 'w') {|fd| fd.write(txt)}
|
116
132
|
FileUtils.chmod(File.stat(fn).mode, new_fn)
|
117
133
|
FileUtils.rm_f(fn)
|
@@ -156,19 +172,37 @@ class FileManager
|
|
156
172
|
# specified project location. A message will be displayed to the screen
|
157
173
|
# indicating that the file is being created.
|
158
174
|
#
|
159
|
-
def _cp( file )
|
175
|
+
def _cp( file, msg = true )
|
160
176
|
dir = File.dirname(file)
|
161
177
|
dir = (dir == '.' ? destination : File.join(destination, dir))
|
162
178
|
dst = File.join(dir, File.basename(file))
|
163
179
|
src = File.join(source, file)
|
164
180
|
|
165
|
-
|
181
|
+
(test(?e, dst) ? updating(dst) : creating(dst)) if msg
|
182
|
+
|
166
183
|
FileUtils.mkdir_p(dir)
|
167
184
|
FileUtils.cp src, dst
|
168
185
|
|
169
186
|
FileUtils.chmod(File.stat(src).mode, dst)
|
170
187
|
end
|
171
188
|
|
189
|
+
private
|
190
|
+
|
191
|
+
def archiving( filename )
|
192
|
+
return unless verbose?
|
193
|
+
@put.puts " #{colorize('archiving', :cyan)} #{filename}"
|
194
|
+
end
|
195
|
+
|
196
|
+
def creating( filename )
|
197
|
+
return unless verbose?
|
198
|
+
@out.puts " #{colorize('creating', :green)} #{filename}"
|
199
|
+
end
|
200
|
+
|
201
|
+
def updating( filename )
|
202
|
+
return unless verbose?
|
203
|
+
@out.puts " #{colorize('updating', :yellow)} #{filename}"
|
204
|
+
end
|
205
|
+
|
172
206
|
end # class FileManager
|
173
207
|
end # module Bones::App
|
174
208
|
|
data/lib/bones/app/freeze.rb
CHANGED
data/lib/bones/app/info.rb
CHANGED
@@ -14,9 +14,9 @@ class Info < Command
|
|
14
14
|
|
15
15
|
msg = "\n"
|
16
16
|
msg << "The default project skeleton will be copied from:\n"
|
17
|
-
msg << " " << skeleton_dir << "\n\n"
|
17
|
+
msg << " " << colorize(skeleton_dir, :cyan) << "\n\n"
|
18
18
|
|
19
|
-
fmt = " %-12s => %s\n"
|
19
|
+
fmt = " #{colorize('%-12s', :green)} #{colorize('=>', :yellow)} #{colorize('%s', :cyan)}\n"
|
20
20
|
msg << "Available projects skeletons are:\n"
|
21
21
|
Dir.glob(File.join(mrbones_dir, '*')).sort.each do |fn|
|
22
22
|
next if fn =~ %r/\.archive$/
|
@@ -25,7 +25,7 @@ class Info < Command
|
|
25
25
|
if test(?f, fn)
|
26
26
|
msg << fmt % [File.basename(fn), File.read(fn).strip]
|
27
27
|
else
|
28
|
-
msg << " " << File.basename(fn) << "\n"
|
28
|
+
msg << " " << colorize(File.basename(fn), :green) << "\n"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/lib/bones/app/plugins.rb
CHANGED
@@ -14,6 +14,7 @@ gems are not installed.
|
|
14
14
|
__
|
15
15
|
|
16
16
|
option('-a', '--all', 'Show all plugins.', lambda { config[:all] = true })
|
17
|
+
option(standard_options[:colorize])
|
17
18
|
end
|
18
19
|
|
19
20
|
def run
|
@@ -46,7 +47,7 @@ gems are not installed.
|
|
46
47
|
name = "bones-#{name}"
|
47
48
|
name << "-#{version}" if version
|
48
49
|
|
49
|
-
stdout.puts(" [%s] %s" % [installed?(name) ? 'installed' : 'available', name])
|
50
|
+
stdout.puts(" [%s] %s" % [installed?(name) ? colorize('installed', :green) : colorize('available', :cyan), name])
|
50
51
|
end
|
51
52
|
|
52
53
|
private
|
data/lib/bones/app/unfreeze.rb
CHANGED
data/lib/bones/colors.rb
CHANGED
@@ -2,53 +2,67 @@
|
|
2
2
|
module Bones::Colors
|
3
3
|
extend self
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
|
19
|
-
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:on_green => 42,
|
29
|
-
:on_yellow => 43,
|
30
|
-
:on_blue => 44,
|
31
|
-
:on_magenta => 45,
|
32
|
-
:on_cyan => 46,
|
33
|
-
:on_white => 47
|
34
|
-
}
|
5
|
+
COLORS = {
|
6
|
+
# Embed in a String to clear all previous ANSI sequences. This *MUST* be
|
7
|
+
# done before the program exits!
|
8
|
+
#
|
9
|
+
:clear => "\e[0m",
|
10
|
+
:erase_line => "\e[K",
|
11
|
+
:erase_char => "\e[P",
|
12
|
+
:bold => "\e[1m",
|
13
|
+
:dark => "\e[2m",
|
14
|
+
:underline => "\e[4m",
|
15
|
+
:blink => "\e[5m",
|
16
|
+
:reverse => "\e[7m",
|
17
|
+
:concealed => "\e[8m",
|
18
|
+
|
19
|
+
# Terminal's foreground ANSI colors
|
20
|
+
:black => "\e[30m",
|
21
|
+
:red => "\e[31m",
|
22
|
+
:green => "\e[32m",
|
23
|
+
:yellow => "\e[33m",
|
24
|
+
:blue => "\e[34m",
|
25
|
+
:magenta => "\e[35m",
|
26
|
+
:cyan => "\e[36m",
|
27
|
+
:white => "\e[37m",
|
35
28
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
# Terminal's background ANSI colors
|
30
|
+
:on_black => "\e[40m",
|
31
|
+
:on_red => "\e[41m",
|
32
|
+
:on_green => "\e[42m",
|
33
|
+
:on_yellow => "\e[43m",
|
34
|
+
:on_blue => "\e[44m",
|
35
|
+
:on_magenta => "\e[45m",
|
36
|
+
:on_cyan => "\e[46m",
|
37
|
+
:on_white => "\e[47m"
|
42
38
|
}
|
39
|
+
COLORS[:reset] = COLORS[:clear]
|
40
|
+
COLORS[:underscore] = COLORS[:underline]
|
41
|
+
|
42
|
+
# This method provides easy access to ANSI color sequences, without the user
|
43
|
+
# needing to remember to CLEAR at the end of each sequence. Just pass the
|
44
|
+
# _string_ to color, followed by a list of _colors_ you would like it to
|
45
|
+
# be affected by. The _colors_ can be class constants, or symbols (:blue
|
46
|
+
# for BLUE, for example). A CLEAR will automatically be embedded to the
|
47
|
+
# end of the returned String.
|
48
|
+
#
|
49
|
+
# This method returns the original _string_ unchanged if colorize? is
|
50
|
+
# +false+.
|
51
|
+
#
|
52
|
+
def colorize( string, *colors )
|
53
|
+
return string unless colorize?
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
code = COLOR_CODES[name]
|
47
|
-
next if code.nil?
|
48
|
-
str = "\e[#{code}m#{str}\e[0m"
|
55
|
+
colors.map! { |c|
|
56
|
+
c.is_a?(Symbol) ? COLORS[c] : c
|
49
57
|
}
|
50
|
-
|
58
|
+
"#{colors.flatten.join}#{string}#{COLORS[:clear]}"
|
51
59
|
end
|
60
|
+
|
61
|
+
# Returns true if Bones is currently using color escapes.
|
62
|
+
#
|
63
|
+
def colorize?
|
64
|
+
Bones.config.colorize
|
65
|
+
end
|
66
|
+
|
52
67
|
end # module Bones::Colors
|
53
68
|
|
54
|
-
# EOF
|
data/lib/bones/plugins/gem.rb
CHANGED
@@ -5,6 +5,8 @@ module Bones::Plugins::Gem
|
|
5
5
|
include ::Bones::Helpers
|
6
6
|
extend self
|
7
7
|
|
8
|
+
GemspecError = Class.new(StandardError)
|
9
|
+
|
8
10
|
module Syntax
|
9
11
|
# Adds the given gem _name_ to the current project's dependency list. An
|
10
12
|
# optional gem _version_ can be given. If omitted, the newest gem version
|
@@ -26,10 +28,21 @@ module Bones::Plugins::Gem
|
|
26
28
|
development ?
|
27
29
|
::Bones.config.gem.development_dependencies << dep :
|
28
30
|
::Bones.config.gem.dependencies << dep
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Add the given _url_ to the list of gem sources.
|
35
|
+
#
|
36
|
+
def source( url )
|
37
|
+
sources = ::Bones.config.gem.sources
|
38
|
+
sources << url unless sources.include? url
|
39
|
+
nil
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
32
43
|
def initialize_gem
|
44
|
+
Gem.configuration
|
45
|
+
|
33
46
|
::Bones.config {
|
34
47
|
desc 'Configuration settings for gem packaging.'
|
35
48
|
gem {
|
@@ -89,6 +102,14 @@ module Bones::Plugins::Gem
|
|
89
102
|
provided for by Mr Bones. You will need to refer to the rubygems
|
90
103
|
documentation for a complete list of specification settings.
|
91
104
|
__
|
105
|
+
|
106
|
+
sources Gem.sources.dup, :desc => <<-__
|
107
|
+
An array of sources to fetch remote gems from. A convenience method
|
108
|
+
is provided to add new gem sources to this list.
|
109
|
+
|
110
|
+
| source 'http://gems.example.com'
|
111
|
+
| source 'http://rubygems.org'
|
112
|
+
__
|
92
113
|
}
|
93
114
|
}
|
94
115
|
|
@@ -98,79 +119,85 @@ module Bones::Plugins::Gem
|
|
98
119
|
def post_load
|
99
120
|
config = ::Bones.config
|
100
121
|
|
101
|
-
config.gem.
|
102
|
-
|
103
|
-
|
122
|
+
Gem.sources = config.gem.sources
|
123
|
+
|
124
|
+
unless $bones_external_spec
|
125
|
+
config.gem.files ||= manifest
|
126
|
+
config.gem.executables ||= config.gem.files.find_all {|fn| fn =~ %r/^bin/}
|
127
|
+
config.gem.development_dependencies << ['bones', ">= #{Bones.version}"]
|
128
|
+
end
|
104
129
|
end
|
105
130
|
|
106
131
|
def define_tasks
|
107
132
|
config = ::Bones.config
|
108
133
|
|
109
134
|
namespace :gem do
|
110
|
-
config.gem._spec
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
135
|
+
if config.gem._spec.nil?
|
136
|
+
config.gem._spec = Gem::Specification.new do |s|
|
137
|
+
s.name = config.name
|
138
|
+
s.version = config.version
|
139
|
+
s.summary = config.summary
|
140
|
+
s.authors = Array(config.authors)
|
141
|
+
s.email = config.email
|
142
|
+
s.homepage = Array(config.url).first
|
143
|
+
s.rubyforge_project = config.name
|
144
|
+
|
145
|
+
if !config.rubyforge.nil? and config.rubyforge.name
|
146
|
+
s.rubyforge_project = config.rubyforge.name
|
147
|
+
end
|
122
148
|
|
123
|
-
|
149
|
+
s.description = config.description
|
124
150
|
|
125
|
-
|
126
|
-
|
127
|
-
|
151
|
+
config.gem.dependencies.each do |dep|
|
152
|
+
s.add_dependency(*dep)
|
153
|
+
end
|
128
154
|
|
129
|
-
|
130
|
-
|
131
|
-
|
155
|
+
config.gem.development_dependencies.each do |dep|
|
156
|
+
s.add_development_dependency(*dep)
|
157
|
+
end
|
132
158
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
159
|
+
s.files = config.gem.files
|
160
|
+
s.executables = config.gem.executables.map {|fn| File.basename(fn)}
|
161
|
+
s.extensions = config.gem.files.grep %r/extconf\.rb$/
|
162
|
+
|
163
|
+
s.bindir = 'bin'
|
164
|
+
dirs = Dir["{#{config.libs.join(',')}}"]
|
165
|
+
s.require_paths = dirs unless dirs.empty?
|
166
|
+
|
167
|
+
if have? :rdoc
|
168
|
+
incl = Regexp.new(config.rdoc.include.join('|'))
|
169
|
+
excl = config.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
|
170
|
+
excl = Regexp.new(excl.join('|'))
|
171
|
+
rdoc_files = config.gem.files.find_all do |fn|
|
172
|
+
case fn
|
173
|
+
when excl; false
|
174
|
+
when incl; true
|
175
|
+
else false end
|
176
|
+
end
|
177
|
+
s.rdoc_options = config.rdoc.opts + ['--main', config.rdoc.main]
|
178
|
+
s.extra_rdoc_files = rdoc_files
|
179
|
+
s.has_rdoc = true
|
180
|
+
end
|
155
181
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
182
|
+
if config.test
|
183
|
+
if test ?f, config.test.file
|
184
|
+
s.test_file = config.test.file
|
185
|
+
else
|
186
|
+
s.test_files = config.test.files.to_a
|
187
|
+
end
|
161
188
|
end
|
162
|
-
end
|
163
189
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
190
|
+
# Do any extra stuff the user wants
|
191
|
+
config.gem.extras.each do |msg, val|
|
192
|
+
case val
|
193
|
+
when Proc
|
194
|
+
val.call(s.send(msg))
|
195
|
+
else
|
196
|
+
s.send "#{msg}=", val
|
197
|
+
end
|
171
198
|
end
|
172
|
-
end
|
173
|
-
end #
|
199
|
+
end # Gem::Specification.new
|
200
|
+
end # if gem._spec.nil?
|
174
201
|
|
175
202
|
::Bones::GemPackageTask.new(config.gem._spec) do |pkg|
|
176
203
|
pkg.need_tar = config.gem.need_tar
|
@@ -192,10 +219,13 @@ module Bones::Plugins::Gem
|
|
192
219
|
puts config.gem._spec.to_ruby
|
193
220
|
end
|
194
221
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
222
|
+
# don't use the "spec" task if we have an external gemspec
|
223
|
+
unless $bones_external_spec
|
224
|
+
desc 'Write the gemspec'
|
225
|
+
task :spec => 'gem:prereqs' do
|
226
|
+
File.open("#{config.name}.gemspec", 'w') do |f|
|
227
|
+
f.write config.gem._spec.to_ruby
|
228
|
+
end
|
199
229
|
end
|
200
230
|
end
|
201
231
|
|
@@ -288,6 +318,78 @@ module Bones::Plugins::Gem
|
|
288
318
|
files.sort!
|
289
319
|
end
|
290
320
|
|
321
|
+
# Import configuration from the given gemspec file.
|
322
|
+
#
|
323
|
+
def import_gemspec( filename )
|
324
|
+
$bones_external_spec = false
|
325
|
+
spec = load_gemspec(filename)
|
326
|
+
return if spec.nil?
|
327
|
+
|
328
|
+
config = ::Bones.config
|
329
|
+
config.gem._spec = spec
|
330
|
+
$bones_external_spec = true
|
331
|
+
|
332
|
+
config.name = spec.name
|
333
|
+
config.version = spec.version
|
334
|
+
config.summary = spec.summary
|
335
|
+
config.authors = spec.authors
|
336
|
+
config.email = spec.email
|
337
|
+
config.url = spec.homepage
|
338
|
+
config.description = spec.description
|
339
|
+
config.files = spec.files
|
340
|
+
config.libs = spec.require_paths
|
341
|
+
config.rubyforge_project = spec.rubyforge_project
|
342
|
+
|
343
|
+
config.gem.executables = spec.executables
|
344
|
+
config.rdoc.opts = spec.rdoc_options
|
345
|
+
config.test.file = spec.test_file if spec.test_file
|
346
|
+
config.test.files = spec.test_files if spec.test_files
|
347
|
+
|
348
|
+
spec.runtime_dependencies.each do |dep|
|
349
|
+
config.gem.dependencies << [dep.name, dep.requirements_list].flatten
|
350
|
+
end
|
351
|
+
|
352
|
+
spec.development_dependencies.each do |dep|
|
353
|
+
config.gem.development_dependencies << [dep.name, dep.requirements_list].flatten
|
354
|
+
end
|
355
|
+
|
356
|
+
[:signing_key, :cert_chain, :post_install_message, :licenses].each { |key|
|
357
|
+
value = spec.send(key)
|
358
|
+
next if value.nil? or value.empty?
|
359
|
+
config.gem.extras[key] = value
|
360
|
+
}
|
361
|
+
|
362
|
+
nil
|
363
|
+
end
|
364
|
+
|
365
|
+
# This method is stolen from the Bundler gem. It loads the gemspec from a
|
366
|
+
# file if available.
|
367
|
+
#
|
368
|
+
def load_gemspec( filename )
|
369
|
+
path = Pathname.new(filename)
|
370
|
+
# Eval the gemspec from its parent directory
|
371
|
+
Dir.chdir(path.dirname) do
|
372
|
+
begin
|
373
|
+
Gem::Specification.from_yaml(path.basename)
|
374
|
+
# Raises ArgumentError if the file is not valid YAML
|
375
|
+
rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception
|
376
|
+
begin
|
377
|
+
eval(File.read(path.basename), TOPLEVEL_BINDING, path.expand_path.to_s)
|
378
|
+
rescue LoadError => e
|
379
|
+
original_line = e.backtrace.find { |line| line.include?(path.to_s) }
|
380
|
+
msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}"
|
381
|
+
msg << " from\n #{original_line}" if original_line
|
382
|
+
msg << "\n"
|
383
|
+
|
384
|
+
if RUBY_VERSION >= "1.9.0"
|
385
|
+
msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9."
|
386
|
+
end
|
387
|
+
|
388
|
+
raise GemspecError, msg
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
291
394
|
end # Bones::Plugins::Gem
|
292
395
|
|
293
|
-
# EOF
|
data/lib/bones/plugins/rdoc.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
# since RDoc v 2.4.2 has RDoc::Task to replace Rake::RDoctask
|
3
|
+
begin
|
4
|
+
gem 'rdoc'
|
5
|
+
require 'rdoc/task'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
end
|
3
9
|
|
4
10
|
module Bones::Plugins::Rdoc
|
5
11
|
include ::Bones::Helpers
|
@@ -18,7 +24,7 @@ module Bones::Plugins::Rdoc
|
|
18
24
|
will be converted in regular expressions.
|
19
25
|
__
|
20
26
|
|
21
|
-
exclude %w(extconf\.rb$), :desc => <<-__
|
27
|
+
exclude %w(extconf\.rb$ ^version.txt), :desc => <<-__
|
22
28
|
An array of patterns that will be used to exclude files from rdoc
|
23
29
|
processing. This is an array of strings that will be converted in
|
24
30
|
regular expressions.
|
@@ -43,31 +49,44 @@ module Bones::Plugins::Rdoc
|
|
43
49
|
config.rdoc.main ||= config.readme_file
|
44
50
|
end
|
45
51
|
|
52
|
+
def rdoc_config(rd, config)
|
53
|
+
rdoc = config.rdoc
|
54
|
+
incl = Regexp.new(rdoc.include.join('|'))
|
55
|
+
excl = Regexp.new(rdoc.exclude.join('|'))
|
56
|
+
files = config.gem.files.find_all do |fn|
|
57
|
+
case fn
|
58
|
+
when excl; false
|
59
|
+
when incl; true
|
60
|
+
else false end
|
61
|
+
end
|
62
|
+
title = "#{config.name}-#{config.version} Documentation"
|
63
|
+
rd.main = rdoc.main
|
64
|
+
rd.rdoc_dir = rdoc.dir
|
65
|
+
|
66
|
+
rd.rdoc_files.push(*files)
|
67
|
+
|
68
|
+
if rd.class == RDoc::Task
|
69
|
+
rd.title = title
|
70
|
+
else
|
71
|
+
rd.options << "-t #{title}"
|
72
|
+
end
|
73
|
+
|
74
|
+
rd.options.concat(rdoc.opts)
|
75
|
+
end
|
76
|
+
|
46
77
|
def define_tasks
|
47
78
|
config = ::Bones.config
|
48
79
|
|
49
80
|
namespace :doc do
|
50
81
|
desc 'Generate RDoc documentation'
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rd
|
55
|
-
|
56
|
-
|
57
|
-
excl = Regexp.new(rdoc.exclude.join('|'))
|
58
|
-
files = config.gem.files.find_all do |fn|
|
59
|
-
case fn
|
60
|
-
when excl; false
|
61
|
-
when incl; true
|
62
|
-
else false end
|
63
|
-
end
|
64
|
-
rd.rdoc_files.push(*files)
|
65
|
-
|
66
|
-
title = "#{config.name}-#{config.version} Documentation"
|
67
|
-
|
68
|
-
rd.options << "-t #{title}"
|
69
|
-
rd.options.concat(rdoc.opts)
|
82
|
+
|
83
|
+
# rdoc-2.4.2
|
84
|
+
begin
|
85
|
+
rd = RDoc::Task.new
|
86
|
+
rescue NameError
|
87
|
+
rd = Rake::RDoctask.new
|
70
88
|
end
|
89
|
+
rdoc_config(rd,config)
|
71
90
|
|
72
91
|
desc 'Generate ri locally for testing'
|
73
92
|
task :ri => :clobber_ri do
|
@@ -92,4 +111,3 @@ module Bones::Plugins::Rdoc
|
|
92
111
|
|
93
112
|
end # module Bones::Plugins::Rdoc
|
94
113
|
|
95
|
-
# EOF
|
@@ -87,8 +87,7 @@ describe Bones::App::FileManager do
|
|
87
87
|
it "should perform ERb templating on '.bns' files" do
|
88
88
|
@fm.source = Bones.path(%w[spec data default])
|
89
89
|
@fm.destination = Bones.path(%w[spec data bar])
|
90
|
-
@fm.
|
91
|
-
@fm.finalize('foo_bar')
|
90
|
+
@fm.template('foo_bar')
|
92
91
|
|
93
92
|
dir = @fm.destination
|
94
93
|
test(?e, File.join(dir, 'Rakefile.bns')).should == false
|
@@ -114,8 +113,7 @@ end
|
|
114
113
|
it "preserves the executable status of .bns files" do
|
115
114
|
@fm.source = Bones.path(%w[spec data default])
|
116
115
|
@fm.destination = Bones.path(%w[spec data bar])
|
117
|
-
@fm.
|
118
|
-
@fm.finalize('foo_bar')
|
116
|
+
@fm.template('foo_bar')
|
119
117
|
|
120
118
|
dir = @fm.destination
|
121
119
|
test(?e, File.join(dir, 'bin/foo_bar')).should == true
|
data/spec/bones/app_spec.rb
CHANGED
@@ -74,7 +74,7 @@ describe Bones::App do
|
|
74
74
|
|
75
75
|
it 'should report an error for unrecognized commands' do
|
76
76
|
lambda {@app.run %w[foo]}.should raise_error(SystemExit)
|
77
|
-
@err.readline.should ==
|
77
|
+
@err.readline.should == "\e[37m\e[41mERROR\e[0m: While executing bones ..."
|
78
78
|
@err.readline.should == ' Unknown command "foo"'
|
79
79
|
end
|
80
80
|
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.6.0
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bones
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 3.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 3.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Pease
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-22 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -114,9 +114,9 @@ extra_rdoc_files:
|
|
114
114
|
- README.rdoc
|
115
115
|
- bin/bones
|
116
116
|
- default/version.txt
|
117
|
+
- gem-development.txt
|
117
118
|
- spec/data/markdown.txt
|
118
119
|
- spec/data/rdoc.txt
|
119
|
-
- version.txt
|
120
120
|
files:
|
121
121
|
- .autotest
|
122
122
|
- History.txt
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- default/spec/spec_helper.rb.bns
|
134
134
|
- default/test/test_NAME.rb
|
135
135
|
- default/version.txt
|
136
|
+
- gem-development.txt
|
136
137
|
- lib/bones.rb
|
137
138
|
- lib/bones/annotation_extractor.rb
|
138
139
|
- lib/bones/app.rb
|