tumblr2 0.4.2

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