Namespace

Included Modules

Bones::Plugins::Gem

Public Instance Methods

define_tasks() click to toggle source
     # File lib/bones/plugins/gem.rb, line 106
106:   def define_tasks
107:     config = ::Bones.config
108: 
109:     namespace :gem do
110:       config.gem._spec = Gem::Specification.new do |s|
111:         s.name = config.name
112:         s.version = config.version
113:         s.summary = config.summary
114:         s.authors = Array(config.authors)
115:         s.email = config.email
116:         s.homepage = Array(config.url).first
117:         s.rubyforge_project = config.name
118: 
119:         if !config.rubyforge.nil? and config.rubyforge.name
120:           s.rubyforge_project = config.rubyforge.name
121:         end
122: 
123:         s.description = config.description
124: 
125:         config.gem.dependencies.each do |dep|
126:           s.add_dependency(*dep)
127:         end
128: 
129:         config.gem.development_dependencies.each do |dep|
130:           s.add_development_dependency(*dep)
131:         end
132: 
133:         s.files = config.gem.files
134:         s.executables = config.gem.executables.map {|fn| File.basename(fn)}
135:         s.extensions = config.gem.files.grep /extconf\.rb$/
136: 
137:         s.bindir = 'bin'
138:         dirs = Dir["{#{config.libs.join(',')}}"]
139:         s.require_paths = dirs unless dirs.empty?
140: 
141:         if have? :rdoc
142:           incl = Regexp.new(config.rdoc.include.join('|'))
143:           excl = config.rdoc.exclude.dup.concat ]\.rb$ ^(\.\/|\/)?ext]
144:           excl = Regexp.new(excl.join('|'))
145:           rdoc_files = config.gem.files.find_all do |fn|
146:                          case fn
147:                          when excl; false
148:                          when incl; true
149:                          else false end
150:                        end
151:           s.rdoc_options = config.rdoc.opts + ['--main', config.rdoc.main]
152:           s.extra_rdoc_files = rdoc_files
153:           s.has_rdoc = true
154:         end
155: 
156:         if config.test
157:           if test ff, config.test.file
158:             s.test_file = config.test.file
159:           else
160:             s.test_files = config.test.files.to_a
161:           end
162:         end
163: 
164:         # Do any extra stuff the user wants
165:         config.gem.extras.each do |msg, val|
166:           case val
167:           when Proc
168:             val.call(s.send(msg))
169:           else
170:             s.send "#{msg}=", val
171:           end
172:         end
173:       end  # Gem::Specification.new
174: 
175:       ::Bones::GemPackageTask.new(config.gem._spec) do |pkg|
176:         pkg.need_tar = config.gem.need_tar
177:         pkg.need_zip = config.gem.need_zip
178:       end
179: 
180:       desc 'Package and upload to rubygems.org'
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: 
190:       desc 'Show information about the gem'
191:       task :debug => 'gem:prereqs' do
192:         puts config.gem._spec.to_ruby
193:       end
194: 
195:       desc 'Write the gemspec '
196:       task :spec => 'gem:prereqs' do
197:         File.open("#{config.name}.gemspec", 'w') do |f|
198:           f.write config.gem._spec.to_ruby
199:         end
200:       end
201: 
202:       desc 'Install the gem'
203:       task :install => [:clobber, 'gem:package'] do
204:         sh "#{SUDO} #{GEM} install --local pkg/#{config.gem._spec.full_name}"
205: 
206:         # use this version of the command for rubygems > 1.0.0
207:         #sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{config.gem._spec.full_name}"
208:       end
209: 
210:       desc 'Uninstall the gem'
211:       task :uninstall do
212:         installed_list = Gem.source_index.find_name(config.name)
213:         if installed_list and installed_list.collect { |s| s.version.to_s}.include?(config.version) then
214:           sh "#{SUDO} #{GEM} uninstall --version '#{config.version}' --ignore-dependencies --executables #{config.name}"
215:         end
216:       end
217: 
218:       desc 'Reinstall the gem'
219:       task :reinstall => [:uninstall, :install]
220: 
221:       desc 'Cleanup the gem'
222:       task :cleanup do
223:         sh "#{SUDO} #{GEM} cleanup #{config.gem._spec.name}"
224:       end
225: 
226:       desc 'Install gem dependencies'
227:       task :install_dependencies => 'gem:prereqs' do
228:         installer = Gem::DependencyInstaller.new
229:         config.gem._spec.dependencies.each {|dep|
230:           next if Gem.available? dep
231: 
232:           $stdout.puts "Installing #{dep.name}"
233:           installer.install dep
234:           installer.installed_gems.each {|spec|
235:             $stdout.puts "Successfully installed #{spec.full_name}"
236:           }
237:         }
238:       end
239:     end  # namespace :gem
240: 
241:     desc 'Alias to gem:package'
242:     task :gem => 'gem:package'
243: 
244:     task :clobber => 'gem:clobber_package'
245:     remove_desc_for_task 'gem:clobber_package'
246:   end
initialize_gem() click to toggle source
    # File lib/bones/plugins/gem.rb, line 32
