facets 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/WHATSNEW +11 -0
- data/lib/core/facets/enumerable/collect.rb +7 -2
- data/lib/core/facets/enumerable/permutation.rb +7 -26
- data/lib/core/facets/module/alias.rb +36 -12
- data/lib/core/facets/module/attr.rb +83 -35
- data/lib/core/facets/module/include.rb +10 -0
- data/lib/methods/facets/module/alias_accessor.rb +1 -1
- data/lib/methods/facets/module/alias_reader.rb +1 -0
- data/lib/methods/facets/module/alias_setter.rb +1 -0
- data/lib/methods/facets/module/alias_switcher.rb +1 -0
- data/lib/methods/facets/module/alias_tester.rb +1 -0
- data/lib/methods/facets/module/alias_toggler.rb +1 -0
- data/lib/methods/facets/module/alias_validator.rb +1 -0
- data/lib/methods/facets/module/alias_writer.rb +1 -0
- data/lib/methods/facets/module/attr_accessor.rb +1 -0
- data/lib/methods/facets/module/attr_reader.rb +1 -0
- data/lib/methods/facets/module/attr_switcher.rb +1 -0
- data/lib/methods/facets/module/attr_writer.rb +1 -0
- data/lib/more/facets/arguments.rb +2 -1
- data/lib/more/facets/command.rb +258 -395
- data/lib/more/facets/crypt.rb +242 -28
- data/lib/more/facets/ziputils.rb +1 -1
- data/log/changelog.txt +0 -0
- data/log/history.txt +22 -0
- data/log/release.txt +10 -0
- data/log/todo.txt +4 -0
- data/meta/{facets-2.0.5.roll → facets-2.1.0.roll} +0 -0
- data/meta/google_ad.html +15 -0
- data/meta/icli.yaml +3 -3
- data/meta/manifest.txt +24 -3
- data/task/clobber/package +10 -0
- data/task/config/general.yaml +21 -3
- data/task/isotest +2 -1
- data/task/loadtest +2 -0
- data/task/prepare +4 -2
- data/task/rdoc +122 -73
- data/task/release +12 -0
- data/task/special/quickopts +15 -0
- data/task/syntax +2 -0
- data/task/test +3 -1
- data/test/unit/enumerable/test_collect.rb +17 -0
- data/test/unit/enumerable/test_permutation.rb +20 -30
- data/test/unit/test_crypt.rb +29 -36
- metadata +40 -12
- data/RELEASE +0 -12
- data/test/unit/test_command.rb +0 -286
data/task/config/general.yaml
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
---
|
2
2
|
|
3
|
-
rdoc:
|
4
|
-
title : Facets
|
5
|
-
|
6
3
|
methods:
|
7
4
|
source : lib/core/facets
|
8
5
|
output : lib/methods/facets
|
@@ -19,6 +16,27 @@ test:
|
|
19
16
|
- lib/core
|
20
17
|
- lib/more
|
21
18
|
|
19
|
+
rdoc:
|
20
|
+
- title : Facets
|
21
|
+
main : README
|
22
|
+
chdir : lib/core
|
23
|
+
output : doc/rdoc/core
|
24
|
+
- title : Facets
|
25
|
+
chdir : lib/more
|
26
|
+
output : doc/rdoc
|
27
|
+
groups :
|
28
|
+
- [ facets/annotations.rb, facets/settings.rb ]
|
29
|
+
- [ facets/aop.rb, facets/cut.rb ]
|
30
|
+
- [ facets/buildable.rb, facets/buildingblock.rb, facets/hashbuilder.rb ]
|
31
|
+
- [ facets/command.rb, facets/arguments.rb, facets/ansicode.rb ] # facets/bbcode.rb
|
32
|
+
- [ facets/dictionary.rb, facets/orderedhash.rb ]
|
33
|
+
- [ facets/fileable.rb, facets/filelist.rb, facets/pathlist.rb, facets/fileshell.rb ]
|
34
|
+
- [ facets/heap.rb, facets/pqueue.rb ]
|
35
|
+
- [ facets/openobject.rb, facets/opencascade.rb, facets/opencollection.rb, facets/ostruct.rb ]
|
36
|
+
- [ facets/syncarray.rb, facets/synchash.rb ]
|
37
|
+
|
38
|
+
ad_file: meta/google_ad.html
|
39
|
+
|
22
40
|
# announce:
|
23
41
|
# template : README
|
24
42
|
# to : transfire@gmail.com #ruby-talk@ruby-lang.org
|
data/task/isotest
CHANGED
data/task/loadtest
CHANGED
data/task/prepare
CHANGED
data/task/rdoc
CHANGED
@@ -7,108 +7,157 @@
|
|
7
7
|
|
8
8
|
# NOTE: THIS IS SPECIALLY WRITTEN FOR FACETS!!!
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
config = {
|
14
|
-
'template' => 'html',
|
15
|
-
'merge' => true,
|
16
|
-
'inline-source' => true
|
17
|
-
}.update(config)
|
18
|
-
|
19
|
-
site = config.delete('op') || 'doc/rdoc'
|
10
|
+
main :rdoc => [ :rdoc_all ] do
|
11
|
+
puts "RDoc complete."
|
12
|
+
end
|
20
13
|
|
21
|
-
|
14
|
+
task :rdoc_all do
|
15
|
+
# Load RDoc configuration.
|
16
|
+
configs = configuration['rdoc']
|
17
|
+
configs = [configs] unless Array===configs
|
22
18
|
|
23
|
-
|
24
|
-
|
19
|
+
configs.each do |config|
|
20
|
+
if config['groups']
|
21
|
+
rdoc_groups(config)
|
22
|
+
else
|
23
|
+
rdoc_target(config)
|
24
|
+
end
|
25
|
+
end
|
25
26
|
end
|
26
27
|
|
28
|
+
# Docuement groups of targets.
|
27
29
|
|
28
|
-
|
30
|
+
def rdoc_groups(config)
|
31
|
+
site = config.delete('output') || config.delete('op') || 'doc/rdoc'
|
32
|
+
tdir = config['chdir']
|
29
33
|
|
30
|
-
|
34
|
+
groups = config.delete('groups')
|
35
|
+
groups = TrueClass===groups ? [] : groups
|
31
36
|
|
37
|
+
# the rest
|
38
|
+
rest = []
|
39
|
+
chdir(tdir){rest=glob('**/*').select{|f| File.file?(f)}}
|
40
|
+
rest = rest - groups.flatten
|
41
|
+
groups.concat(rest.collect{ |r| [r] })
|
32
42
|
|
33
|
-
|
43
|
+
title = config['title'].to_s
|
34
44
|
|
35
|
-
|
45
|
+
# rdoc each group
|
46
|
+
groups.each do |group|
|
47
|
+
gf1st = File.basename(group.first)
|
48
|
+
gname = gf1st.chomp(File.extname(gf1st))
|
49
|
+
gsite = File.join(site,gname)
|
50
|
+
gtitle = "#{title} #{gname.capitalize}".strip
|
36
51
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
single = ARGV[0]
|
41
|
-
|
42
|
-
# Just do the one requested.
|
43
|
-
if targets.keys.include?(single)
|
44
|
-
targets = { single => targets[single] }
|
45
|
-
single_site = File.join(site, single)
|
46
|
-
# Remove just the one doc directory.
|
47
|
-
rm_r(single_site) if dir?(single_site) and safe?(single_site)
|
48
|
-
else
|
49
|
-
# Remove all old rdocs.
|
50
|
-
rm_r(site) if dir?(site) and safe?(site)
|
52
|
+
gconfig = config.merge('title' => gtitle, 'op' => gsite, 'files' => group)
|
53
|
+
|
54
|
+
rdoc_target(gconfig)
|
51
55
|
end
|
56
|
+
end
|
52
57
|
|
53
|
-
|
54
|
-
targets.each do |name, options|
|
55
|
-
tgdir = options.delete('chdir')
|
56
|
-
files = options.delete('files')
|
58
|
+
# Document target.
|
57
59
|
|
58
|
-
|
60
|
+
def rdoc_target(config)
|
61
|
+
config = {
|
62
|
+
'template' => 'html',
|
63
|
+
'merge' => true,
|
64
|
+
'inline-source' => true,
|
65
|
+
'files' => '**/*'
|
66
|
+
}.merge(config)
|
59
67
|
|
60
|
-
|
61
|
-
|
68
|
+
site = config.delete('output') || config.delete('op') || 'doc/rdoc'
|
69
|
+
tgdir = config.delete('chdir')
|
70
|
+
files = config.delete('files')
|
62
71
|
|
63
|
-
|
64
|
-
'op' => outdir,
|
65
|
-
'title' => title
|
66
|
-
)
|
72
|
+
config['op'] = File.expand_path(site)
|
67
73
|
|
68
|
-
|
69
|
-
vector = [files, config] #.flatten.compact
|
74
|
+
config['main'] = File.expand_path(config['main']) if config['main']
|
70
75
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
76
|
+
# Helps to ensure we're in the right place.
|
77
|
+
#dir!(File.dirname(site))
|
78
|
+
|
79
|
+
# Remove all old rdocs.
|
80
|
+
rm_r(site) if dir?(site) and safe?(site)
|
81
|
+
|
82
|
+
# Prepare command arguments.
|
83
|
+
vector = [files, config] #.flatten.compact
|
84
|
+
|
85
|
+
# Create Documentation.
|
86
|
+
cd(tgdir) do
|
87
|
+
rdoc(vector.to_console)
|
75
88
|
end
|
76
89
|
|
90
|
+
insert_ads(site)
|
77
91
|
end
|
78
92
|
|
93
|
+
# Insert ads.
|
79
94
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
google_ad_format = "234x60_as";
|
87
|
-
google_ad_type = "text_image";
|
88
|
-
//2007-08-31: facets
|
89
|
-
google_ad_channel = "2923120207";
|
90
|
-
//-->
|
91
|
-
</script>
|
92
|
-
<script type="text/javascript"
|
93
|
-
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
94
|
-
</script>
|
95
|
-
</div>
|
96
|
-
END
|
97
|
-
|
98
|
-
|
99
|
-
task :insert_ads do
|
100
|
-
puts
|
101
|
-
dirs = Dir.glob(File.join(site,'*'))
|
95
|
+
def insert_ads(site)
|
96
|
+
adfile = configuration['ad_file'] || 'meta/site_ad.html'
|
97
|
+
return unless adfile && File.file?(adfile)
|
98
|
+
adtext = File.read(adfile)
|
99
|
+
#puts
|
100
|
+
dirs = Dir.glob(File.join(site,'*/'))
|
102
101
|
dirs.each do |dir|
|
103
|
-
files = Dir.glob(File.join(dir,
|
104
|
-
files += Dir.glob(File.join(dir,'files', '**/*.html'))
|
102
|
+
files = Dir.glob(File.join(dir, '**/*.html'))
|
105
103
|
files.each do |file|
|
106
104
|
html = file_read(file)
|
107
105
|
bodi = html.index('<body>')
|
108
|
-
html[bodi + 7] = "\n" +
|
106
|
+
html[bodi + 7] = "\n" + adtext
|
109
107
|
#print "Augmenting #{file}..."
|
110
108
|
file_write(file, html) unless dryrun?
|
111
109
|
#puts "[done]"
|
112
110
|
end
|
113
111
|
end
|
114
112
|
end
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# Build RDoc's for each target,
|
118
|
+
|
119
|
+
# task :rdoc_targets do
|
120
|
+
#
|
121
|
+
# #targets.each do |name, files|
|
122
|
+
# # targets[name] = files.split(/\s+/) if String===files
|
123
|
+
# #end
|
124
|
+
#
|
125
|
+
#
|
126
|
+
# # single = ARGV[0]
|
127
|
+
#
|
128
|
+
# # # Just do the one requested.
|
129
|
+
# # if targets.keys.include?(single)
|
130
|
+
# # targets = { single => targets[single] }
|
131
|
+
# # single_site = File.join(site, single)
|
132
|
+
# # # Remove just the one doc directory.
|
133
|
+
# # rm_r(single_site) if dir?(single_site) and safe?(single_site)
|
134
|
+
# # else
|
135
|
+
# # # Remove all old rdocs.
|
136
|
+
# # rm_r(site) if dir?(site) and safe?(site)
|
137
|
+
# # end
|
138
|
+
#
|
139
|
+
# # Document each target.
|
140
|
+
# targets.each do |name, options|
|
141
|
+
# tgdir = options.delete('chdir')
|
142
|
+
# files = options.delete('files')
|
143
|
+
#
|
144
|
+
# #files.collect!{|f| "lib/more/facets/#{f}" }
|
145
|
+
#
|
146
|
+
# outdir = File.expand_path(File.join(site, name.gsub(' ','')))
|
147
|
+
# title = "Facets #{name.capitalize}"
|
148
|
+
#
|
149
|
+
# config = config.merge(
|
150
|
+
# 'op' => outdir,
|
151
|
+
# 'title' => title
|
152
|
+
# )
|
153
|
+
#
|
154
|
+
# # Prepare command arguments.
|
155
|
+
# vector = [files, config] #.flatten.compact
|
156
|
+
#
|
157
|
+
# # Create Documentation.
|
158
|
+
# cd(tgdir) do
|
159
|
+
# rdoc(vector.to_params)
|
160
|
+
# end
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
# end
|
data/task/release
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ratch
|
2
|
+
|
3
|
+
# generate quick options .html part
|
4
|
+
|
5
|
+
main :quickopts do
|
6
|
+
str = ''
|
7
|
+
cd('doc/rdoc') do
|
8
|
+
dirs = Dir.glob('*') - ['core']
|
9
|
+
dirs.each do |f|
|
10
|
+
str << %{ <option value="#{f}"> #{f.capitalize} </option> \n}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
File.open('doc/siteparts/quickopts.html', 'w'){ |f| f << str }
|
14
|
+
end
|
15
|
+
|
data/task/syntax
CHANGED
data/task/test
CHANGED
@@ -40,6 +40,18 @@ class TestEnumerable < Test::Unit::TestCase
|
|
40
40
|
assert_equal( [1,2,4], a )
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_injecting
|
44
|
+
r = [1,2,3,4,5].injecting([]){ |a,i| a << i % 2 }
|
45
|
+
e = [1,0,1,0,1]
|
46
|
+
assert_equal(e, r)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_injecting_equal
|
50
|
+
r = [].injecting([]){ |a,i| a << i % 2 }
|
51
|
+
e = []
|
52
|
+
assert_equal(e, r)
|
53
|
+
end
|
54
|
+
|
43
55
|
# def test_op_mod
|
44
56
|
# a = [:A,:B,:C]
|
45
57
|
# assert_equal( a[1], a/1 )
|
@@ -79,6 +91,11 @@ class TestEnumerable < Test::Unit::TestCase
|
|
79
91
|
assert_equal(r, h.cluster_by{|k, v| v%2}.each{|a| a.sort!})
|
80
92
|
end
|
81
93
|
|
94
|
+
def test_cluster_by_empty
|
95
|
+
r = [].cluster_by{ |a| a }
|
96
|
+
assert_equal([], r)
|
97
|
+
end
|
98
|
+
|
82
99
|
def test_each_by_01
|
83
100
|
x = []
|
84
101
|
[1,2,3,4].each_by{ |a,b| x << [a,b] }
|
@@ -1,32 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
class TestEnumerablePermutation < Test::Unit::TestCase
|
21
|
-
|
22
|
-
def test_permutation
|
23
|
-
o = Set.new
|
24
|
-
%w[a b c].each_permutation { |x| o << x.join('') }
|
25
|
-
r = Set.new(['abc','acb','bac','bca','cab','cba'])
|
26
|
-
assert_equal( r, o )
|
27
|
-
end
|
28
|
-
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for facets/enumerable/permutation.rb
|
8
|
+
|
9
|
+
require 'facets/enumerable/permutation.rb'
|
10
|
+
require 'test/unit'
|
11
|
+
require 'set'
|
12
|
+
|
13
|
+
class TestEnumerablePermutation < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_permutation
|
16
|
+
o = Set.new
|
17
|
+
%w[a b c].each_permutation { |x| o << x.join('') }
|
18
|
+
r = Set.new(['abc','acb','bac','bca','cab','cba'])
|
19
|
+
assert_equal( r, o )
|
29
20
|
end
|
30
21
|
|
31
|
-
|
32
|
-
|
22
|
+
end
|
data/test/unit/test_crypt.rb
CHANGED
@@ -1,48 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for facets/crypt.rb
|
12
8
|
|
13
|
-
|
9
|
+
require 'facets/crypt.rb'
|
14
10
|
|
11
|
+
require "test/unit"
|
15
12
|
|
13
|
+
class CryptTest < Test::Unit::TestCase
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def array_test(arr, algo)
|
22
|
-
arr.each do |password, hash|
|
23
|
-
assert(Crypt.check(password, hash, algo))
|
24
|
-
end
|
15
|
+
def array_test(arr, algo)
|
16
|
+
arr.each do |password, hash|
|
17
|
+
assert(Crypt.check(password, hash, algo))
|
25
18
|
end
|
19
|
+
end
|
26
20
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
21
|
+
def test_md5
|
22
|
+
a = [ [' ', '$1$yiiZbNIH$YiCsHZjcTkYd31wkgW8JF.'],
|
23
|
+
['pass', '$1$YeNsbWdH$wvOF8JdqsoiLix754LTW90'],
|
24
|
+
['____fifteen____', '$1$s9lUWACI$Kk1jtIVVdmT01p0z3b/hw1'],
|
25
|
+
['____sixteen_____', '$1$dL3xbVZI$kkgqhCanLdxODGq14g/tW1'],
|
26
|
+
['____seventeen____', '$1$NaH5na7J$j7y8Iss0hcRbu3kzoJs5V.'],
|
27
|
+
['__________thirty-three___________', '$1$HO7Q6vzJ$yGwp2wbL5D7eOVzOmxpsy.'],
|
28
|
+
['apache', '$apr1$J.w5a/..$IW9y6DR0oO/ADuhlMF5/X1']
|
29
|
+
]
|
30
|
+
array_test(a, :md5)
|
31
|
+
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
33
|
+
def test_bad_algo
|
34
|
+
assert_raise(ArgumentError) do
|
35
|
+
Crypt.crypt("qsdf", :qsdf)
|
43
36
|
end
|
44
|
-
|
45
37
|
end
|
46
38
|
|
39
|
+
end
|
47
40
|
|
48
41
|
|