bones 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +2 -0
- data/README.txt +7 -1
- data/Rakefile +1 -1
- data/data/README.txt.erb +8 -8
- data/data/Rakefile.erb +5 -5
- data/data/tasks/annotations.rake +6 -6
- data/data/tasks/setup.rb +1 -1
- data/lib/bones.rb +25 -169
- data/lib/bones/annotation_extractor.rb +70 -0
- data/lib/bones/main.rb +187 -0
- data/tasks/annotations.rake +7 -7
- data/tasks/setup.rb +2 -2
- metadata +5 -3
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.1.0 / 2007-12-29
|
2
|
+
|
3
|
+
* 3 minor enhancements
|
4
|
+
* Output message when files are created or updated
|
5
|
+
* Directory cleanup if project creation fails
|
6
|
+
* Pulled the rails source annotation extractor into Mr Bones
|
7
|
+
|
1
8
|
== 1.0.0 / 2007-12-28
|
2
9
|
|
3
10
|
* 1 major enhancement
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -66,7 +66,6 @@ following gems installed you will not get all that Mr Bones has to offer.
|
|
66
66
|
* rubyforge - for easy gem publishing to rubyforge.org
|
67
67
|
* rcov - for code coverage testing
|
68
68
|
* rspec - if that's the way you roll
|
69
|
-
* rails - for source annotation extractor (notes)
|
70
69
|
|
71
70
|
== INSTALL:
|
72
71
|
|
@@ -132,6 +131,13 @@ most current version number for the installed gem is used.
|
|
132
131
|
depend_on 'logging'
|
133
132
|
depend_on 'rake', '0.7.3'
|
134
133
|
|
134
|
+
== ACKNOWLEDGEMENTS:
|
135
|
+
|
136
|
+
Ryan Davis and Eric Hodel and their Hoe gem (from which much of the Mr Bones
|
137
|
+
rake tasks have been stolen). The rails team and their source annotation
|
138
|
+
extractor. Bruce Williams for help in coming up with the project name. Ara
|
139
|
+
T. Howard for letting me squat in the codeforpeople rubyforge project.
|
140
|
+
|
135
141
|
== LICENSE:
|
136
142
|
|
137
143
|
MIT License
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ PROJ.summary = 'Mr Bones is a handy tool that builds a skeleton for your new Rub
|
|
12
12
|
PROJ.authors = 'Tim Pease'
|
13
13
|
PROJ.email = 'tim.pease@gmail.com'
|
14
14
|
PROJ.url = 'http://codeforpeople.rubyforge.org/bones'
|
15
|
-
PROJ.description = paragraphs_of('README.txt',
|
15
|
+
PROJ.description = paragraphs_of('README.txt', 1).join("\n\n")
|
16
16
|
PROJ.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
|
17
17
|
PROJ.rubyforge_name = 'codeforpeople'
|
18
18
|
PROJ.rdoc_remote_dir = 'bones'
|
data/data/README.txt.erb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
<%= name %>
|
2
|
-
by
|
3
|
-
|
2
|
+
by FIXME (your name)
|
3
|
+
FIXME (url)
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
|
7
|
+
FIXME (describe your package)
|
8
8
|
|
9
9
|
== FEATURES/PROBLEMS:
|
10
10
|
|
11
|
-
*
|
11
|
+
* FIXME (list of features or problems)
|
12
12
|
|
13
13
|
== SYNOPSIS:
|
14
14
|
|
15
|
-
|
15
|
+
FIXME (code sample of usage)
|
16
16
|
|
17
17
|
== REQUIREMENTS:
|
18
18
|
|
19
|
-
*
|
19
|
+
* FIXME (list of requirements)
|
20
20
|
|
21
21
|
== INSTALL:
|
22
22
|
|
23
|
-
*
|
23
|
+
* FIXME (sudo gem install, anything else)
|
24
24
|
|
25
25
|
== LICENSE:
|
26
26
|
|
27
27
|
(The MIT License)
|
28
28
|
|
29
|
-
Copyright (c) 2007
|
29
|
+
Copyright (c) 2007 FIXME (different license?)
|
30
30
|
|
31
31
|
Permission is hereby granted, free of charge, to any person obtaining
|
32
32
|
a copy of this software and associated documentation files (the
|
data/data/Rakefile.erb
CHANGED
@@ -10,11 +10,11 @@ require '<%= name %>'
|
|
10
10
|
task :default => 'spec:run'
|
11
11
|
|
12
12
|
PROJ.name = '<%= name %>'
|
13
|
-
PROJ.summary = '
|
14
|
-
PROJ.authors = '
|
15
|
-
PROJ.email = '
|
16
|
-
PROJ.url = '
|
17
|
-
PROJ.description = paragraphs_of('README.txt',
|
13
|
+
PROJ.summary = 'FIXME (summary of your project)'
|
14
|
+
PROJ.authors = 'FIXME (who is writing this software)'
|
15
|
+
PROJ.email = 'FIXME (your e-mail)'
|
16
|
+
PROJ.url = 'FIXME (project homepage)'
|
17
|
+
PROJ.description = paragraphs_of('README.txt', 1).join("\n\n")
|
18
18
|
PROJ.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
|
19
19
|
PROJ.rubyforge_name = '<%= name %>'
|
20
20
|
|
data/data/tasks/annotations.rake
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
# $Id$
|
2
2
|
|
3
|
-
if
|
3
|
+
if HAVE_BONES
|
4
4
|
|
5
5
|
desc "Enumerate all annotations"
|
6
6
|
task :notes do
|
7
|
-
|
7
|
+
Bones::AnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
|
8
8
|
end
|
9
9
|
|
10
10
|
namespace :notes do
|
11
11
|
desc "Enumerate all OPTIMIZE annotations"
|
12
12
|
task :optimize do
|
13
|
-
|
13
|
+
Bones::AnnotationExtractor.enumerate "OPTIMIZE"
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "Enumerate all FIXME annotations"
|
17
17
|
task :fixme do
|
18
|
-
|
18
|
+
Bones::AnnotationExtractor.enumerate "FIXME"
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "Enumerate all TODO annotations"
|
22
22
|
task :todo do
|
23
|
-
|
23
|
+
Bones::AnnotationExtractor.enumerate "TODO"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
end # if
|
27
|
+
end # if HAVE_BONES
|
28
28
|
|
29
29
|
# EOF
|
data/data/tasks/setup.rb
CHANGED
@@ -89,7 +89,7 @@ SUDO = if WIN32 then ''
|
|
89
89
|
RCOV = WIN32 ? 'rcov.cmd' : 'rcov'
|
90
90
|
GEM = WIN32 ? 'gem.cmd' : 'gem'
|
91
91
|
|
92
|
-
%w(rcov spec rubyforge
|
92
|
+
%w(rcov spec rubyforge bones).each do |lib|
|
93
93
|
begin
|
94
94
|
require lib
|
95
95
|
Object.instance_eval {const_set "HAVE_#{lib.upcase}", true}
|
data/lib/bones.rb
CHANGED
@@ -1,177 +1,33 @@
|
|
1
|
-
# $Id: bones.rb
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
require 'optparse'
|
5
|
-
require 'erb'
|
1
|
+
# $Id: bones.rb 423 2007-12-29 18:32:34Z tim_pease $
|
6
2
|
|
7
3
|
module Bones
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
def parse( args )
|
32
|
-
self.data = File.join(::Bones::PATH, 'data')
|
33
|
-
self.update = false
|
34
|
-
|
35
|
-
opts = OptionParser.new
|
36
|
-
opts.banner << ' project_name'
|
37
|
-
|
38
|
-
opts.separator ''
|
39
|
-
opts.on('-u', '--update',
|
40
|
-
'update the rake tasks for the project') {self.update = true}
|
41
|
-
|
42
|
-
opts.separator ''
|
43
|
-
opts.separator 'common options:'
|
44
|
-
|
45
|
-
opts.on_tail( '-h', '--help', 'show this message' ) {puts opts; exit}
|
46
|
-
opts.on_tail( '--version', 'show version' ) do
|
47
|
-
puts "Bones #{::Bones::VERSION}"
|
48
|
-
exit
|
49
|
-
end
|
50
|
-
|
51
|
-
# parse the command line arguments
|
52
|
-
opts.parse! args
|
53
|
-
self.name = args.shift
|
54
|
-
|
55
|
-
if name.nil?
|
56
|
-
puts opts
|
57
|
-
::Kernel.abort
|
58
|
-
end
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
|
62
|
-
# Returns +true+ if we are updating an already existing project. Returns
|
63
|
-
# +false+ if we are creating a new project.
|
64
|
-
#
|
65
|
-
def update?
|
66
|
-
@update
|
67
|
-
end
|
68
|
-
|
69
|
-
# Returns the project name but converted to be useable as a Ruby class
|
70
|
-
# name.
|
71
|
-
#
|
72
|
-
def classname
|
73
|
-
name.split('_').map {|x| x.capitalize}.join
|
74
|
-
end
|
75
|
-
|
76
|
-
#
|
77
|
-
#
|
78
|
-
def create
|
79
|
-
# see if the directory already exists
|
80
|
-
abort "'#{name}' already exists" if test ?e, name
|
81
|
-
|
82
|
-
files_to_copy.each {|fn| cp fn}
|
5
|
+
# :stopdoc:
|
6
|
+
VERSION = '1.1.0'
|
7
|
+
PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
8
|
+
WIN32 = %r/win32/ =~ RUBY_PLATFORM unless defined? WIN32
|
9
|
+
DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
|
10
|
+
# :startdoc:
|
11
|
+
|
12
|
+
# call-seq:
|
13
|
+
# Bones.require_all_libs_relative_to( filename, directory = nil )
|
14
|
+
#
|
15
|
+
# Utility method used to rquire all files ending in .rb that lie in the
|
16
|
+
# directory below this file that has the same name as the filename passed
|
17
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
18
|
+
# the _filename_ does not have to be equivalent to the directory.
|
19
|
+
#
|
20
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
21
|
+
dir ||= File.basename(fname, '.*')
|
22
|
+
search_me = File.expand_path(
|
23
|
+
File.join(File.dirname(fname), dir, '**', '*.rb'))
|
24
|
+
|
25
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
26
|
+
end
|
83
27
|
|
84
|
-
|
85
|
-
begin
|
86
|
-
FileUtils.cd name
|
87
|
-
system "rake manifest:create 2>&1 > /dev/null"
|
88
|
-
ensure
|
89
|
-
FileUtils.cd pwd
|
90
|
-
end
|
91
|
-
|
92
|
-
# * copy files from either
|
93
|
-
# 1) the user's '.bones/data' directory or
|
94
|
-
# 2) the Bones 'data' directory
|
95
|
-
#
|
96
|
-
# TODO - figure out if this really is the best way of doing this
|
97
|
-
# should I just use either the .bones data or the gem data, not
|
98
|
-
# both
|
99
|
-
end
|
100
|
-
|
101
|
-
# Archive any existing tasks in the project's tasks folder, and then
|
102
|
-
# copy in new tasks from the bones/data directory.
|
103
|
-
#
|
104
|
-
def update
|
105
|
-
abort "'#{name}' does no exist" unless test ?e, name
|
106
|
-
|
107
|
-
task_dir = File.join(name, 'tasks')
|
108
|
-
abort "no tasks directory found in '#{name}'" unless test ?d, task_dir
|
109
|
-
|
110
|
-
archive_dir = File.join(task_dir, 'archive')
|
111
|
-
FileUtils.rm_rf archive_dir
|
112
|
-
FileUtils.mkdir archive_dir
|
113
|
-
|
114
|
-
Dir.glob(File.join(task_dir, '*')).each do |fn|
|
115
|
-
next if fn == archive_dir
|
116
|
-
FileUtils.cp fn, archive_dir
|
117
|
-
end
|
118
|
-
|
119
|
-
files_to_copy.each do |fn|
|
120
|
-
next unless 'tasks' == File.basename(File.dirname(fn))
|
121
|
-
cp fn
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
|
-
private
|
127
|
-
|
128
|
-
# Copy a file from the Bones prototype project location to the user
|
129
|
-
# specified project location. A message will be displayed to the screen
|
130
|
-
# indicating tha the file is being created.
|
131
|
-
#
|
132
|
-
def cp( file )
|
133
|
-
dir = File.join(name, File.dirname(file))
|
134
|
-
dst = File.join(dir, File.basename(file, '.erb').sub('NAME', name))
|
135
|
-
src = File.join(data, file)
|
136
|
-
|
137
|
-
FileUtils.mkdir_p(dir)
|
138
|
-
|
139
|
-
if '.erb' == File.extname(file)
|
140
|
-
txt = ERB.new(File.read(src), nil, '-').result(binding)
|
141
|
-
File.open(dst, 'w') {|fd| fd.write(txt)}
|
142
|
-
else
|
143
|
-
FileUtils.cp src, dst
|
144
|
-
end
|
145
|
-
|
146
|
-
FileUtils.chmod(File.stat(src).mode, dst)
|
147
|
-
end
|
148
|
-
|
149
|
-
# Prints an abort _msg_ to the screen and then exits the Ruby interpreter.
|
150
|
-
#
|
151
|
-
def abort( msg )
|
152
|
-
STDERR.puts msg
|
153
|
-
exit 1
|
154
|
-
end
|
155
|
-
|
156
|
-
# Returns a list of the files to copy from the bones/data directory to
|
157
|
-
# the new project directory
|
158
|
-
#
|
159
|
-
def files_to_copy
|
160
|
-
rgxp = %r/\A#{data}\/?/o
|
161
|
-
exclude = %r/tmp$|bak$|~$|CVS|\.svn/o
|
162
|
-
|
163
|
-
ary = Dir.glob(File.join(data, '**', '*')).map do |filename|
|
164
|
-
next if exclude =~ filename
|
165
|
-
next if test(?d, filename)
|
166
|
-
filename.sub rgxp, ''
|
167
|
-
end
|
28
|
+
end # module Bones
|
168
29
|
|
169
|
-
ary.compact!
|
170
|
-
ary.sort!
|
171
|
-
ary
|
172
|
-
end
|
173
30
|
|
174
|
-
|
175
|
-
end # module Bones
|
31
|
+
Bones.require_all_libs_relative_to __FILE__
|
176
32
|
|
177
33
|
# EOF
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# $Id: annotation_extractor.rb 423 2007-12-29 18:32:34Z tim_pease $
|
2
|
+
|
3
|
+
module Bones
|
4
|
+
class AnnotationExtractor
|
5
|
+
|
6
|
+
class Annotation < Struct.new(:line, :tag, :text)
|
7
|
+
def to_s(options={})
|
8
|
+
s = "[%3d] " % line
|
9
|
+
s << "[#{tag}] " if options[:tag]
|
10
|
+
s << text
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.enumerate(tag, options={})
|
15
|
+
extractor = new(tag)
|
16
|
+
extractor.display(extractor.find, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :tag
|
20
|
+
|
21
|
+
def initialize(tag)
|
22
|
+
@tag = tag
|
23
|
+
end
|
24
|
+
|
25
|
+
def find(dirs=%w(app lib test))
|
26
|
+
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_in(dir)
|
30
|
+
results = {}
|
31
|
+
|
32
|
+
Dir.glob("#{dir}/*") do |item|
|
33
|
+
next if File.basename(item)[0] == ?.
|
34
|
+
|
35
|
+
if File.directory?(item)
|
36
|
+
results.update(find_in(item))
|
37
|
+
elsif item =~ /\.(builder|(r(?:b|xml|js)))$/
|
38
|
+
results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
|
39
|
+
elsif item =~ /\.(rhtml|erb)$/
|
40
|
+
results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
results
|
45
|
+
end
|
46
|
+
|
47
|
+
def extract_annotations_from(file, pattern)
|
48
|
+
lineno = 0
|
49
|
+
result = File.readlines(file).inject([]) do |list, line|
|
50
|
+
lineno += 1
|
51
|
+
next list unless line =~ pattern
|
52
|
+
list << Annotation.new(lineno, $1, $2)
|
53
|
+
end
|
54
|
+
result.empty? ? {} : { file => result }
|
55
|
+
end
|
56
|
+
|
57
|
+
def display(results, options={})
|
58
|
+
results.keys.sort.each do |file|
|
59
|
+
puts "#{file}:"
|
60
|
+
results[file].each do |note|
|
61
|
+
puts " * #{note.to_s(options)}"
|
62
|
+
end
|
63
|
+
puts
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end # class AnnotationExtractor
|
68
|
+
end # module Bones
|
69
|
+
|
70
|
+
# EOF
|
data/lib/bones/main.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# $Id: main.rb 423 2007-12-29 18:32:34Z tim_pease $
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'optparse'
|
5
|
+
require 'erb'
|
6
|
+
|
7
|
+
module Bones
|
8
|
+
class Main
|
9
|
+
|
10
|
+
attr_writer :update
|
11
|
+
attr_accessor :name, :data, :verbose
|
12
|
+
|
13
|
+
# Create a new instance of Main, and run the +bones+ application given
|
14
|
+
# the command line _args_.
|
15
|
+
#
|
16
|
+
def self.run( args )
|
17
|
+
bones = self.new
|
18
|
+
bones.parse args
|
19
|
+
|
20
|
+
if bones.update? then bones.update
|
21
|
+
else bones.create end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parse the command line arguments and store the values for later use by
|
25
|
+
# the +create+ and +update+ methods.
|
26
|
+
#
|
27
|
+
def parse( args )
|
28
|
+
self.data = File.join(::Bones::PATH, 'data')
|
29
|
+
self.update = false
|
30
|
+
self.verbose = false
|
31
|
+
|
32
|
+
opts = OptionParser.new
|
33
|
+
opts.banner << ' project_name'
|
34
|
+
|
35
|
+
opts.separator ''
|
36
|
+
opts.on('-u', '--update',
|
37
|
+
'update the rake tasks for the project') {self.update = true}
|
38
|
+
opts.on('-v', '--verbose',
|
39
|
+
'enable verbose output') {self.verbose = true}
|
40
|
+
|
41
|
+
opts.separator ''
|
42
|
+
opts.separator 'common options:'
|
43
|
+
|
44
|
+
opts.on_tail( '-h', '--help', 'show this message' ) {puts opts; exit}
|
45
|
+
opts.on_tail( '--version', 'show version' ) do
|
46
|
+
puts "Bones #{::Bones::VERSION}"
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
50
|
+
# parse the command line arguments
|
51
|
+
opts.parse! args
|
52
|
+
self.name = args.shift
|
53
|
+
|
54
|
+
if name.nil?
|
55
|
+
puts opts
|
56
|
+
::Kernel.abort
|
57
|
+
end
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns +true+ if we are updating an already existing project. Returns
|
62
|
+
# +false+ if we are creating a new project.
|
63
|
+
#
|
64
|
+
def update?
|
65
|
+
@update
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns the project name but converted to be useable as a Ruby class
|
69
|
+
# name.
|
70
|
+
#
|
71
|
+
def classname
|
72
|
+
name.split('_').map {|x| x.capitalize}.join
|
73
|
+
end
|
74
|
+
|
75
|
+
# Create a new project from the bones/data project template.
|
76
|
+
#
|
77
|
+
def create
|
78
|
+
# * copy files from either
|
79
|
+
# 1) the user's '.bones/data' directory or
|
80
|
+
# 2) the Bones 'data' directory
|
81
|
+
#
|
82
|
+
# TODO - figure out if this really is the best way of doing this
|
83
|
+
# should I just use either the .bones data or the gem data, not
|
84
|
+
# both
|
85
|
+
|
86
|
+
# see if the directory already exists
|
87
|
+
abort "'#{name}' already exists" if test ?e, name
|
88
|
+
|
89
|
+
begin
|
90
|
+
files_to_copy.each {|fn| cp fn}
|
91
|
+
|
92
|
+
pwd = File.expand_path(FileUtils.pwd)
|
93
|
+
begin
|
94
|
+
FileUtils.cd name
|
95
|
+
system "rake manifest:create 2>&1 > #{::Bones::DEV_NULL}"
|
96
|
+
ensure
|
97
|
+
FileUtils.cd pwd
|
98
|
+
end
|
99
|
+
rescue Exception => err
|
100
|
+
FileUtils.rm_rf name
|
101
|
+
abort "could not create '#{name}'"
|
102
|
+
end
|
103
|
+
|
104
|
+
STDOUT.puts "created '#{name}'"
|
105
|
+
end
|
106
|
+
|
107
|
+
# Archive any existing tasks in the project's tasks folder, and then
|
108
|
+
# copy in new tasks from the bones/data directory.
|
109
|
+
#
|
110
|
+
def update
|
111
|
+
abort "'#{name}' does no exist" unless test ?e, name
|
112
|
+
|
113
|
+
task_dir = File.join(name, 'tasks')
|
114
|
+
abort "no tasks directory found in '#{name}'" unless test ?d, task_dir
|
115
|
+
|
116
|
+
archive_dir = File.join(task_dir, 'archive')
|
117
|
+
FileUtils.rm_rf archive_dir
|
118
|
+
FileUtils.mkdir archive_dir
|
119
|
+
|
120
|
+
Dir.glob(File.join(task_dir, '*')).each do |fn|
|
121
|
+
next if fn == archive_dir
|
122
|
+
FileUtils.cp fn, archive_dir
|
123
|
+
end
|
124
|
+
|
125
|
+
files_to_copy.each do |fn|
|
126
|
+
next unless 'tasks' == File.basename(File.dirname(fn))
|
127
|
+
cp fn
|
128
|
+
end
|
129
|
+
|
130
|
+
STDOUT.puts "updated tasks for '#{name}'"
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
# Copy a file from the Bones prototype project location to the user
|
137
|
+
# specified project location. A message will be displayed to the screen
|
138
|
+
# indicating tha the file is being created.
|
139
|
+
#
|
140
|
+
def cp( file )
|
141
|
+
dir = File.dirname(file)
|
142
|
+
dir = (dir == '.' ? name : File.join(name, dir))
|
143
|
+
dst = File.join(dir, File.basename(file, '.erb').sub('NAME', name))
|
144
|
+
src = File.join(data, file)
|
145
|
+
|
146
|
+
puts (test(?e, dst) ? "updating #{dst}" : "creating #{dst}") if verbose
|
147
|
+
FileUtils.mkdir_p(dir)
|
148
|
+
|
149
|
+
if '.erb' == File.extname(file)
|
150
|
+
txt = ERB.new(File.read(src), nil, '-').result(binding)
|
151
|
+
File.open(dst, 'w') {|fd| fd.write(txt)}
|
152
|
+
else
|
153
|
+
FileUtils.cp src, dst
|
154
|
+
end
|
155
|
+
|
156
|
+
FileUtils.chmod(File.stat(src).mode, dst)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Prints an abort _msg_ to the screen and then exits the Ruby interpreter.
|
160
|
+
#
|
161
|
+
def abort( msg )
|
162
|
+
STDERR.puts msg
|
163
|
+
exit 1
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns a list of the files to copy from the bones/data directory to
|
167
|
+
# the new project directory
|
168
|
+
#
|
169
|
+
def files_to_copy
|
170
|
+
rgxp = %r/\A#{data}\/?/o
|
171
|
+
exclude = %r/tmp$|bak$|~$|CVS|\.svn/o
|
172
|
+
|
173
|
+
ary = Dir.glob(File.join(data, '**', '*')).map do |filename|
|
174
|
+
next if exclude =~ filename
|
175
|
+
next if test(?d, filename)
|
176
|
+
filename.sub rgxp, ''
|
177
|
+
end
|
178
|
+
|
179
|
+
ary.compact!
|
180
|
+
ary.sort!
|
181
|
+
ary
|
182
|
+
end
|
183
|
+
|
184
|
+
end # class Main
|
185
|
+
end # module Bones
|
186
|
+
|
187
|
+
# EOF
|
data/tasks/annotations.rake
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
# $Id: annotations.rake
|
1
|
+
# $Id: annotations.rake 423 2007-12-29 18:32:34Z tim_pease $
|
2
2
|
|
3
|
-
if
|
3
|
+
if HAVE_BONES
|
4
4
|
|
5
5
|
desc "Enumerate all annotations"
|
6
6
|
task :notes do
|
7
|
-
|
7
|
+
Bones::AnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
|
8
8
|
end
|
9
9
|
|
10
10
|
namespace :notes do
|
11
11
|
desc "Enumerate all OPTIMIZE annotations"
|
12
12
|
task :optimize do
|
13
|
-
|
13
|
+
Bones::AnnotationExtractor.enumerate "OPTIMIZE"
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "Enumerate all FIXME annotations"
|
17
17
|
task :fixme do
|
18
|
-
|
18
|
+
Bones::AnnotationExtractor.enumerate "FIXME"
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "Enumerate all TODO annotations"
|
22
22
|
task :todo do
|
23
|
-
|
23
|
+
Bones::AnnotationExtractor.enumerate "TODO"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
end # if
|
27
|
+
end # if HAVE_BONES
|
28
28
|
|
29
29
|
# EOF
|
data/tasks/setup.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: setup.rb
|
1
|
+
# $Id: setup.rb 423 2007-12-29 18:32:34Z tim_pease $
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'rake'
|
@@ -89,7 +89,7 @@ SUDO = if WIN32 then ''
|
|
89
89
|
RCOV = WIN32 ? 'rcov.cmd' : 'rcov'
|
90
90
|
GEM = WIN32 ? 'gem.cmd' : 'gem'
|
91
91
|
|
92
|
-
%w(rcov spec rubyforge
|
92
|
+
%w(rcov spec rubyforge bones).each do |lib|
|
93
93
|
begin
|
94
94
|
require lib
|
95
95
|
Object.instance_eval {const_set "HAVE_#{lib.upcase}", true}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bones
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2007-12-
|
12
|
+
date: 2007-12-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: "Mr Bones
|
16
|
+
description: "== DESCRIPTION: Mr Bones is a handy tool that builds a skeleton for your new Ruby projects. The skeleton contains some starter code and a collection of rake tasks to ease the management and deployment of your source code. Mr Bones is not viral -- all the code your project needs is included in the skeleton (no gem dependency required)."
|
17
17
|
email: tim.pease@gmail.com
|
18
18
|
executables:
|
19
19
|
- bones
|
@@ -46,6 +46,8 @@ files:
|
|
46
46
|
- data/tasks/test.rake
|
47
47
|
- data/test/test_NAME.rb
|
48
48
|
- lib/bones.rb
|
49
|
+
- lib/bones/annotation_extractor.rb
|
50
|
+
- lib/bones/main.rb
|
49
51
|
- tasks/annotations.rake
|
50
52
|
- tasks/doc.rake
|
51
53
|
- tasks/gem.rake
|