32:   def initialize_gem
33:     ::Bones.config {
34:       desc 'Configuration settings for gem packaging.'
35:       gem {
36:         dependencies  Array.new, :desc =>           Array of gem dependencies.          A convenience method is provided to add gem dependencies, and so you          should not muck about with this configuration setting manually.          |  depend_on 'rake'          |  depend_on 'rspec', '1.2.8'    # expands to '>= 1.2.8'          |  depend_on 'main', '~> 2.0'
37: 
38:         development_dependencies  Array.new, :desc =>           Array of development gem dependencies.          A convenience method is provided to add gem dependencies, and so you          should not muck about with this configuration setting manually.          |  depend_on 'bones', :development => true          |  depend_on 'mocha', :version => '0.9.8', :development => true
39: 
40:         executables  nil, :desc =>           Array of executables provided by your project. All files in the 'bin'          folder will be included by default. However, if you are using a          non-standard location for your executables then you will need to          include them explicitly here as an Array.
41: 
42:         extensions  FileList['ext/**/extconf.rb'], :desc =>           Array of gem extensions. This is the list of 'extconf.rb' files          provided by your project. Rubygems uses this list of files to          compile extensions when installing your gem.
43: 
44:         files  nil, :desc =>           The list of files to include when packaging up your gem. This          defaults to all files in the current directory excluding those          matched by the 'exclude' option and the 'ignore_file'. You can          supply your Array of files if you desire.
45: 
46:         need_tar  true, :desc =>           When set to true a tar-gzip file will be produced along with your          gem. The default is true.
47: 
48:         need_zip  false, :desc =>           When set to true a zip file will be produced along with your gem.          The default is false.
49: 
50:         extras  Hash.new, :desc =>           A hash of extra Gem::Specification settings that are otherwise not          provided for by Mr Bones. You will need to refer to the rubygems          documentation for a complete list of specification settings.
51:       }
52:     }
53: 
54:     have?(:gem) { true }
55:   end
manifest() click to toggle source

Scans the current working directory and creates a list of files that are candidates to be in the manifest.

     # File lib/bones/plugins/gem.rb, line 251
251:   def manifest
252:     config = ::Bones.config
253:     files = []
254:     exclude = config.exclude.dup
255:     comment = /^\s*#/
256: 
257:     # process the ignore file and add the items there to the exclude list
258:     if test(ff, config.ignore_file)
259:       ary = []
260:       File.readlines(config.ignore_file).each do |line|
261:         next if line =~ comment
262:         line.chomp!
263:         line.strip!
264:         next if line.nil? or line.empty?
265: 
266:         glob = line =~ /\*\./ ? File.join('**', line) : line
267:         Dir.glob(glob).each {|fn| ary << "^#{Regexp.escape(fn)}"}
268:       end
269:       exclude.concat ary
270:     end
271: 
272:     # generate a regular expression from the exclude list
273:     exclude = Regexp.new(exclude.join('|'))
274: 
275:     Find.find '.' do |path|
276:       path.sub! /^(\.\/|\/)/, ''
277:       next unless test ff, path
278:       next if path =~ exclude
279:       files << path
280:     end
281:     files.sort!
282:   end
post_load() click to toggle source
     # File lib/bones/plugins/gem.rb, line 98
 98:   def post_load
 99:     config = ::Bones.config
100: 
101:     config.gem.files ||= manifest
102:     config.gem.executables ||= config.gem.files.find_all {|fn| fn =~ /^bin/}
103:     config.gem.development_dependencies << ['bones', ">= #{Bones.version}"]
104:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.