bones 2.5.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/History.txt +2 -0
  2. data/README.rdoc +54 -306
  3. data/Rakefile +28 -37
  4. data/bin/bones +10 -3
  5. data/{spec/data/data → default}/.bnsignore +3 -1
  6. data/{data → default}/History.txt.bns +0 -0
  7. data/{data → default}/README.txt.bns +0 -0
  8. data/default/Rakefile.bns +21 -0
  9. data/{data → default}/bin/NAME.bns +0 -0
  10. data/{data → default}/lib/NAME.rb.bns +0 -0
  11. data/{data → default}/spec/NAME_spec.rb.bns +0 -0
  12. data/{data → default}/spec/spec_helper.rb.bns +0 -0
  13. data/{data → default}/test/test_NAME.rb +0 -0
  14. data/lib/bones.rb +73 -31
  15. data/lib/bones/annotation_extractor.rb +16 -26
  16. data/lib/bones/app.rb +87 -58
  17. data/lib/bones/app/command.rb +143 -64
  18. data/lib/bones/app/create.rb +93 -0
  19. data/lib/bones/app/file_manager.rb +7 -8
  20. data/lib/bones/app/freeze.rb +59 -0
  21. data/lib/bones/app/info.rb +39 -0
  22. data/lib/bones/app/unfreeze.rb +44 -0
  23. data/lib/bones/colors.rb +54 -0
  24. data/lib/bones/gem_package_task.rb +71 -0
  25. data/lib/bones/helpers.rb +93 -0
  26. data/lib/bones/plugins/ann.rb +166 -0
  27. data/lib/bones/plugins/bones_plugin.rb +193 -0
  28. data/lib/bones/plugins/gem.rb +274 -0
  29. data/lib/bones/plugins/notes.rb +45 -0
  30. data/lib/bones/plugins/rdoc.rb +93 -0
  31. data/lib/bones/plugins/test.rb +57 -0
  32. data/lib/bones/smtp_tls.rb +1 -0
  33. data/spec/bones/app/file_manager_spec.rb +6 -6
  34. data/spec/bones/app_spec.rb +14 -18
  35. data/spec/bones_spec.rb +9 -4
  36. data/{data → spec/data/default}/.bnsignore +0 -0
  37. data/spec/data/{data → default}/History +0 -0
  38. data/spec/data/{data → default}/NAME/NAME.rb.bns +0 -0
  39. data/spec/data/{data → default}/README.txt.bns +0 -0
  40. data/{data → spec/data/default}/Rakefile.bns +0 -0
  41. data/spec/data/{data → default}/lib/NAME.rb.bns +0 -0
  42. metadata +94 -68
  43. data/lib/bones/app/create_command.rb +0 -86
  44. data/lib/bones/app/freeze_command.rb +0 -73
  45. data/lib/bones/app/info_command.rb +0 -58
  46. data/lib/bones/app/unfreeze_command.rb +0 -53
  47. data/lib/bones/app/update_command.rb +0 -47
  48. data/lib/bones/debug.rb +0 -72
  49. data/lib/bones/tasks/ann.rake +0 -80
  50. data/lib/bones/tasks/bones.rake +0 -20
  51. data/lib/bones/tasks/gem.rake +0 -201
  52. data/lib/bones/tasks/git.rake +0 -40
  53. data/lib/bones/tasks/notes.rake +0 -27
  54. data/lib/bones/tasks/post_load.rake +0 -34
  55. data/lib/bones/tasks/rdoc.rake +0 -51
  56. data/lib/bones/tasks/rubyforge.rake +0 -55
  57. data/lib/bones/tasks/setup.rb +0 -292
  58. data/lib/bones/tasks/spec.rake +0 -54
  59. data/lib/bones/tasks/svn.rake +0 -47
  60. data/lib/bones/tasks/test.rake +0 -40
  61. data/lib/bones/tasks/zentest.rake +0 -36
  62. data/spec/data/data/Rakefile.bns +0 -30
  63. data/tasks/ann.rake +0 -80
  64. data/tasks/bones.rake +0 -20
  65. data/tasks/gem.rake +0 -201
  66. data/tasks/git.rake +0 -40
  67. data/tasks/notes.rake +0 -27
  68. data/tasks/post_load.rake +0 -34
  69. data/tasks/rdoc.rake +0 -51
  70. data/tasks/rubyforge.rake +0 -55
  71. data/tasks/setup.rb +0 -292
  72. data/tasks/spec.rake +0 -54
  73. data/tasks/svn.rake +0 -47
  74. data/tasks/test.rake +0 -40
  75. data/tasks/zentest.rake +0 -36
