mob 0.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.
Files changed (4) hide show
  1. data/Rakefile +395 -0
  2. data/lib/mob.rb +3 -0
  3. data/mob.gemspec +28 -0
  4. metadata +47 -0
data/Rakefile ADDED
@@ -0,0 +1,395 @@
1
+ This.rubyforge_project = 'codeforpeople'
2
+ This.author = "Ara T. Howard"
3
+ This.email = "ara.t.howard@gmail.com"
4
+ This.homepage = "https://github.com/ahoward/#{ This.lib }"
5
+
6
+
7
+ task :default do
8
+ puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
9
+ end
10
+
11
+ task :test do
12
+ run_tests!
13
+ end
14
+
15
+ namespace :test do
16
+ task(:unit){ run_tests!(:unit) }
17
+ task(:functional){ run_tests!(:functional) }
18
+ task(:integration){ run_tests!(:integration) }
19
+ end
20
+
21
+ def run_tests!(which = nil)
22
+ which ||= '**'
23
+ test_dir = File.join(This.dir, "test")
24
+ test_glob ||= File.join(test_dir, "#{ which }/**_test.rb")
25
+ test_rbs = Dir.glob(test_glob).sort
26
+
27
+ div = ('=' * 119)
28
+ line = ('-' * 119)
29
+
30
+ test_rbs.each_with_index do |test_rb, index|
31
+ testno = index + 1
32
+ test_rb.gsub!(/#{ Regexp.escape(This.dir) }/, '.')
33
+ command = "#{ File.basename(This.ruby) } -I./lib -I./test/lib #{ test_rb }"
34
+
35
+ puts
36
+ say(div, :color => :cyan, :bold => true)
37
+ say("@#{ testno } => ", :bold => true, :method => :print)
38
+ say(command, :color => :cyan, :bold => true)
39
+ say(line, :color => :cyan, :bold => true)
40
+
41
+ system(command)
42
+
43
+ say(line, :color => :cyan, :bold => true)
44
+
45
+ status = $?.exitstatus
46
+
47
+ if status.zero?
48
+ say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
49
+ say("SUCCESS", :color => :green, :bold => true)
50
+ else
51
+ say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
52
+ say("FAILURE", :color => :red, :bold => true)
53
+ end
54
+ say(line, :color => :cyan, :bold => true)
55
+
56
+ exit(status) unless status.zero?
57
+ end
58
+ end
59
+
60
+
61
+ task :gemspec do
62
+ ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
63
+ ignore_directories = ['pkg', 'test/tmp', 'tmp']
64
+ ignore_files = ['test/log', 'a.rb'] + Dir['db/*'] + %w'db'
65
+
66
+ root = File.expand_path(File.dirname(__FILE__))
67
+
68
+ ignore_directories.map!{|_| File.join(root, _)}
69
+ ignore_files.map!{|_| File.join(root, _)}
70
+
71
+ shiteless =
72
+ lambda do |list|
73
+ list.delete_if do |entry|
74
+ next unless test(?e, entry)
75
+ extension = File.basename(entry).split(%r/[.]/).last
76
+ ignore_extensions.any?{|ext| ext === extension}
77
+ end
78
+ list.delete_if do |entry|
79
+ next unless test(?f, entry)
80
+ filename = File.expand_path(entry)
81
+ ignore_files.any?{|file| File.expand_path(file) == filename}
82
+ end
83
+ list.delete_if do |entry|
84
+ dirname = File.expand_path(entry)
85
+ ignore_directories.any?{|dir| dirname[dir]}
86
+ end
87
+ end
88
+
89
+ lib = This.lib
90
+ object = This.object
91
+ version = This.version
92
+ files = shiteless[Dir::glob("**/**")]
93
+ executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
94
+ #has_rdoc = true #File.exist?('doc')
95
+ test_files = test(?e, "test/#{ lib }.rb") ? "test/#{ lib }.rb" : nil
96
+ summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
97
+ description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
98
+
99
+ if This.extensions.nil?
100
+ This.extensions = []
101
+ extensions = This.extensions
102
+ %w( Makefile configure extconf.rb ).each do |ext|
103
+ extensions << ext if File.exists?(ext)
104
+ end
105
+ end
106
+ extensions = [extensions].flatten.compact
107
+
108
+ # TODO
109
+ if This.dependencies.nil?
110
+ dependencies = []
111
+ else
112
+ case This.dependencies
113
+ when Hash
114
+ dependencies = This.dependencies.values
115
+ when Array
116
+ dependencies = This.dependencies
117
+ end
118
+ end
119
+
120
+ template =
121
+ if test(?e, 'gemspec.erb')
122
+ Template{ IO.read('gemspec.erb') }
123
+ else
124
+ Template {
125
+ <<-__
126
+ ## <%= lib %>.gemspec
127
+ #
128
+
129
+ Gem::Specification::new do |spec|
130
+ spec.name = <%= lib.inspect %>
131
+ spec.version = <%= version.inspect %>
132
+ spec.platform = Gem::Platform::RUBY
133
+ spec.summary = <%= lib.inspect %>
134
+ spec.description = <%= description.inspect %>
135
+
136
+ spec.files =\n<%= files.sort.pretty_inspect %>
137
+ spec.executables = <%= executables.inspect %>
138
+
139
+ spec.require_path = "lib"
140
+
141
+ spec.test_files = <%= test_files.inspect %>
142
+
143
+ <% dependencies.each do |lib_version| %>
144
+ spec.add_dependency(*<%= Array(lib_version).flatten.inspect %>)
145
+ <% end %>
146
+
147
+ spec.extensions.push(*<%= extensions.inspect %>)
148
+
149
+ spec.rubyforge_project = <%= This.rubyforge_project.inspect %>
150
+ spec.author = <%= This.author.inspect %>
151
+ spec.email = <%= This.email.inspect %>
152
+ spec.homepage = <%= This.homepage.inspect %>
153
+ end
154
+ __
155
+ }
156
+ end
157
+
158
+ Fu.mkdir_p(This.pkgdir)
159
+ gemspec = "#{ lib }.gemspec"
160
+ open(gemspec, "w"){|fd| fd.puts(template)}
161
+ This.gemspec = gemspec
162
+ end
163
+
164
+ task :gem => [:clean, :gemspec] do
165
+ Fu.mkdir_p(This.pkgdir)
166
+ before = Dir['*.gem']
167
+ cmd = "gem build #{ This.gemspec }"
168
+ `#{ cmd }`
169
+ after = Dir['*.gem']
170
+ gem = ((after - before).first || after.first) or abort('no gem!')
171
+ Fu.mv(gem, This.pkgdir)
172
+ This.gem = File.join(This.pkgdir, File.basename(gem))
173
+ end
174
+
175
+ task :readme do
176
+ samples = ''
177
+ prompt = '~ > '
178
+ lib = This.lib
179
+ version = This.version
180
+
181
+ Dir['sample*/*'].sort.each do |sample|
182
+ samples << "\n" << " <========< #{ sample } >========>" << "\n\n"
183
+
184
+ cmd = "cat #{ sample }"
185
+ samples << Util.indent(prompt + cmd, 2) << "\n\n"
186
+ samples << Util.indent(`#{ cmd }`, 4) << "\n"
187
+
188
+ cmd = "ruby #{ sample }"
189
+ samples << Util.indent(prompt + cmd, 2) << "\n\n"
190
+
191
+ cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'"
192
+ samples << Util.indent(`#{ cmd } 2>&1`, 4) << "\n"
193
+ end
194
+
195
+ template =
196
+ if test(?e, 'readme.erb')
197
+ Template{ IO.read('readme.erb') }
198
+ else
199
+ Template {
200
+ <<-__
201
+ NAME
202
+ #{ lib }
203
+
204
+ DESCRIPTION
205
+
206
+ INSTALL
207
+ gem install #{ lib }
208
+
209
+ SAMPLES
210
+ #{ samples }
211
+ __
212
+ }
213
+ end
214
+
215
+ open("README", "w"){|fd| fd.puts template}
216
+ end
217
+
218
+
219
+ task :clean do
220
+ Dir[File.join(This.pkgdir, '**/**')].each{|entry| Fu.rm_rf(entry)}
221
+ end
222
+
223
+
224
+ task :release => [:clean, :gemspec, :gem] do
225
+ gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
226
+ raise "which one? : #{ gems.inspect }" if gems.size > 1
227
+ raise "no gems?" if gems.size < 1
228
+
229
+ cmd = "gem push #{ This.gem }"
230
+ puts cmd
231
+ puts
232
+ system(cmd)
233
+ abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
234
+
235
+ cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.gem }"
236
+ puts cmd
237
+ puts
238
+ system(cmd)
239
+ abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
240
+ end
241
+
242
+
243
+
244
+
245
+
246
+ BEGIN {
247
+ # support for this rakefile
248
+ #
249
+ $VERBOSE = nil
250
+
251
+ require 'ostruct'
252
+ require 'erb'
253
+ require 'fileutils'
254
+ require 'rbconfig'
255
+ require 'pp'
256
+
257
+ # fu shortcut
258
+ #
259
+ Fu = FileUtils
260
+
261
+ # cache a bunch of stuff about this rakefile/environment
262
+ #
263
+ This = OpenStruct.new
264
+
265
+ This.file = File.expand_path(__FILE__)
266
+ This.dir = File.dirname(This.file)
267
+ This.pkgdir = File.join(This.dir, 'pkg')
268
+
269
+ # grok lib
270
+ #
271
+ lib = ENV['LIB']
272
+ unless lib
273
+ lib = File.basename(Dir.pwd).sub(/[-].*$/, '')
274
+ end
275
+ This.lib = lib
276
+
277
+ # grok version
278
+ #
279
+ version = ENV['VERSION']
280
+ unless version
281
+ require "./lib/#{ This.lib }"
282
+ This.name = lib.capitalize
283
+ This.object = eval(This.name)
284
+ version = This.object.send(:version)
285
+ end
286
+ This.version = version
287
+
288
+ # see if dependencies are export by the module
289
+ #
290
+ if This.object.respond_to?(:dependencies)
291
+ This.dependencies = This.object.dependencies
292
+ end
293
+
294
+ # we need to know the name of the lib an it's version
295
+ #
296
+ abort('no lib') unless This.lib
297
+ abort('no version') unless This.version
298
+
299
+ # discover full path to this ruby executable
300
+ #
301
+ c = RbConfig::CONFIG
302
+ bindir = c["bindir"] || c['BINDIR']
303
+ ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby'
304
+ ruby_ext = c['EXEEXT'] || ''
305
+ ruby = File.join(bindir, (ruby_install_name + ruby_ext))
306
+ This.ruby = ruby
307
+
308
+ # some utils
309
+ #
310
+ module Util
311
+ def indent(s, n = 2)
312
+ s = unindent(s)
313
+ ws = ' ' * n
314
+ s.gsub(%r/^/, ws)
315
+ end
316
+
317
+ def unindent(s)
318
+ indent = nil
319
+ s.each_line do |line|
320
+ next if line =~ %r/^\s*$/
321
+ indent = line[%r/^\s*/] and break
322
+ end
323
+ indent ? s.gsub(%r/^#{ indent }/, "") : s
324
+ end
325
+ extend self
326
+ end
327
+
328
+ # template support
329
+ #
330
+ class Template
331
+ def initialize(&block)
332
+ @block = block
333
+ @template = block.call.to_s
334
+ end
335
+ def expand(b=nil)
336
+ ERB.new(Util.unindent(@template)).result((b||@block).binding)
337
+ end
338
+ alias_method 'to_s', 'expand'
339
+ end
340
+ def Template(*args, &block) Template.new(*args, &block) end
341
+
342
+ # colored console output support
343
+ #
344
+ This.ansi = {
345
+ :clear => "\e[0m",
346
+ :reset => "\e[0m",
347
+ :erase_line => "\e[K",
348
+ :erase_char => "\e[P",
349
+ :bold => "\e[1m",
350
+ :dark => "\e[2m",
351
+ :underline => "\e[4m",
352
+ :underscore => "\e[4m",
353
+ :blink => "\e[5m",
354
+ :reverse => "\e[7m",
355
+ :concealed => "\e[8m",
356
+ :black => "\e[30m",
357
+ :red => "\e[31m",
358
+ :green => "\e[32m",
359
+ :yellow => "\e[33m",
360
+ :blue => "\e[34m",
361
+ :magenta => "\e[35m",
362
+ :cyan => "\e[36m",
363
+ :white => "\e[37m",
364
+ :on_black => "\e[40m",
365
+ :on_red => "\e[41m",
366
+ :on_green => "\e[42m",
367
+ :on_yellow => "\e[43m",
368
+ :on_blue => "\e[44m",
369
+ :on_magenta => "\e[45m",
370
+ :on_cyan => "\e[46m",
371
+ :on_white => "\e[47m"
372
+ }
373
+ def say(phrase, *args)
374
+ options = args.last.is_a?(Hash) ? args.pop : {}
375
+ options[:color] = args.shift.to_s.to_sym unless args.empty?
376
+ keys = options.keys
377
+ keys.each{|key| options[key.to_s.to_sym] = options.delete(key)}
378
+
379
+ color = options[:color]
380
+ bold = options.has_key?(:bold)
381
+
382
+ parts = [phrase]
383
+ parts.unshift(This.ansi[color]) if color
384
+ parts.unshift(This.ansi[:bold]) if bold
385
+ parts.push(This.ansi[:clear]) if parts.size > 1
386
+
387
+ method = options[:method] || :puts
388
+
389
+ Kernel.send(method, parts.join)
390
+ end
391
+
392
+ # always run out of the project dir
393
+ #
394
+ Dir.chdir(This.dir)
395
+ }
data/lib/mob.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Mob
2
+ def Mob.version() '0.0.0' end
3
+ end
data/mob.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ ## mob.gemspec
2
+ #
3
+
4
+ Gem::Specification::new do |spec|
5
+ spec.name = "mob"
6
+ spec.version = "0.0.0"
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.summary = "mob"
9
+ spec.description = "description: mob kicks the ass"
10
+
11
+ spec.files =
12
+ ["Rakefile", "lib", "lib/mob.rb", "mob.gemspec"]
13
+
14
+ spec.executables = []
15
+
16
+ spec.require_path = "lib"
17
+
18
+ spec.test_files = nil
19
+
20
+
21
+
22
+ spec.extensions.push(*[])
23
+
24
+ spec.rubyforge_project = "codeforpeople"
25
+ spec.author = "Ara T. Howard"
26
+ spec.email = "ara.t.howard@gmail.com"
27
+ spec.homepage = "https://github.com/ahoward/mob"
28
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mob
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ara T. Howard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! 'description: mob kicks the ass'
15
+ email: ara.t.howard@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Rakefile
21
+ - lib/mob.rb
22
+ - mob.gemspec
23
+ homepage: https://github.com/ahoward/mob
24
+ licenses: []
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project: codeforpeople
43
+ rubygems_version: 1.8.11
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: mob
47
+ test_files: []