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