fattr 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +27 -24
- data/{README.tmpl → README.erb} +6 -4
- data/Rakefile +241 -0
- data/fattr.gemspec +28 -0
- data/lib/fattr.rb +1 -1
- data/test/fattr.rb +128 -0
- metadata +14 -13
- data/gemspec.rb +0 -28
- data/gen_readme.rb +0 -32
- data/install.rb +0 -214
data/README
CHANGED
@@ -7,7 +7,6 @@ INSTALL
|
|
7
7
|
URIS
|
8
8
|
http://codeforpeople.com/lib/ruby
|
9
9
|
http://rubyforge.org/projects/codeforpeople/
|
10
|
-
http://codeforpeople.rubyforge.org/svn/
|
11
10
|
|
12
11
|
SYNOPSIS
|
13
12
|
fattr.rb is a "fatter attr" for ruby.
|
@@ -52,28 +51,6 @@ SYNOPSIS
|
|
52
51
|
|
53
52
|
all this in < 100 lines of code
|
54
53
|
|
55
|
-
HISTORY
|
56
|
-
1.0.2:
|
57
|
-
added Fattr shortcut for adding class/module level fattrs
|
58
|
-
|
59
|
-
class C
|
60
|
-
Fattr 'children' => []
|
61
|
-
|
62
|
-
def C.inherited other
|
63
|
-
(children << other).uniq!
|
64
|
-
super
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class B < C
|
69
|
-
end
|
70
|
-
|
71
|
-
p C.children #=> B
|
72
|
-
|
73
|
-
1.0.0:
|
74
|
-
port from attributes.rb retaining all the same features of that version of
|
75
|
-
attributes.rb
|
76
|
-
|
77
54
|
SAMPLES
|
78
55
|
|
79
56
|
<========< samples/a.rb >========>
|
@@ -237,7 +214,7 @@ SAMPLES
|
|
237
214
|
|
238
215
|
~ > ruby samples/e.rb
|
239
216
|
|
240
|
-
#<Config:
|
217
|
+
#<Config:0x2de88 @port=80, @host="codeforpeople.org">
|
241
218
|
|
242
219
|
|
243
220
|
<========< samples/f.rb >========>
|
@@ -296,3 +273,29 @@ SAMPLES
|
|
296
273
|
|
297
274
|
"42"
|
298
275
|
|
276
|
+
|
277
|
+
|
278
|
+
HISTORY
|
279
|
+
1.1.0:
|
280
|
+
ruby19 testing. move to github.
|
281
|
+
|
282
|
+
1.0.2:
|
283
|
+
added Fattr shortcut for adding class/module level fattrs
|
284
|
+
|
285
|
+
class C
|
286
|
+
Fattr 'children' => []
|
287
|
+
|
288
|
+
def C.inherited other
|
289
|
+
(children << other).uniq!
|
290
|
+
super
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
class B < C
|
295
|
+
end
|
296
|
+
|
297
|
+
p C.children #=> B
|
298
|
+
|
299
|
+
1.0.0:
|
300
|
+
port from attributes.rb retaining all the same features of that version of
|
301
|
+
attributes.rb
|
data/{README.tmpl → README.erb}
RENAMED
@@ -7,7 +7,6 @@ INSTALL
|
|
7
7
|
URIS
|
8
8
|
http://codeforpeople.com/lib/ruby
|
9
9
|
http://rubyforge.org/projects/codeforpeople/
|
10
|
-
http://codeforpeople.rubyforge.org/svn/
|
11
10
|
|
12
11
|
SYNOPSIS
|
13
12
|
fattr.rb is a "fatter attr" for ruby.
|
@@ -52,7 +51,13 @@ SYNOPSIS
|
|
52
51
|
|
53
52
|
all this in < 100 lines of code
|
54
53
|
|
54
|
+
SAMPLES
|
55
|
+
<%= samples %>
|
56
|
+
|
55
57
|
HISTORY
|
58
|
+
1.1.0:
|
59
|
+
ruby19 testing. move to github.
|
60
|
+
|
56
61
|
1.0.2:
|
57
62
|
added Fattr shortcut for adding class/module level fattrs
|
58
63
|
|
@@ -73,6 +78,3 @@ HISTORY
|
|
73
78
|
1.0.0:
|
74
79
|
port from attributes.rb retaining all the same features of that version of
|
75
80
|
attributes.rb
|
76
|
-
|
77
|
-
SAMPLES
|
78
|
-
@samples
|
data/Rakefile
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
This.author = "Ara T. Howard"
|
2
|
+
This.email = "ara.t.howard@gmail.com"
|
3
|
+
This.homepage = "http://github.com/ahoward/#{ This.lib }/tree/master"
|
4
|
+
This.rubyforge_project = 'codeforpeople'
|
5
|
+
|
6
|
+
task :default do
|
7
|
+
puts(Rake::Task.tasks.map{|task| task.name} - ['default'])
|
8
|
+
end
|
9
|
+
|
10
|
+
task :spec do
|
11
|
+
require 'spec/rake/spectask'
|
12
|
+
Spec::Rake::SpecTask.new do |t|
|
13
|
+
t.spec_files = FileList['spec/*_spec.rb']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :gemspec do
|
18
|
+
ignore_extensions = 'git', 'svn', 'tmp', /sw./, 'bak', 'gem'
|
19
|
+
ignore_directories = 'pkg'
|
20
|
+
ignore_files = 'test/log'
|
21
|
+
|
22
|
+
shiteless =
|
23
|
+
lambda do |list|
|
24
|
+
list.delete_if do |entry|
|
25
|
+
next unless test(?e, entry)
|
26
|
+
extension = File.basename(entry).split(%r/[.]/).last
|
27
|
+
ignore_extensions.any?{|ext| ext === extension}
|
28
|
+
end
|
29
|
+
list.delete_if do |entry|
|
30
|
+
next unless test(?d, entry)
|
31
|
+
dirname = File.expand_path(entry)
|
32
|
+
ignore_directories.any?{|dir| File.expand_path(dir) == dirname}
|
33
|
+
end
|
34
|
+
list.delete_if do |entry|
|
35
|
+
next unless test(?f, entry)
|
36
|
+
filename = File.expand_path(entry)
|
37
|
+
ignore_files.any?{|file| File.expand_path(file) == filename}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
lib = This.lib
|
42
|
+
version = This.version
|
43
|
+
files = shiteless[Dir::glob("**/**")]
|
44
|
+
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
45
|
+
has_rdoc = true #File.exist?('doc')
|
46
|
+
test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
|
47
|
+
|
48
|
+
extensions = This.extensions
|
49
|
+
if extensions.nil?
|
50
|
+
%w( Makefile configure extconf.rb ).each do |ext|
|
51
|
+
extensions << ext if File.exists?(ext)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
extensions = [extensions].flatten.compact
|
55
|
+
|
56
|
+
template =
|
57
|
+
if test(?e, 'gemspec.erb')
|
58
|
+
Template{ IO.read('gemspec.erb') }
|
59
|
+
else
|
60
|
+
Template {
|
61
|
+
<<-__
|
62
|
+
## #{ lib }.gemspec
|
63
|
+
#
|
64
|
+
|
65
|
+
Gem::Specification::new do |spec|
|
66
|
+
spec.name = #{ lib.inspect }
|
67
|
+
spec.version = #{ version.inspect }
|
68
|
+
spec.platform = Gem::Platform::RUBY
|
69
|
+
spec.summary = #{ lib.inspect }
|
70
|
+
|
71
|
+
spec.files = #{ files.inspect }
|
72
|
+
spec.executables = #{ executables.inspect }
|
73
|
+
|
74
|
+
<% if test(?d, 'lib') %>
|
75
|
+
spec.require_path = "lib"
|
76
|
+
<% end %>
|
77
|
+
|
78
|
+
spec.has_rdoc = #{ has_rdoc.inspect }
|
79
|
+
spec.test_files = #{ test_files.inspect }
|
80
|
+
#spec.add_dependency 'lib', '>= version'
|
81
|
+
#spec.add_dependency 'fattr'
|
82
|
+
|
83
|
+
spec.extensions.push(*#{ extensions.inspect })
|
84
|
+
|
85
|
+
spec.rubyforge_project = #{ This.rubyforge_project.inspect }
|
86
|
+
spec.author = #{ This.author.inspect }
|
87
|
+
spec.email = #{ This.email.inspect }
|
88
|
+
spec.homepage = #{ This.homepage.inspect }
|
89
|
+
end
|
90
|
+
__
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
open("#{ lib }.gemspec", "w"){|fd| fd.puts template}
|
95
|
+
This.gemspec = "#{ lib }.gemspec"
|
96
|
+
end
|
97
|
+
|
98
|
+
task :gem => [:clean, :gemspec] do
|
99
|
+
Fu.mkdir_p This.pkgdir
|
100
|
+
before = Dir['*.gem']
|
101
|
+
cmd = "gem build #{ This.gemspec }"
|
102
|
+
`#{ cmd }`
|
103
|
+
after = Dir['*.gem']
|
104
|
+
gem = ((after - before).first || after.first) or abort('no gem!')
|
105
|
+
Fu.mv gem, This.pkgdir
|
106
|
+
This.gem = File.basename(gem)
|
107
|
+
end
|
108
|
+
|
109
|
+
task :readme do
|
110
|
+
samples = ''
|
111
|
+
prompt = '~ > '
|
112
|
+
lib = This.lib
|
113
|
+
version = This.version
|
114
|
+
|
115
|
+
Dir['sample*/*'].sort.each do |sample|
|
116
|
+
samples << "\n" << " <========< #{ sample } >========>" << "\n\n"
|
117
|
+
|
118
|
+
cmd = "cat #{ sample }"
|
119
|
+
samples << Util.indent(prompt + cmd, 2) << "\n\n"
|
120
|
+
samples << Util.indent(`#{ cmd }`, 4) << "\n"
|
121
|
+
|
122
|
+
cmd = "ruby #{ sample }"
|
123
|
+
samples << Util.indent(prompt + cmd, 2) << "\n\n"
|
124
|
+
|
125
|
+
cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -Ilib #{ sample })'"
|
126
|
+
samples << Util.indent(`#{ cmd } 2>&1`, 4) << "\n"
|
127
|
+
end
|
128
|
+
|
129
|
+
template =
|
130
|
+
if test(?e, 'readme.erb')
|
131
|
+
Template{ IO.read('readme.erb') }
|
132
|
+
else
|
133
|
+
Template {
|
134
|
+
<<-__
|
135
|
+
NAME
|
136
|
+
#{ lib }
|
137
|
+
|
138
|
+
DESCRIPTION
|
139
|
+
|
140
|
+
INSTALL
|
141
|
+
gem install #{ lib }
|
142
|
+
|
143
|
+
SAMPLES
|
144
|
+
#{ samples }
|
145
|
+
__
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
open("README", "w"){|fd| fd.puts template}
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
task :clean do
|
154
|
+
Dir[File.join(This.pkgdir, '**/**')].each{|entry| Fu.rm_rf(entry)}
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
task :release => [:clean, :gemspec, :gem] do
|
159
|
+
gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
|
160
|
+
raise "which one? : #{ gems.inspect }" if gems.size > 1
|
161
|
+
raise "no gems?" if gems.size < 1
|
162
|
+
cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.pkgdir }/#{ This.gem }"
|
163
|
+
puts cmd
|
164
|
+
system cmd
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
BEGIN {
|
172
|
+
$VERBOSE = nil
|
173
|
+
|
174
|
+
require 'ostruct'
|
175
|
+
require 'erb'
|
176
|
+
require 'fileutils'
|
177
|
+
|
178
|
+
Fu = FileUtils
|
179
|
+
|
180
|
+
This = OpenStruct.new
|
181
|
+
|
182
|
+
This.file = File.expand_path(__FILE__)
|
183
|
+
This.dir = File.dirname(This.file)
|
184
|
+
This.pkgdir = File.join(This.dir, 'pkg')
|
185
|
+
|
186
|
+
lib = ENV['LIB']
|
187
|
+
unless lib
|
188
|
+
lib = File.basename(Dir.pwd)
|
189
|
+
end
|
190
|
+
This.lib = lib
|
191
|
+
|
192
|
+
version = ENV['VERSION']
|
193
|
+
unless version
|
194
|
+
name = lib.capitalize
|
195
|
+
library = "./lib/#{ lib }.rb"
|
196
|
+
program = "./bin/#{ lib }"
|
197
|
+
if test(?e, library)
|
198
|
+
require library
|
199
|
+
version = eval(name).send(:version)
|
200
|
+
elsif test(?e, program)
|
201
|
+
version = `#{ program } --version`.strip
|
202
|
+
end
|
203
|
+
abort('no version') if(version.nil? or version.empty?)
|
204
|
+
end
|
205
|
+
This.version = version
|
206
|
+
|
207
|
+
abort('no lib') unless This.lib
|
208
|
+
abort('no version') unless This.version
|
209
|
+
|
210
|
+
module Util
|
211
|
+
def indent(s, n = 2)
|
212
|
+
s = unindent(s)
|
213
|
+
ws = ' ' * n
|
214
|
+
s.gsub(%r/^/, ws)
|
215
|
+
end
|
216
|
+
|
217
|
+
def unindent(s)
|
218
|
+
indent = nil
|
219
|
+
s.each do |line|
|
220
|
+
next if line =~ %r/^\s*$/
|
221
|
+
indent = line[%r/^\s*/] and break
|
222
|
+
end
|
223
|
+
indent ? s.gsub(%r/^#{ indent }/, "") : s
|
224
|
+
end
|
225
|
+
extend self
|
226
|
+
end
|
227
|
+
|
228
|
+
class Template
|
229
|
+
def initialize(&block)
|
230
|
+
@block = block
|
231
|
+
@template = block.call.to_s
|
232
|
+
end
|
233
|
+
def expand(b=nil)
|
234
|
+
ERB.new(Util.unindent(@template)).result(b||@block)
|
235
|
+
end
|
236
|
+
alias_method 'to_s', 'expand'
|
237
|
+
end
|
238
|
+
def Template(*args, &block) Template.new(*args, &block) end
|
239
|
+
|
240
|
+
Dir.chdir(This.dir)
|
241
|
+
}
|
data/fattr.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## fattr.gemspec
|
2
|
+
#
|
3
|
+
|
4
|
+
Gem::Specification::new do |spec|
|
5
|
+
spec.name = "fattr"
|
6
|
+
spec.version = "1.1.0"
|
7
|
+
spec.platform = Gem::Platform::RUBY
|
8
|
+
spec.summary = "fattr"
|
9
|
+
|
10
|
+
spec.files = ["fattr.gemspec", "lib", "lib/fattr.rb", "Rakefile", "README", "README.erb", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb", "samples/g.rb", "test", "test/fattr.rb"]
|
11
|
+
spec.executables = []
|
12
|
+
|
13
|
+
|
14
|
+
spec.require_path = "lib"
|
15
|
+
|
16
|
+
|
17
|
+
spec.has_rdoc = true
|
18
|
+
spec.test_files = "test/fattr.rb"
|
19
|
+
#spec.add_dependency 'lib', '>= version'
|
20
|
+
#spec.add_dependency 'fattr'
|
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 = "http://github.com/ahoward/fattr/tree/master"
|
28
|
+
end
|
data/lib/fattr.rb
CHANGED
data/test/fattr.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'fattr'
|
2
|
+
|
3
|
+
Testing Fattr do
|
4
|
+
testing 'that a basic set of methods are defined' do
|
5
|
+
o = Class.new{ fattr :a }.new
|
6
|
+
%w( a a= a? ).each do |msg|
|
7
|
+
assert("respond_to?(#{ msg.inspect })"){ o.respond_to?(msg) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
testing 'that the basic usage works' do
|
12
|
+
o = Class.new{ fattr :a }.new
|
13
|
+
assert{ o.a==nil }
|
14
|
+
assert{ o.a=42 }
|
15
|
+
assert{ o.a(42.0) }
|
16
|
+
assert{ o.a? }
|
17
|
+
end
|
18
|
+
|
19
|
+
testing 'that simple defaults work' do
|
20
|
+
o = Class.new{ fattr :a => 42 }.new
|
21
|
+
assert{ o.a==42 }
|
22
|
+
end
|
23
|
+
|
24
|
+
testing 'that block defaults work' do
|
25
|
+
n = 41
|
26
|
+
o = Class.new{ fattr(:a){ n += 1 } }.new
|
27
|
+
assert{ o.a==42 }
|
28
|
+
assert{ n==42 }
|
29
|
+
end
|
30
|
+
|
31
|
+
testing 'that > 1 fattrs can be defined at once' do
|
32
|
+
o = Class.new{ fattr :a, :b }.new
|
33
|
+
%w( a a= a? b b= b? ).each do |msg|
|
34
|
+
assert("respond_to?(#{ msg.inspect })"){ o.respond_to?(msg) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
testing 'that > 1 fattrs with defaults can be defined at once' do
|
39
|
+
o = Class.new{ fattr :a => 40, :b => 2 }.new
|
40
|
+
assert{ o.a+o.b==42 }
|
41
|
+
end
|
42
|
+
|
43
|
+
testing 'that fattrs can be retrieved from the object' do
|
44
|
+
c = Class.new{ fattr :a, :b, :c; self }
|
45
|
+
assert{ c.fattrs.sort === %w[a b c] }
|
46
|
+
end
|
47
|
+
|
48
|
+
testing 'getters as setters' do
|
49
|
+
o = Class.new{ fattr :a }.new
|
50
|
+
assert{ o.a(42) }
|
51
|
+
assert{ o.a==42 }
|
52
|
+
end
|
53
|
+
|
54
|
+
testing 'module fattrs' do
|
55
|
+
m = Module.new{ class << self; fattr :a => 42; end; }
|
56
|
+
assert{ m.a==42 }
|
57
|
+
end
|
58
|
+
|
59
|
+
testing 'module fattr shortcut' do
|
60
|
+
m = Module.new{ Fattr :a => 42 }
|
61
|
+
assert{ m.a==42 }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
BEGIN {
|
72
|
+
require 'test/unit'
|
73
|
+
STDOUT.sync = true
|
74
|
+
$:.unshift 'lib'
|
75
|
+
$:.unshift '../lib'
|
76
|
+
$:.unshift '.'
|
77
|
+
|
78
|
+
def Testing(*args, &block)
|
79
|
+
Class.new(Test::Unit::TestCase) do
|
80
|
+
def self.slug_for(*args)
|
81
|
+
string = args.flatten.compact.join('-')
|
82
|
+
words = string.to_s.scan(%r/\w+/)
|
83
|
+
words.map!{|word| word.gsub %r/[^0-9a-zA-Z_-]/, ''}
|
84
|
+
words.delete_if{|word| word.nil? or word.strip.empty?}
|
85
|
+
words.join('-').downcase
|
86
|
+
end
|
87
|
+
|
88
|
+
@@testing_subclass_count = 0 unless defined?(@@testing_subclass_count)
|
89
|
+
@@testing_subclass_count += 1
|
90
|
+
slug = slug_for(*args).gsub(%r/-/,'_')
|
91
|
+
name = ['TESTING', '%03d' % @@testing_subclass_count, slug].delete_if{|part| part.empty?}.join('_')
|
92
|
+
name = name.upcase!
|
93
|
+
const_set(:Name, name)
|
94
|
+
def self.name() const_get(:Name) end
|
95
|
+
|
96
|
+
def self.testno()
|
97
|
+
'%05d' % (@testno ||= 0)
|
98
|
+
ensure
|
99
|
+
@testno += 1
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.testing(*args, &block)
|
103
|
+
method = ["test", testno, slug_for(*args)].delete_if{|part| part.empty?}.join('_')
|
104
|
+
define_method("test_#{ testno }_#{ slug_for(*args) }", &block)
|
105
|
+
end
|
106
|
+
|
107
|
+
alias_method '__assert__', 'assert'
|
108
|
+
|
109
|
+
def assert(*args, &block)
|
110
|
+
if block
|
111
|
+
label = "assert(#{ args.join ' ' })"
|
112
|
+
result = nil
|
113
|
+
assert_nothing_raised{ result = block.call }
|
114
|
+
__assert__(result, label)
|
115
|
+
result
|
116
|
+
else
|
117
|
+
result = args.shift
|
118
|
+
label = "assert(#{ args.join ' ' })"
|
119
|
+
__assert__(result, label)
|
120
|
+
result
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
module_eval &block
|
125
|
+
self
|
126
|
+
end
|
127
|
+
end
|
128
|
+
}
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ara T. Howard
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-09-28 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,13 +22,12 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- gemspec
|
26
|
-
- gen_readme.rb
|
27
|
-
- install.rb
|
25
|
+
- fattr.gemspec
|
28
26
|
- lib
|
29
27
|
- lib/fattr.rb
|
28
|
+
- Rakefile
|
30
29
|
- README
|
31
|
-
- README.
|
30
|
+
- README.erb
|
32
31
|
- samples
|
33
32
|
- samples/a.rb
|
34
33
|
- samples/b.rb
|
@@ -37,8 +36,10 @@ files:
|
|
37
36
|
- samples/e.rb
|
38
37
|
- samples/f.rb
|
39
38
|
- samples/g.rb
|
40
|
-
|
41
|
-
|
39
|
+
- test
|
40
|
+
- test/fattr.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/ahoward/fattr/tree/master
|
42
43
|
post_install_message:
|
43
44
|
rdoc_options: []
|
44
45
|
|
@@ -58,10 +59,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
59
|
version:
|
59
60
|
requirements: []
|
60
61
|
|
61
|
-
rubyforge_project:
|
62
|
-
rubygems_version: 1.
|
62
|
+
rubyforge_project: codeforpeople
|
63
|
+
rubygems_version: 1.3.1
|
63
64
|
signing_key:
|
64
65
|
specification_version: 2
|
65
66
|
summary: fattr
|
66
|
-
test_files:
|
67
|
-
|
67
|
+
test_files:
|
68
|
+
- test/fattr.rb
|
data/gemspec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
lib, version = File::basename(File::dirname(File::expand_path(__FILE__))).split %r/-/, 2
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
|
6
|
-
Gem::Specification::new do |spec|
|
7
|
-
$VERBOSE = nil
|
8
|
-
spec.name = lib
|
9
|
-
spec.version = version
|
10
|
-
spec.platform = Gem::Platform::RUBY
|
11
|
-
spec.summary = lib
|
12
|
-
|
13
|
-
spec.files = Dir::glob "**/**"
|
14
|
-
spec.executables = Dir::glob("bin/*").map{|exe| File::basename exe}
|
15
|
-
|
16
|
-
spec.require_path = "lib"
|
17
|
-
spec.autorequire = lib
|
18
|
-
|
19
|
-
spec.has_rdoc = File::exist? "doc"
|
20
|
-
spec.test_suite_file = "test/#{ lib }.rb" if File::directory? "test"
|
21
|
-
#spec.add_dependency 'pervasives', '>= 1.0'
|
22
|
-
|
23
|
-
spec.extensions << "extconf.rb" if File::exists? "extconf.rb"
|
24
|
-
|
25
|
-
spec.author = "Ara T. Howard"
|
26
|
-
spec.email = "ara.t.howard@gmail.com"
|
27
|
-
spec.homepage = "http://codeforpeople.com/lib/ruby/#{ lib }/"
|
28
|
-
end
|
data/gen_readme.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
|
3
|
-
$VERBOSE=nil
|
4
|
-
|
5
|
-
def indent s, n = 2
|
6
|
-
ws = ' ' * n
|
7
|
-
s.gsub %r/^/, ws
|
8
|
-
end
|
9
|
-
|
10
|
-
template = IO::read 'README.tmpl'
|
11
|
-
|
12
|
-
samples = ''
|
13
|
-
prompt = '~ > '
|
14
|
-
|
15
|
-
Dir['sample*/*'] .each do |sample|
|
16
|
-
samples << "\n" << " <========< #{ sample } >========>" << "\n\n"
|
17
|
-
|
18
|
-
cmd = "cat #{ sample }"
|
19
|
-
samples << indent(prompt + cmd, 2) << "\n\n"
|
20
|
-
samples << indent(`#{ cmd }`, 4) << "\n"
|
21
|
-
|
22
|
-
cmd = "ruby #{ sample }"
|
23
|
-
samples << indent(prompt + cmd, 2) << "\n\n"
|
24
|
-
|
25
|
-
cmd = "ruby -Ilib #{ sample }"
|
26
|
-
samples << indent(`#{ cmd } 2>&1`, 4) << "\n"
|
27
|
-
end
|
28
|
-
|
29
|
-
#samples.gsub! %r/^/, ' '
|
30
|
-
|
31
|
-
readme = template.gsub %r/^\s*@samples\s*$/, samples
|
32
|
-
print readme
|
data/install.rb
DELETED
@@ -1,214 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rbconfig'
|
3
|
-
require 'find'
|
4
|
-
require 'ftools'
|
5
|
-
require 'tempfile'
|
6
|
-
include Config
|
7
|
-
|
8
|
-
LIBDIR = "lib"
|
9
|
-
LIBDIR_MODE = 0644
|
10
|
-
|
11
|
-
BINDIR = "bin"
|
12
|
-
BINDIR_MODE = 0755
|
13
|
-
|
14
|
-
|
15
|
-
$srcdir = CONFIG["srcdir"]
|
16
|
-
$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
17
|
-
$libdir = File.join(CONFIG["libdir"], "ruby", $version)
|
18
|
-
$archdir = File.join($libdir, CONFIG["arch"])
|
19
|
-
$site_libdir = $:.find {|x| x =~ /site_ruby$/}
|
20
|
-
$bindir = CONFIG["bindir"] || CONFIG['BINDIR']
|
21
|
-
$ruby_install_name = CONFIG['ruby_install_name'] || CONFIG['RUBY_INSTALL_NAME'] || 'ruby'
|
22
|
-
$ruby_ext = CONFIG['EXEEXT'] || ''
|
23
|
-
$ruby = File.join($bindir, ($ruby_install_name + $ruby_ext))
|
24
|
-
|
25
|
-
if !$site_libdir
|
26
|
-
$site_libdir = File.join($libdir, "site_ruby")
|
27
|
-
elsif $site_libdir !~ %r/#{Regexp.quote($version)}/
|
28
|
-
$site_libdir = File.join($site_libdir, $version)
|
29
|
-
end
|
30
|
-
|
31
|
-
def install_rb(srcdir=nil, destdir=nil, mode=nil, bin=nil)
|
32
|
-
#{{{
|
33
|
-
path = []
|
34
|
-
dir = []
|
35
|
-
Find.find(srcdir) do |f|
|
36
|
-
next unless FileTest.file?(f)
|
37
|
-
next if (f = f[srcdir.length+1..-1]) == nil
|
38
|
-
next if (/CVS$/ =~ File.dirname(f))
|
39
|
-
next if (/\.svn/ =~ File.dirname(f))
|
40
|
-
next if f =~ %r/\.lnk/
|
41
|
-
next if f =~ %r/\.svn/
|
42
|
-
next if f =~ %r/\.swp/
|
43
|
-
next if f =~ %r/\.svn/
|
44
|
-
path.push f
|
45
|
-
dir |= [File.dirname(f)]
|
46
|
-
end
|
47
|
-
for f in dir
|
48
|
-
next if f == "."
|
49
|
-
next if f == "CVS"
|
50
|
-
File::makedirs(File.join(destdir, f))
|
51
|
-
end
|
52
|
-
for f in path
|
53
|
-
next if (/\~$/ =~ f)
|
54
|
-
next if (/^\./ =~ File.basename(f))
|
55
|
-
unless bin
|
56
|
-
File::install(File.join(srcdir, f), File.join(destdir, f), mode, true)
|
57
|
-
else
|
58
|
-
from = File.join(srcdir, f)
|
59
|
-
to = File.join(destdir, f)
|
60
|
-
shebangify(from) do |sf|
|
61
|
-
$deferr.print from, " -> ", File::catname(from, to), "\n"
|
62
|
-
$deferr.printf "chmod %04o %s\n", mode, to
|
63
|
-
File::install(sf, to, mode, false)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
#}}}
|
68
|
-
end
|
69
|
-
def shebangify f
|
70
|
-
#{{{
|
71
|
-
open(f) do |fd|
|
72
|
-
buf = fd.read 42
|
73
|
-
if buf =~ %r/^\s*#\s*!.*ruby/o
|
74
|
-
ftmp = Tempfile::new("#{ $$ }_#{ File::basename(f) }")
|
75
|
-
begin
|
76
|
-
fd.rewind
|
77
|
-
ftmp.puts "#!#{ $ruby }"
|
78
|
-
while((buf = fd.read(8192)))
|
79
|
-
ftmp.write buf
|
80
|
-
end
|
81
|
-
ftmp.close
|
82
|
-
yield ftmp.path
|
83
|
-
ensure
|
84
|
-
ftmp.close!
|
85
|
-
end
|
86
|
-
else
|
87
|
-
yield f
|
88
|
-
end
|
89
|
-
end
|
90
|
-
#}}}
|
91
|
-
end
|
92
|
-
def ARGV.switch
|
93
|
-
#{{{
|
94
|
-
return nil if self.empty?
|
95
|
-
arg = self.shift
|
96
|
-
return nil if arg == '--'
|
97
|
-
if arg =~ /^-(.)(.*)/
|
98
|
-
return arg if $1 == '-'
|
99
|
-
raise 'unknown switch "-"' if $2.index('-')
|
100
|
-
self.unshift "-#{$2}" if $2.size > 0
|
101
|
-
"-#{$1}"
|
102
|
-
else
|
103
|
-
self.unshift arg
|
104
|
-
nil
|
105
|
-
end
|
106
|
-
#}}}
|
107
|
-
end
|
108
|
-
def ARGV.req_arg
|
109
|
-
#{{{
|
110
|
-
self.shift || raise('missing argument')
|
111
|
-
#}}}
|
112
|
-
end
|
113
|
-
def linkify d, linked = []
|
114
|
-
#--{{{
|
115
|
-
if test ?d, d
|
116
|
-
versioned = Dir[ File::join(d, "*-[0-9].[0-9].[0-9].rb") ]
|
117
|
-
versioned.each do |v|
|
118
|
-
src, dst = v, v.gsub(%r/\-[\d\.]+\.rb$/, '.rb')
|
119
|
-
lnk = nil
|
120
|
-
begin
|
121
|
-
if test ?l, dst
|
122
|
-
lnk = "#{ dst }.lnk"
|
123
|
-
puts "#{ dst } -> #{ lnk }"
|
124
|
-
File::rename dst, lnk
|
125
|
-
end
|
126
|
-
unless test ?e, dst
|
127
|
-
puts "#{ src } -> #{ dst }"
|
128
|
-
File::copy src, dst
|
129
|
-
linked << dst
|
130
|
-
end
|
131
|
-
ensure
|
132
|
-
if lnk
|
133
|
-
at_exit do
|
134
|
-
puts "#{ lnk } -> #{ dst }"
|
135
|
-
File::rename lnk, dst
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
linked
|
142
|
-
#--}}}
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
#
|
147
|
-
# main program
|
148
|
-
#
|
149
|
-
|
150
|
-
libdir = $site_libdir
|
151
|
-
bindir = $bindir
|
152
|
-
no_linkify = false
|
153
|
-
linked = nil
|
154
|
-
help = false
|
155
|
-
|
156
|
-
usage = <<-usage
|
157
|
-
#{ File::basename $0 }
|
158
|
-
-d, --destdir <destdir>
|
159
|
-
-l, --libdir <libdir>
|
160
|
-
-b, --bindir <bindir>
|
161
|
-
-r, --ruby <ruby>
|
162
|
-
-n, --no_linkify
|
163
|
-
-s, --sudo
|
164
|
-
-h, --help
|
165
|
-
usage
|
166
|
-
|
167
|
-
begin
|
168
|
-
while switch = ARGV.switch
|
169
|
-
case switch
|
170
|
-
when '-d', '--destdir'
|
171
|
-
libdir = ARGV.req_arg
|
172
|
-
when '-l', '--libdir'
|
173
|
-
libdir = ARGV.req_arg
|
174
|
-
when '-b', '--bindir'
|
175
|
-
bindir = ARGV.req_arg
|
176
|
-
when '-r', '--ruby'
|
177
|
-
$ruby = ARGV.req_arg
|
178
|
-
when '-n', '--no_linkify'
|
179
|
-
no_linkify = true
|
180
|
-
when '-s', '--sudo'
|
181
|
-
sudo = 'sudo'
|
182
|
-
when '-h', '--help'
|
183
|
-
help = true
|
184
|
-
else
|
185
|
-
raise "unknown switch #{switch.dump}"
|
186
|
-
end
|
187
|
-
end
|
188
|
-
rescue
|
189
|
-
STDERR.puts $!.to_s
|
190
|
-
STDERR.puts usage
|
191
|
-
exit 1
|
192
|
-
end
|
193
|
-
|
194
|
-
if help
|
195
|
-
STDOUT.puts usage
|
196
|
-
exit
|
197
|
-
end
|
198
|
-
|
199
|
-
system "#{ sudo } #{ $ruby } pre-install.rb" if test(?s, 'pre-install.rb')
|
200
|
-
|
201
|
-
unless no_linkify
|
202
|
-
linked = linkify('lib') + linkify('bin')
|
203
|
-
end
|
204
|
-
|
205
|
-
system "#{ $ruby } extconf.rb && make && #{ sudo } make install" if test(?s, 'extconf.rb')
|
206
|
-
|
207
|
-
install_rb(LIBDIR, libdir, LIBDIR_MODE)
|
208
|
-
install_rb(BINDIR, bindir, BINDIR_MODE, bin=true)
|
209
|
-
|
210
|
-
if linked
|
211
|
-
linked.each{|path| File::rm_f path}
|
212
|
-
end
|
213
|
-
|
214
|
-
system "#{ sudo } #{ $ruby } post-install.rb" if test(?s, 'post-install.rb')
|