@@ -0,0 +1,193 @@
1
+
2
+ module Bones::Plugins::BonesPlugin
3
+ include ::Bones::Helpers
4
+ extend self
5
+
6
+ module Syntax
7
+ def enable_sudo
8
+ use_sudo true
9
+ end
10
+ end
11
+
12
+ def initialize_bones_plugin
13
+ ::Bones.config {
14
+ # ==== Project Defaults
15
+ name nil, :desc => <<-__
16
+ The project name that will be used for packaging and distributing
17
+ your Ruby code as a gem.
18
+ __
19
+
20
+ summary nil, :desc => <<-__
21
+ A short summary of your project. This summary is required in the
22
+ gemspec, and it is used by the rubygem framework when searching
23
+ for gems. If a summary is not given, then the first sentence from
24
+ the project's README description is used as the summary.
25
+ __
26
+
27
+ description nil, :desc => <<-__
28
+ A longer description of your project. The description is used in
29
+ the gemspec, but it is not required to build a gem. If a
30
+ description is not given then the first paragraph from the
31
+ project's README description is used as the description.
32
+ __
33
+
34
+ changes nil, :desc => <<-__
35
+ The list of notable changes in your project since the last release.
36
+ The changes are automatically filled in by reading the list of
37
+ changes from the project's History file. Only the changes for the
38
+ most current release are included.
39
+ __
40
+
41
+ authors nil, :desc => <<-__
42
+ This can be a single author (as a string) or an array of authors
43
+ if more than one person is working on the project.
44
+ __
45
+
46
+ email nil, :desc => <<-__
47
+ An email address so others can contact you with questions, bug
48
+ reports, compliments, large quantities of cash, etc.
49
+ __
50
+
51
+ url "\000", :desc => <<-__
52
+ The canonical URL for your project. This should be a location
53
+ where others can go to find out more information about the project
54
+ such as links to source code, bug trackers, wikis, generated
55
+ documentation, etc. A good recommendation would be to point
56
+ to your gem on gemcutter.org (soon to be rubygems.org).
57
+ __
58
+
59
+ version ENV['VERSION'] || '0.0.0', :desc => <<-__
60
+ Version number to use when creating the gem. This can be set either
61
+ in the Rakefile or on the command line by setting the VERSION flag to
62
+ the desired value.
63
+ |
64
+ | rake gem VERSION=0.4.2
65
+ |
66
+ The VERSION flag must be explicitly set on the command line when
67
+ releasing a gem. This is just a safety measure to prevent premature
68
+ gem release.
69
+ __
70
+
71
+ release_name ENV['RELEASE'], :desc => <<-__
72
+ And optional release name to be associated with your gem. This is used
73
+ only when creating a release announcement.
74
+ __
75
+
76
+ exclude %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/), :desc => <<-__
77
+ A list of regular expression patterns that will be used to exclude
78
+ certain files from the gem packaging process. Each pattern is given
79
+ as a string, and they are all combined using the regular expression
80
+ or "|" operator.
81
+ __
82
+
83
+ # ==== System Defaults
84
+ ruby_opts %w(-w), :desc => <<-__
85
+ Default options to pass to the Ruby interpreter when executing tests
86
+ and specs. The default is to enable all warnings. Since this is an
87
+ array, the current options can be cleared and new options can be added
88
+ using the standard array operations
89
+ |
90
+ | ruby_opts.clear
91
+ | ruby_opts << '-Ilib' << '-rubygems'
92
+ |
93
+ __
94
+
95
+ libs Array.new, :desc => <<-__
96
+ This is an array of directories to automatically include in the
97
+ LOAD_PATH of your project. These directories are use for tests and
98
+ specs, and the gem system sets the "require_paths" for the gem from
99
+ these directories. If no libs are given, then the "lib" and "ext"
100
+ directories are automatically added if they are present in your
101
+ project.
102
+ __
103
+
104
+ history_file 'History.txt', :desc => <<-__
105
+ The name of your project's History file. The default is 'History.txt'
106
+ but you are free to change it to whatever you choose.
107
+ __
108
+
109
+ readme_file 'README.txt', :desc => <<-__
110
+ The name of your project's README file. The default is 'README.txt'
111
+ but you are free to change it to whatever you choose. Since GitHub
112
+ understand various markup languages, you can change the README
113
+ file to support your markup language of choice.
114
+ __
115
+
116
+ ignore_file '.bnsignore', :desc => <<-__
117
+ Mr Bones does not use a manifest to determine which fiels should be
118
+ included in your project. All files are included unless they appear
119
+ in the ignore file or in the "exclude" configruation option. The
120
+ ignore file defaults to '.bnsignore'; however, if you are using git
121
+ as your version control system you can just as easily set the ignore
122
+ file to your '.gitignore' file.
123
+ __
124
+
125
+ colorize true, :desc => <<-__
126
+ When set to true, various output from Mr Bones will be colorized
127
+ using terminal ANSI codes. Set to false if your terminal does not
128
+ support colors.
129
+ __
130
+
131
+ use_sudo false, :desc => <<-__
132
+ When set to true gem commands will be run using sudo. A convenience
133
+ method is provided to enable sudo for gem commands
134
+ |
135
+ | enable_sudo
136
+ |
137
+ This is equivalent to 'use_sudo true', but it reads a little nicer.
138
+ __
139
+ }
140
+ end
141
+
142
+ def post_load
143
+ config = ::Bones.config
144
+
145
+ config.exclude << "^#{Regexp.escape(config.ignore_file)}$"
146
+ config.changes ||= paragraphs_of(config.history_file, 0..1).join("\n\n")
147
+ config.description ||= paragraphs_of(config.readme_file, 'description').join("\n\n")
148
+ config.summary ||= config.description.split('.').first
149
+
150
+ if config.libs.empty?
151
+ %w(lib ext).each { |dir| config.libs << dir if test ?d, dir }
152
+ end
153
+
154
+ ::Bones::Helpers::SUDO.replace('') unless config.use_sudo
155
+ end
156
+
157
+ def define_tasks
158
+ config = ::Bones.config
159
+
160
+ namespace :bones do
161
+ desc 'Show the current Mr Bones configuration'
162
+ task :debug do |t|
163
+ atr = if t.application.top_level_tasks.length == 2
164
+ t.application.top_level_tasks.pop
165
+ end
166
+
167
+ ::Bones.help.show(atr, :descriptions => false, :values => true)
168
+ end
169
+
170
+ desc 'Show descriptions for the various Mr Bones configuration options'
171
+ task :help do |t|
172
+ atr = if t.application.top_level_tasks.length == 2
173
+ t.application.top_level_tasks.pop
174
+ end
175
+
176
+ ::Bones.help.show(atr, :descriptions => true, :values => true)
177
+ end
178
+
179
+ desc 'Show the available Mr Bones configuration options'
180
+ task :options do |t|
181
+ atr = if t.application.top_level_tasks.length == 2
182
+ t.application.top_level_tasks.pop
183
+ end
184
+
185
+ ::Bones.help.show(atr, :descriptions => false, :values => false)
186
+ end
187
+
188
+ end # namespace :bones
189
+ end
190
+
191
+ end # module Bones::Plugins::BonesPlugin
192
+
193
+ # EOF
@@ -0,0 +1,274 @@
1
+
2
+ module Bones::Plugins::Gem
3
+ include ::Bones::Helpers
4
+ extend self
5
+
6
+ module Syntax
7
+ # Adds the given gem _name_ to the current project's dependency list. An
8
+ # optional gem _version_ can be given. If omitted, the newest gem version
9
+ # will be used.
10
+ #
11
+ def depend_on( name, *args )
12
+ opts = Hash === args.last ? args.pop : {}
13
+ version = args.first || opts[:version]
14
+ development = opts.key?(:development) ? opts[:development] : opts.key?(:dev) ? opts[:dev] : false
15
+
16
+ spec = Gem.source_index.find_name(name).last
17
+ version = spec.version.to_s if version.nil? and !spec.nil?
18
+
19
+ dep = case version
20
+ when nil; [name]
21
+ when %r/^\d/; [name, ">= #{version}"]
22
+ else [name, version] end
23
+
24
+ development ?
25
+ ::Bones.config.gem.development_dependencies << dep :
26
+ ::Bones.config.gem.dependencies << dep
27
+ end
28
+ end
29
+
30
+ def initialize_gem
31
+ ::Bones.config {
32
+ desc 'Configuration settings for gem packaging.'
33
+ gem {
34
+ dependencies Array.new, :desc => <<-__
35
+ Array of gem dependencies.
36
+
37
+ A convenience method is provided to add gem dependencies, and so you
38
+ should not muck about with this configuration setting manually.
39
+
40
+ | depend_on 'rake'
41
+ | depend_on 'rspec', '1.2.8' # expands to '>= 1.2.8'
42
+ | depend_on 'main', '~> 2.0'
43
+ __
44
+
45
+ development_dependencies Array.new, :desc => <<-__
46
+ Array of development gem dependencies.
47
+
48
+ A convenience method is provided to add gem dependencies, and so you
49
+ should not muck about with this configuration setting manually.
50
+
51
+ | depend_on 'bones', :deveopment => true
52
+ | depend_on 'mocah', :version => '0.9.8', :development => true
53
+ __
54
+
55
+ executables nil, :desc => <<-__
56
+ Array of executables provided by your project. All files in the 'bin'
57
+ folder will be included by default. However, if you are using a
58
+ non-standard location for your executables then you will need to
59
+ include them explicitly here as an Array.
60
+ __
61
+
62
+ extensions FileList['ext/**/extconf.rb'], :desc => <<-__
63
+ Array of gem extensions. This is the list of 'extconf.rb' files
64
+ provided by your project. Rubygems uses this list of files to
65
+ compile extensions when installing your gem.
66
+ __
67
+
68
+ files nil, :desc => <<-__
69
+ The list of files to include when packaging up your gem. This
70
+ defaults to all files in the current directory excluding those
71
+ matched by the 'exclude' option and the 'ignore_file'. You can
72
+ supply your Array of files if you desire.
73
+ __
74
+
75
+ need_tar true, :desc => <<-__
76
+ When set to true a tar-gzip file will be produced along with your
77
+ gem. The default is true.
78
+ __
79
+
80
+ need_zip false, :desc => <<-__
81
+ When set to true a zip file will be produced along with your gem.
82
+ The default is false.
83
+ __
84
+
85
+ extras Hash.new, :desc => <<-__
86
+ A hash of extra Gem::Specification settings that are otherwise not
87
+ provided for by Mr Bones. You will need to refer to the rubygems
88
+ documentation for a complete list of specification settings.
89
+ __
90
+ }
91
+ }
92
+
93
+ have?(:gem) { true }
94
+ end
95
+
96
+ def post_load
97
+ config = ::Bones.config
98
+
99
+ config.gem.files ||= manifest
100
+ config.gem.executables ||= config.gem.files.find_all {|fn| fn =~ %r/^bin/}
101
+ config.gem.development_dependencies << ['bones', ">= #{Bones::VERSION}"]
102
+
103
+ have?(:gemcutter) {
104
+ Gem.searcher.instance_variable_get(:@gemspecs).
105
+ map {|gs| gs.name}.include? 'gemcutter'
106
+ }
107
+ end
108
+
109
+ def define_tasks
110
+ config = ::Bones.config
111
+
112
+ namespace :gem do
113
+ config.gem._spec = Gem::Specification.new do |s|
114
+ s.name = config.name
115
+ s.version = config.version
116
+ s.summary = config.summary
117
+ s.authors = Array(config.authors)
118
+ s.email = config.email
119
+ s.homepage = Array(config.url).first
120
+ s.rubyforge_project = config.rubyforge.name || config.name rescue config.name
121
+
122
+ s.description = config.description
123
+
124
+ config.gem.dependencies.each do |dep|
125
+ s.add_dependency(*dep)
126
+ end
127
+
128
+ config.gem.development_dependencies.each do |dep|
129
+ s.add_development_dependency(*dep)
130
+ end
131
+
132
+ s.files = config.gem.files
133
+ s.executables = config.gem.executables.map {|fn| File.basename(fn)}
134
+ s.extensions = config.gem.files.grep %r/extconf\.rb$/
135
+
136
+ s.bindir = 'bin'
137
+ dirs = Dir["{#{config.libs.join(',')}}"]
138
+ s.require_paths = dirs unless dirs.empty?
139
+
140
+ if config.rdoc
141
+ incl = Regexp.new(config.rdoc.include.join('|'))
142
+ excl = config.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
143
+ excl = Regexp.new(excl.join('|'))
144
+ rdoc_files = config.gem.files.find_all do |fn|
145
+ case fn
146
+ when excl; false
147
+ when incl; true
148
+ else false end
149
+ end
150
+ s.rdoc_options = config.rdoc.opts + ['--main', config.rdoc.main]
151
+ s.extra_rdoc_files = rdoc_files
152
+ s.has_rdoc = true
153
+ end
154
+
155
+ if config.test
156
+ if test ?f, config.test.file
157
+ s.test_file = config.test.file
158
+ else
159
+ s.test_files = config.test.files.to_a
160
+ end
161
+ end
162
+
163
+ # Do any extra stuff the user wants
164
+ config.gem.extras.each do |msg, val|
165
+ case val
166
+ when Proc
167
+ val.call(s.send(msg))
168
+ else
169
+ s.send "#{msg}=", val
170
+ end
171
+ end
172
+ end # Gem::Specification.new
173
+
174
+ ::Bones::GemPackageTask.new(config.gem._spec) do |pkg|
175
+ pkg.need_tar = config.gem.need_tar
176
+ pkg.need_zip = config.gem.need_zip
177
+ end
178
+
179
+ if have? :gemcutter
180
+ desc 'Package and upload to Gemcutter'
181
+ task :release => [:clobber, 'gem'] do |t|
182
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
183
+ abort "Versions don't match #{v} vs #{config.version}" if v != config.version
184
+
185
+ Dir.glob("pkg/#{config.gem._spec.full_name}*.gem").each { |fn|
186
+ sh "#{GEM} push #{fn}"
187
+ }
188
+ end
189
+ end
190
+
191
+ desc 'Show information about the gem'
192
+ task :debug => 'gem:prereqs' do
193
+ puts config.gem._spec.to_ruby
194
+ end
195
+
196
+ desc 'Write the gemspec '
197
+ task :spec => 'gem:prereqs' do
198
+ File.open("#{config.name}.gemspec", 'w') do |f|
199
+ f.write config.gem._spec.to_ruby
200
+ end
201
+ end
202
+
203
+ desc 'Install the gem'
204
+ task :install => [:clobber, 'gem:package'] do
205
+ sh "#{SUDO} #{GEM} install --local pkg/#{config.gem._spec.full_name}"
206
+
207
+ # use this version of the command for rubygems > 1.0.0
208
+ #sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{config.gem._spec.full_name}"
209
+ end
210
+
211
+ desc 'Uninstall the gem'
212
+ task :uninstall do
213
+ installed_list = Gem.source_index.find_name(config.name)
214
+ if installed_list and installed_list.collect { |s| s.version.to_s}.include?(config.version) then
215
+ sh "#{SUDO} #{GEM} uninstall --version '#{config.version}' --ignore-dependencies --executables #{config.name}"
216
+ end
217
+ end
218
+
219
+ desc 'Reinstall the gem'
220
+ task :reinstall => [:uninstall, :install]
221
+
222
+ desc 'Cleanup the gem'
223
+ task :cleanup do
224
+ sh "#{SUDO} #{GEM} cleanup #{config.gem._spec.name}"
225
+ end
226
+ end # namespace :gem
227
+
228
+
229
+ desc 'Alias to gem:package'
230
+ task :gem => 'gem:package'
231
+
232
+ task :clobber => 'gem:clobber_package'
233
+ remove_desc_for_task 'gem:clobber_package'
234
+ end
235
+
236
+ # Scans the current working directory and creates a list of files that are
237
+ # candidates to be in the manifest.
238
+ #
239
+ def manifest
240
+ config = ::Bones.config
241
+ files = []
242
+ exclude = config.exclude.dup
243
+ comment = %r/^\s*#/
244
+
245
+ # process the ignore file and add the items there to the exclude list
246
+ if test(?f, config.ignore_file)
247
+ ary = []
248
+ File.readlines(config.ignore_file).each do |line|
249
+ next if line =~ comment
250
+ line.chomp!
251
+ line.strip!
252
+ next if line.nil? or line.empty?
253
+
254
+ glob = line =~ %r/\*\./ ? File.join('**', line) : line
255
+ Dir.glob(glob).each {|fn| ary << "^#{Regexp.escape(fn)}"}
256
+ end
257
+ exclude.concat ary
258
+ end
259
+
260
+ # generate a regular expression from the exclude list
261
+ exclude = Regexp.new(exclude.join('|'))
262
+
263
+ Find.find '.' do |path|
264
+ path.sub! %r/^(\.\/|\/)/o, ''
265
+ next unless test ?f, path
266
+ next if path =~ exclude
267
+ files << path
268
+ end
269
+ files.sort!
270
+ end
271
+
272
+ end # Bones::Plugins::Gem
273
+
274
+ # EOF