facets 2.0.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/WHATSNEW +11 -0
  2. data/lib/core/facets/enumerable/collect.rb +7 -2
  3. data/lib/core/facets/enumerable/permutation.rb +7 -26
  4. data/lib/core/facets/module/alias.rb +36 -12
  5. data/lib/core/facets/module/attr.rb +83 -35
  6. data/lib/core/facets/module/include.rb +10 -0
  7. data/lib/methods/facets/module/alias_accessor.rb +1 -1
  8. data/lib/methods/facets/module/alias_reader.rb +1 -0
  9. data/lib/methods/facets/module/alias_setter.rb +1 -0
  10. data/lib/methods/facets/module/alias_switcher.rb +1 -0
  11. data/lib/methods/facets/module/alias_tester.rb +1 -0
  12. data/lib/methods/facets/module/alias_toggler.rb +1 -0
  13. data/lib/methods/facets/module/alias_validator.rb +1 -0
  14. data/lib/methods/facets/module/alias_writer.rb +1 -0
  15. data/lib/methods/facets/module/attr_accessor.rb +1 -0
  16. data/lib/methods/facets/module/attr_reader.rb +1 -0
  17. data/lib/methods/facets/module/attr_switcher.rb +1 -0
  18. data/lib/methods/facets/module/attr_writer.rb +1 -0
  19. data/lib/more/facets/arguments.rb +2 -1
  20. data/lib/more/facets/command.rb +258 -395
  21. data/lib/more/facets/crypt.rb +242 -28
  22. data/lib/more/facets/ziputils.rb +1 -1
  23. data/log/changelog.txt +0 -0
  24. data/log/history.txt +22 -0
  25. data/log/release.txt +10 -0
  26. data/log/todo.txt +4 -0
  27. data/meta/{facets-2.0.5.roll → facets-2.1.0.roll} +0 -0
  28. data/meta/google_ad.html +15 -0
  29. data/meta/icli.yaml +3 -3
  30. data/meta/manifest.txt +24 -3
  31. data/task/clobber/package +10 -0
  32. data/task/config/general.yaml +21 -3
  33. data/task/isotest +2 -1
  34. data/task/loadtest +2 -0
  35. data/task/prepare +4 -2
  36. data/task/rdoc +122 -73
  37. data/task/release +12 -0
  38. data/task/special/quickopts +15 -0
  39. data/task/syntax +2 -0
  40. data/task/test +3 -1
  41. data/test/unit/enumerable/test_collect.rb +17 -0
  42. data/test/unit/enumerable/test_permutation.rb +20 -30
  43. data/test/unit/test_crypt.rb +29 -36
  44. metadata +40 -12
  45. data/RELEASE +0 -12
  46. data/test/unit/test_command.rb +0 -286
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ratch
2
+
3
+ # Remove package products.
4
+
5
+ main :clobber_packaging do
6
+ glob("pkg/*").each do |f|
7
+ rm_r(f)
8
+ end
9
+ end
10
+
@@ -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
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ratch
2
2
 
3
- #
3
+ # run tests in separate processes
4
+
4
5
  require 'facets/hash/rekey'
5
6
  require 'facets/string/tabs'
6
7
  require 'facets/progressbar'
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ratch
2
2
 
3
+ # simple load test
4
+
3
5
  main :syntax do
4
6
  scripts = "lib/**/*.rb"
5
7
  libpath = [ 'lib/methods', 'lib/core', 'lib/more' ].join(':')
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ratch
2
2
 
3
- manifest "-u meta/manifest.txt"
4
- box
3
+ # prepare package
4
+
5
+ manifest 'update'
6
+ box 'build'
5
7
 
data/task/rdoc CHANGED
@@ -7,108 +7,157 @@
7
7
 
8
8
  # NOTE: THIS IS SPECIALLY WRITTEN FOR FACETS!!!
9
9
 
10
- # Load RDoc configuration.
11
-
12
- config = configuration['rdoc']
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
- targets = configuration('rdoc.yaml')
14
+ task :rdoc_all do
15
+ # Load RDoc configuration.
16
+ configs = configuration['rdoc']
17
+ configs = [configs] unless Array===configs
22
18
 
23
- targets.each do |name, files|
24
- targets[name] = files.split(/\s+/) if String===files
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
- # Build RDocs.
30
+ def rdoc_groups(config)
31
+ site = config.delete('output') || config.delete('op') || 'doc/rdoc'
32
+ tdir = config['chdir']
29
33
 
