bones 2.5.1 → 3.0.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 +2 -0
- data/README.rdoc +54 -306
- data/Rakefile +28 -37
- data/bin/bones +10 -3
- data/{spec/data/data → default}/.bnsignore +3 -1
- data/{data → default}/History.txt.bns +0 -0
- data/{data → default}/README.txt.bns +0 -0
- data/default/Rakefile.bns +21 -0
- data/{data → default}/bin/NAME.bns +0 -0
- data/{data → default}/lib/NAME.rb.bns +0 -0
- data/{data → default}/spec/NAME_spec.rb.bns +0 -0
- data/{data → default}/spec/spec_helper.rb.bns +0 -0
- data/{data → default}/test/test_NAME.rb +0 -0
- data/lib/bones.rb +73 -31
- data/lib/bones/annotation_extractor.rb +16 -26
- data/lib/bones/app.rb +87 -58
- data/lib/bones/app/command.rb +143 -64
- data/lib/bones/app/create.rb +93 -0
- data/lib/bones/app/file_manager.rb +7 -8
- data/lib/bones/app/freeze.rb +59 -0
- data/lib/bones/app/info.rb +39 -0
- data/lib/bones/app/unfreeze.rb +44 -0
- data/lib/bones/colors.rb +54 -0
- data/lib/bones/gem_package_task.rb +71 -0
- data/lib/bones/helpers.rb +93 -0
- data/lib/bones/plugins/ann.rb +166 -0
- data/lib/bones/plugins/bones_plugin.rb +193 -0
- data/lib/bones/plugins/gem.rb +274 -0
- data/lib/bones/plugins/notes.rb +45 -0
- data/lib/bones/plugins/rdoc.rb +93 -0
- data/lib/bones/plugins/test.rb +57 -0
- data/lib/bones/smtp_tls.rb +1 -0
- data/spec/bones/app/file_manager_spec.rb +6 -6
- data/spec/bones/app_spec.rb +14 -18
- data/spec/bones_spec.rb +9 -4
- data/{data → spec/data/default}/.bnsignore +0 -0
- data/spec/data/{data → default}/History +0 -0
- data/spec/data/{data → default}/NAME/NAME.rb.bns +0 -0
- data/spec/data/{data → default}/README.txt.bns +0 -0
- data/{data → spec/data/default}/Rakefile.bns +0 -0
- data/spec/data/{data → default}/lib/NAME.rb.bns +0 -0
- metadata +94 -68
- data/lib/bones/app/create_command.rb +0 -86
- data/lib/bones/app/freeze_command.rb +0 -73
- data/lib/bones/app/info_command.rb +0 -58
- data/lib/bones/app/unfreeze_command.rb +0 -53
- data/lib/bones/app/update_command.rb +0 -47
- data/lib/bones/debug.rb +0 -72
- data/lib/bones/tasks/ann.rake +0 -80
- data/lib/bones/tasks/bones.rake +0 -20
- data/lib/bones/tasks/gem.rake +0 -201
- data/lib/bones/tasks/git.rake +0 -40
- data/lib/bones/tasks/notes.rake +0 -27
- data/lib/bones/tasks/post_load.rake +0 -34
- data/lib/bones/tasks/rdoc.rake +0 -51
- data/lib/bones/tasks/rubyforge.rake +0 -55
- data/lib/bones/tasks/setup.rb +0 -292
- data/lib/bones/tasks/spec.rake +0 -54
- data/lib/bones/tasks/svn.rake +0 -47
- data/lib/bones/tasks/test.rake +0 -40
- data/lib/bones/tasks/zentest.rake +0 -36
- data/spec/data/data/Rakefile.bns +0 -30
- data/tasks/ann.rake +0 -80
- data/tasks/bones.rake +0 -20
- data/tasks/gem.rake +0 -201
- data/tasks/git.rake +0 -40
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -51
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -292
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/zentest.rake +0 -36
data/bin/bones
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
4
|
+
|
5
|
+
begin
|
6
|
+
require File.join(root, %w[lib bones])
|
7
|
+
rescue LoadError
|
8
|
+
require 'bones'
|
9
|
+
end
|
10
|
+
|
11
|
+
Bones::App.initialize_plugins
|
12
|
+
Bones::App.run
|
6
13
|
|
7
14
|
# EOF
|
@@ -4,7 +4,9 @@
|
|
4
4
|
# A .gitignore file can be used instead by setting it as the ignore
|
5
5
|
# file in your Rakefile:
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# Bones {
|
8
|
+
# ignore_file '.gitignore'
|
9
|
+
# }
|
8
10
|
#
|
9
11
|
# For a project with a C extension, the following would be a good set of
|
10
12
|
# exclude patterns (uncomment them if you want to use them):
|
File without changes
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'bones'
|
4
|
+
rescue LoadError
|
5
|
+
abort '### Please install the "bones" gem ###'
|
6
|
+
end
|
7
|
+
|
8
|
+
ensure_in_path 'lib'
|
9
|
+
require '<%= name %>'
|
10
|
+
|
11
|
+
task :default => 'test:run'
|
12
|
+
|
13
|
+
Bones {
|
14
|
+
name '<%= name %>'
|
15
|
+
authors 'FIXME (who is writing this software)'
|
16
|
+
email 'FIXME (your e-mail)'
|
17
|
+
url 'FIXME (project homepage)'
|
18
|
+
version <%= classname %>::VERSION
|
19
|
+
}
|
20
|
+
|
21
|
+
# EOF
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/bones.rb
CHANGED
@@ -1,68 +1,110 @@
|
|
1
1
|
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'find'
|
2
7
|
require 'rbconfig'
|
8
|
+
require 'little-plugger'
|
9
|
+
require 'loquacious'
|
10
|
+
require 'git'
|
3
11
|
|
4
12
|
module Bones
|
13
|
+
extend LittlePlugger
|
5
14
|
|
6
15
|
# :stopdoc:
|
7
|
-
VERSION = '
|
16
|
+
VERSION = '3.0.0'
|
8
17
|
PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
18
|
+
LIBPATH = File.expand_path(File.join(PATH, 'lib'))
|
9
19
|
HOME = File.expand_path(ENV['HOME'] || ENV['USERPROFILE'])
|
10
|
-
DEV_NULL = File.exist?('/dev/null') ? '/dev/null' : 'NUL:'
|
11
20
|
|
12
21
|
# Ruby Interpreter location - taken from Rake source code
|
13
22
|
RUBY = File.join(Config::CONFIG['bindir'],
|
14
23
|
Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
|
24
|
+
|
25
|
+
module Plugins; end
|
15
26
|
# :startdoc:
|
16
27
|
|
17
28
|
# Returns the path for Mr Bones. If any arguments are given,
|
18
|
-
# they will be joined to the end of the path using
|
19
|
-
# <tt>File.join</tt>.
|
29
|
+
# they will be joined to the end of the path using <tt>File.join</tt>.
|
20
30
|
#
|
21
31
|
def self.path( *args )
|
22
32
|
args.empty? ? PATH : File.join(PATH, args.flatten)
|
23
33
|
end
|
24
34
|
|
35
|
+
# Returns the lib path for Mr Bones. If any arguments are given,
|
36
|
+
# they will be joined to the end of the path using <tt>File.join</tt>.
|
37
|
+
#
|
38
|
+
def self.libpath( *args )
|
39
|
+
args.empty? ? LIBPATH : File.join(LIBPATH, args.flatten)
|
40
|
+
end
|
41
|
+
|
25
42
|
# call-seq:
|
26
|
-
# Bones.
|
43
|
+
# Bones.config
|
44
|
+
# Bones.config { block }
|
27
45
|
#
|
28
|
-
#
|
29
|
-
# directory below this file that has the same name as the filename passed
|
30
|
-
# in. Optionally, a specific _directory_ name can be passed in such that
|
31
|
-
# the _filename_ does not have to be equivalent to the directory.
|
46
|
+
# Returns the configuration object for setting up Mr Bones options.
|
32
47
|
#
|
33
|
-
def self.
|
34
|
-
|
35
|
-
|
36
|
-
File.join(File.dirname(fname), dir, '*.rb'))
|
48
|
+
def self.config( &block )
|
49
|
+
Loquacious.configuration_for('Bones', &block)
|
50
|
+
end
|
37
51
|
|
38
|
-
|
52
|
+
# call-seq:
|
53
|
+
# Bones.help
|
54
|
+
#
|
55
|
+
# Returns a help object that can be used to show the current Mr Bones
|
56
|
+
# configuration and descriptions for the various configuration attributes.
|
57
|
+
#
|
58
|
+
def self.help
|
59
|
+
Loquacious.help_for('Bones', :colorize => config.colorize, :nesting_nodes => false)
|
39
60
|
end
|
61
|
+
end # module Bones
|
62
|
+
|
63
|
+
begin
|
64
|
+
$LOAD_PATH.unshift Bones.libpath
|
65
|
+
%w[colors helpers gem_package_task annotation_extractor smtp_tls app app/command app/file_manager].
|
66
|
+
each { |fn| require File.join('bones', fn) }
|
40
67
|
|
68
|
+
Bones.config {}
|
69
|
+
Loquacious.remove :gem, :file, :test
|
70
|
+
ensure
|
71
|
+
$LOAD_PATH.shift
|
72
|
+
end
|
73
|
+
|
74
|
+
module Kernel
|
41
75
|
# call-seq:
|
42
|
-
# Bones
|
76
|
+
# Bones { block }
|
43
77
|
#
|
78
|
+
# Configure Mr Bones using the given _block_ of code. If a block is not
|
79
|
+
# given, the Bones module is returned.
|
44
80
|
#
|
45
|
-
def
|
46
|
-
local_setup = File.join(Dir.pwd, %w[tasks setup.rb])
|
81
|
+
def Bones( &block )
|
47
82
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
83
|
+
# we absolutely have to have the bones plugin
|
84
|
+
plugin_names = ::Bones.plugin_names
|
85
|
+
::Bones.plugin :bones_plugin unless plugin_names.empty? or plugin_names.include? :bones_plugin
|
52
86
|
|
53
|
-
|
54
|
-
|
87
|
+
plugins = ::Bones.initialize_plugins.values
|
88
|
+
return ::Bones unless block
|
55
89
|
|
56
|
-
|
57
|
-
|
58
|
-
|
90
|
+
config = ::Bones.config
|
91
|
+
extend_method = Object.new.method(:extend).unbind.bind(config)
|
92
|
+
instance_eval_method = Object.new.method(:instance_eval).unbind.bind(config)
|
59
93
|
|
60
|
-
|
61
|
-
|
62
|
-
|
94
|
+
plugins.each { |plugin|
|
95
|
+
ps = plugin.const_get :Syntax rescue next
|
96
|
+
extend_method.call ps
|
97
|
+
}
|
98
|
+
instance_eval_method.call(&block)
|
63
99
|
|
64
|
-
|
100
|
+
# config.exclude << "^#{Regexp.escape(config.rcov.dir)}/"
|
65
101
|
|
66
|
-
|
102
|
+
plugins.each { |plugin| plugin.post_load if plugin.respond_to? :post_load }
|
103
|
+
plugins.each { |plugin| plugin.define_tasks if plugin.respond_to? :define_tasks }
|
104
|
+
|
105
|
+
rakefiles = Dir.glob(File.join(Dir.pwd, %w[tasks *.rake])).sort
|
106
|
+
rakefiles.each {|fn| Rake.application.add_import(fn)}
|
107
|
+
end
|
108
|
+
end
|
67
109
|
|
68
110
|
# EOF
|
@@ -1,19 +1,10 @@
|
|
1
1
|
|
2
|
-
begin
|
3
|
-
require 'facets/ansicode'
|
4
|
-
HAVE_COLOR = true
|
5
|
-
rescue LoadError
|
6
|
-
HAVE_COLOR = false
|
7
|
-
end
|
8
|
-
|
9
|
-
module Bones
|
10
|
-
|
11
2
|
# A helper class used to find and display any annotations in a collection of
|
12
3
|
# project files.
|
13
4
|
#
|
14
|
-
class AnnotationExtractor
|
5
|
+
class Bones::AnnotationExtractor
|
15
6
|
|
16
|
-
|
7
|
+
Annotation = Struct.new(:line, :tag, :text) {
|
17
8
|
# Returns a string representation of the annotation. If the
|
18
9
|
# <tt>:tag</tt> parameter is given as +true+, then the annotation tag
|
19
10
|
# will be included in the string.
|
@@ -23,25 +14,25 @@ class AnnotationExtractor
|
|
23
14
|
s << "[#{tag}] " if opts[:tag]
|
24
15
|
s << text
|
25
16
|
end
|
26
|
-
|
17
|
+
}
|
27
18
|
|
28
|
-
# Enumerate all the annoations for the given
|
19
|
+
# Enumerate all the annoations for the given _config_ and _tag_. This
|
29
20
|
# will search for all athe annotations and display them on standard
|
30
21
|
# output.
|
31
22
|
#
|
32
|
-
def self.enumerate(
|
33
|
-
extractor = new(
|
23
|
+
def self.enumerate( config, tag, id = nil, opts = {} )
|
24
|
+
extractor = new(config, tag, id)
|
34
25
|
extractor.display(extractor.find, opts)
|
35
26
|
end
|
36
27
|
|
37
|
-
attr_reader :tag, :
|
28
|
+
attr_reader :tag, :config, :id
|
38
29
|
|
39
|
-
# Creates a new annotation extractor configured to use the
|
30
|
+
# Creates a new annotation extractor configured to use the _config_ open
|
40
31
|
# strcut and to search for the given _tag_ (which can be more than one tag
|
41
32
|
# via a regular expression 'or' operation -- i.e. THIS|THAT|OTHER)
|
42
33
|
#
|
43
|
-
def initialize(
|
44
|
-
@
|
34
|
+
def initialize( config, tag, id)
|
35
|
+
@config = config
|
45
36
|
@tag = tag
|
46
37
|
@id = @id_rgxp = nil
|
47
38
|
|
@@ -58,11 +49,11 @@ class AnnotationExtractor
|
|
58
49
|
results = {}
|
59
50
|
rgxp = %r/(#{tag}):?\s*(.*?)(?:\s*(?:-?%>|\*+\/))?$/o
|
60
51
|
|
61
|
-
extensions =
|
62
|
-
exclude = if
|
63
|
-
else Regexp.new(
|
52
|
+
extensions = config.notes.extensions.dup
|
53
|
+
exclude = if config.notes.exclude.empty? then nil
|
54
|
+
else Regexp.new(config.notes.exclude.join('|')) end
|
64
55
|
|
65
|
-
|
56
|
+
config.gem.files.each do |fn|
|
66
57
|
next if exclude && exclude =~ fn
|
67
58
|
next unless extensions.include? File.extname(fn)
|
68
59
|
results.update(extract_annotations_from(fn, rgxp))
|
@@ -83,7 +74,7 @@ class AnnotationExtractor
|
|
83
74
|
|
84
75
|
text = m[2]
|
85
76
|
if text =~ @id_rgxp
|
86
|
-
text.gsub!(@id_rgxp) {|str|
|
77
|
+
text.gsub!(@id_rgxp) {|str| ::Bones::Colors.green(str)} if config.colorize
|
87
78
|
list << Annotation.new(lineno, m[1], text)
|
88
79
|
end
|
89
80
|
list
|
@@ -105,7 +96,6 @@ class AnnotationExtractor
|
|
105
96
|
end
|
106
97
|
end
|
107
98
|
|
108
|
-
end # class AnnotationExtractor
|
109
|
-
end # module Bones
|
99
|
+
end # class Bones::AnnotationExtractor
|
110
100
|
|
111
101
|
# EOF
|
data/lib/bones/app.rb
CHANGED
@@ -1,58 +1,80 @@
|
|
1
1
|
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require 'erb'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
5
4
|
|
6
|
-
module Bones
|
7
|
-
|
5
|
+
module Bones::App
|
6
|
+
extend LittlePlugger(:path => 'bones/app', :module => Bones::App)
|
7
|
+
disregard_plugins :error, :main, :command, :file_manager
|
8
8
|
|
9
|
-
|
10
|
-
# the command line _args_.
|
11
|
-
#
|
12
|
-
def self.run( args )
|
13
|
-
self.new.run args
|
14
|
-
end
|
9
|
+
Error = Class.new(StandardError)
|
15
10
|
|
16
|
-
# Create a new
|
17
|
-
#
|
11
|
+
# Create a new instance of Main, and run the +bones+ application given
|
12
|
+
# the command line _args_.
|
18
13
|
#
|
19
|
-
def
|
20
|
-
|
21
|
-
|
14
|
+
def self.run( args = nil )
|
15
|
+
args ||= ARGV.dup.map! { |v| v.dup }
|
16
|
+
::Bones::App::Main.new.run args
|
22
17
|
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
19
|
+
class Main
|
20
|
+
attr_reader :stdout
|
21
|
+
attr_reader :stderr
|
22
|
+
|
23
|
+
# Create a new Main application instance. Options can be passed to
|
24
|
+
# configuret he stdout and stderr IO streams (very useful for testing).
|
25
|
+
#
|
26
|
+
def initialize( opts = {} )
|
27
|
+
opts[:stdout] ||= $stdout
|
28
|
+
opts[:stderr] ||= $stderr
|
29
|
+
|
30
|
+
@opts = opts
|
31
|
+
@stdout = opts[:stdout]
|
32
|
+
@stderr = opts[:stderr]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Parse the desired user command and run that command object.
|
36
|
+
#
|
37
|
+
def run( args )
|
38
|
+
commands = []
|
39
|
+
@plugins = ::Bones::App.plugins
|
40
|
+
@plugins.each { |k,v| commands << k.to_s if v < ::Bones::App::Command }
|
41
|
+
|
42
|
+
cmd_str = args.shift
|
43
|
+
cmd = case cmd_str
|
44
|
+
when *commands
|
45
|
+
key = cmd_str.to_sym
|
46
|
+
@plugins[key].new @opts
|
47
|
+
when nil, '-h', '--help'
|
48
|
+
help
|
49
|
+
when '-v', '--version'
|
50
|
+
stdout.puts "Mr Bones v#{::Bones::VERSION}"
|
51
|
+
else
|
52
|
+
raise Error, "Unknown command #{cmd_str.inspect}"
|
53
|
+
end
|
54
|
+
|
55
|
+
if cmd
|
56
|
+
cmd.parse args
|
57
|
+
cmd.run
|
41
58
|
end
|
42
59
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
rescue Bones::App::Error => err
|
61
|
+
stderr.puts "ERROR: While executing bones ..."
|
62
|
+
stderr.puts " #{err.message}"
|
63
|
+
exit 1
|
64
|
+
rescue StandardError => err
|
65
|
+
stderr.puts "ERROR: While executing bones ... (#{err.class})"
|
66
|
+
stderr.puts " #{err.to_s}"
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
|
70
|
+
# Show the toplevel Mr Bones help message.
|
71
|
+
#
|
72
|
+
def help
|
73
|
+
msg = <<-MSG
|
74
|
+
NAME
|
75
|
+
bones v#{::Bones::VERSION}
|
76
|
+
|
77
|
+
DESCRIPTION
|
56
78
|
Mr Bones is a handy tool that builds a skeleton for your new Ruby
|
57
79
|
projects. The skeleton contains some starter code and a collection of
|
58
80
|
rake tasks to ease the management and deployment of your source code.
|
@@ -68,25 +90,32 @@ class App
|
|
68
90
|
bones create -s bort new_rails_project
|
69
91
|
|
70
92
|
Commands:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
bones
|
93
|
+
MSG
|
94
|
+
|
95
|
+
fmt = lambda { |cmd|
|
96
|
+
if @plugins[cmd] < ::Bones::App::Command
|
97
|
+
msg << " bones %-15s %s\n" % [cmd, @plugins[cmd].summary]
|
98
|
+
end
|
99
|
+
}
|
100
|
+
|
101
|
+
ary = [:create, :freeze, :unfreeze, :info]
|
102
|
+
ary.each(&fmt)
|
103
|
+
(@plugins.keys - ary).each(&fmt)
|
104
|
+
|
105
|
+
msg.concat <<-MSG
|
76
106
|
|
77
107
|
Further Help:
|
78
108
|
Each command has a '--help' option that will provide detailed
|
79
109
|
information for that command.
|
80
110
|
|
81
|
-
http://
|
111
|
+
http://github.com/TwP/bones
|
82
112
|
|
83
|
-
|
84
|
-
nil
|
85
|
-
end
|
113
|
+
MSG
|
86
114
|
|
87
|
-
|
88
|
-
end
|
115
|
+
stdout.puts msg
|
116
|
+
end
|
89
117
|
|
90
|
-
|
118
|
+
end # class Main
|
119
|
+
end # module Bones::App
|
91
120
|
|
92
121
|
# EOF
|