30
- main :rdoc => [ :rdoc_targets, :insert_ads ]
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
- # Build RDoc's for each target,
43
+ title = config['title'].to_s
34
44
 
35
- task :rdoc_targets do
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
- # Helps to ensure we're in the right place.
38
- dir!(File.dirname(site))
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
- # Document each target.
54
- targets.each do |name, options|
55
- tgdir = options.delete('chdir')
56
- files = options.delete('files')
58
+ # Document target.
57
59
 
58
- #files.collect!{|f| "lib/more/facets/#{f}" }
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
- outdir = File.expand_path(File.join(site, name.gsub(' ','')))
61
- title = "Facets #{name.capitalize}"
68
+ site = config.delete('output') || config.delete('op') || 'doc/rdoc'
69
+ tgdir = config.delete('chdir')
70
+ files = config.delete('files')
62
71
 
63
- config = config.merge(
64
- 'op' => outdir,
65
- 'title' => title
66
- )
72
+ config['op'] = File.expand_path(site)
67
73
 
68
- # Prepare command arguments.
69
- vector = [files, config] #.flatten.compact
74
+ config['main'] = File.expand_path(config['main']) if config['main']
70
75
 
71
- # Create Documentation.
72
- cd(tgdir) do
73
- rdoc(vector.to_params)
74
- end
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
- GOOGLE_AD = <<-END
81
- <div style="position: absolute; top: 5px; right: 10px;">
82
- <script type="text/javascript"><!--
83
- google_ad_client = "pub-1126154564663472";
84
- google_ad_width = 234;
85
- google_ad_height = 60;
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,'classes', '**/*.html'))
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" + GOOGLE_AD
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
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ratch
2
+
3
+ # release packages
4
+
5
+ main :release do
6
+ fname = Dir.glob('meta/*.roll').first
7
+ pname = File.basename(fname).chomp('.roll')
8
+ name, version = *pname.split('-')
9
+
10
+ icli "rubyforge release --version=#{version}"
11
+ end
12
+
@@ -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
+
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ratch
2
2
 
3
+ # check syntax
4
+
3
5
  main :syntax do
4
6
  scripts = "lib/**/*.rb"
5
7
  libpath = [ 'lib/methods', 'lib/core', 'lib/more' ].join(':')
data/task/test CHANGED
@@ -21,6 +21,8 @@ main :test do
21
21
 
22
22
  Dir.glob(find).each do |file|
23
23
  next if dir?(file)
24
- load file
24
+ puts "Loading: #{file}"
25
+ load(file)
25
26
  end
26
27
  end
28
+
@@ -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
- # for lib/facets/enumerable/permutation.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
12
-
13
- require 'facets/enumerable/permutation.rb'
14
-
15
-
16
-
17
- require 'test/unit'
18
- require 'set'
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
@@ -1,48 +1,41 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/crypt.rb
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
- require 'facets/crypt.rb'
9
+ require 'facets/crypt.rb'
14
10
 
11
+ require "test/unit"
15
12
 
13
+ class CryptTest < Test::Unit::TestCase
16
14
 
17
- require "test/unit"
18
-
19
- class CryptTest < Test::Unit::TestCase
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
- def test_md5
28
- a = [ [' ', '$1$yiiZbNIH$YiCsHZjcTkYd31wkgW8JF.'],
29
- ['pass', '$1$YeNsbWdH$wvOF8JdqsoiLix754LTW90'],
30
- ['____fifteen____', '$1$s9lUWACI$Kk1jtIVVdmT01p0z3b/hw1'],
31
- ['____sixteen_____', '$1$dL3xbVZI$kkgqhCanLdxODGq14g/tW1'],
32
- ['____seventeen____', '$1$NaH5na7J$j7y8Iss0hcRbu3kzoJs5V.'],
33
- ['__________thirty-three___________', '$1$HO7Q6vzJ$yGwp2wbL5D7eOVzOmxpsy.'],
34
- ['apache', '$apr1$J.w5a/..$IW9y6DR0oO/ADuhlMF5/X1']
35
- ]
36
- array_test(a, :md5)
37
- end
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
- def test_bad_algo
40
- assert_raise(ArgumentError) do
41
- Crypt.crypt("qsdf", :qsdf)
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