facets 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -1
- data/RELEASE +6 -0
- data/lib/core/facets/hash/op.rb +1 -1
- data/lib/more/facets/command.rb +15 -4
- data/lib/more/facets/dictionary.rb +7 -3
- data/meta/{facets-2.0.3.roll → facets-2.0.4.roll} +0 -0
- data/meta/icli.yaml +17 -0
- data/meta/manifest.txt +4 -2
- data/task/config/rdoc.yaml +1 -2
- data/task/groups +3 -3
- data/task/log +17 -0
- data/task/prepare +1 -1
- data/test/unit/hash/test_op.rb +52 -47
- metadata +6 -4
- data/task/extest +0 -129
data/AUTHORS
CHANGED
@@ -10,10 +10,10 @@ The following developers have contributed significant
|
|
10
10
|
amounts of time to the development of Facets. They are held
|
11
11
|
in the highest regard for their efforts.
|
12
12
|
|
13
|
-
* Noah Gibbs
|
14
13
|
* Florian Gross
|
15
14
|
* George Moschovitis
|
16
15
|
* Tyler Rick
|
16
|
+
* Noah Gibbs
|
17
17
|
|
18
18
|
== Rubyists of Distinction
|
19
19
|
|
data/RELEASE
ADDED
data/lib/core/facets/hash/op.rb
CHANGED
data/lib/more/facets/command.rb
CHANGED
@@ -91,7 +91,8 @@ module Console
|
|
91
91
|
end
|
92
92
|
alias_method :global_options, :global_option
|
93
93
|
|
94
|
-
# Options
|
94
|
+
# Define a set of options. This can be a Command::Options subclass,
|
95
|
+
# or a block whihc will be used to create an Command::Options subclass.
|
95
96
|
|
96
97
|
def options(name, klass=nil, &block)
|
97
98
|
raise ArgumentError if klass && block
|
@@ -488,10 +489,20 @@ module Console
|
|
488
489
|
#
|
489
490
|
|
490
491
|
def to_h
|
491
|
-
|
492
|
-
|
493
|
-
|
492
|
+
opts = @__self__.public_methods(true).select{ |m| m =~ /^[A-Za-z0-9]+[=!]$/ || m =~ /^[_][A-Za-z0-9]+$/ }
|
493
|
+
#opts.reject!{ |k| k =~ /_$/ }
|
494
|
+
opts.collect!{ |m| m.chomp('=').chomp('!') }
|
495
|
+
opts.inject({}) do |h, m|
|
496
|
+
k = m.sub(/^_+/, '')
|
497
|
+
v = @__self__.send(m)
|
498
|
+
h[k] = v if v
|
499
|
+
h
|
494
500
|
end
|
501
|
+
|
502
|
+
#@__self__.instance_variables.inject({}) do |h, v|
|
503
|
+
# next h if v == "@__self__"
|
504
|
+
# h[v[1..-1]] = @__self__.instance_variable_get(v); h
|
505
|
+
#end
|
495
506
|
end
|
496
507
|
|
497
508
|
# Provides a very basic usage help string.
|
@@ -139,9 +139,13 @@ class Dictionary
|
|
139
139
|
def initialize(*args, &blk)
|
140
140
|
@order = []
|
141
141
|
@order_by = nil
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
if blk
|
143
|
+
dict = self # This ensure autmatic key entry effect the
|
144
|
+
oblk = lambda{ |hsh, key| blk[dict,key] } # dictionary rather then just the interal hash.
|
145
|
+
@hash = Hash.new(*args, &oblk)
|
146
|
+
else
|
147
|
+
@hash = Hash.new
|
148
|
+
end
|
145
149
|
end
|
146
150
|
|
147
151
|
def order
|
File without changes
|
data/meta/icli.yaml
ADDED
data/meta/manifest.txt
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
AUTHORS
|
3
3
|
LICENSE
|
4
4
|
README
|
5
|
+
RELEASE
|
5
6
|
demo
|
6
7
|
demo/bench
|
7
8
|
demo/bench/enumerable
|
@@ -726,7 +727,8 @@ lib/more/facets/version.rb
|
|
726
727
|
lib/more/facets/yaml.rb
|
727
728
|
lib/more/facets/ziputils.rb
|
728
729
|
meta
|
729
|
-
meta/facets-2.0.
|
730
|
+
meta/facets-2.0.4.roll
|
731
|
+
meta/icli.yaml
|
730
732
|
meta/manifest.txt
|
731
733
|
task
|
732
734
|
task/clean
|
@@ -734,11 +736,11 @@ task/config
|
|
734
736
|
task/config/general.yaml
|
735
737
|
task/config/rdoc.yaml
|
736
738
|
task/crosstest
|
737
|
-
task/extest
|
738
739
|
task/groups
|
739
740
|
task/install
|
740
741
|
task/isotest
|
741
742
|
task/loadtest
|
743
|
+
task/log
|
742
744
|
task/methods
|
743
745
|
task/prepare
|
744
746
|
task/publish
|
data/task/config/rdoc.yaml
CHANGED
data/task/groups
CHANGED
@@ -5,10 +5,10 @@
|
|
5
5
|
main :groups do
|
6
6
|
dir = 'lib/core/facets'
|
7
7
|
|
8
|
-
|
9
|
-
dirs =
|
8
|
+
cd(dir) do
|
9
|
+
dirs = glob('*').select{ |f| File.directory?(f) }
|
10
10
|
dirs.each do |d|
|
11
|
-
files =
|
11
|
+
files = glob("#{d}/**/*.rb")
|
12
12
|
code = files.collect { |f| "require 'facets/#{f}'" }.join("\n")
|
13
13
|
if noharm?
|
14
14
|
puts "#{d}.rb"
|
data/task/log
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ratch
|
2
|
+
|
3
|
+
# produce changelog
|
4
|
+
|
5
|
+
main :changelog do
|
6
|
+
text = `svn log --xml`
|
7
|
+
i = text.index("?>\n")
|
8
|
+
text.insert(i+2, "\n" + '<?xml-stylesheet href="changelog.xsl" type="text/xsl" ?>')
|
9
|
+
|
10
|
+
if dryrun?
|
11
|
+
puts text
|
12
|
+
else
|
13
|
+
File.open('doc/log/changelog.xml') do |f|
|
14
|
+
f << text
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/task/prepare
CHANGED
data/test/unit/hash/test_op.rb
CHANGED
@@ -1,52 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
12
|
-
|
13
|
-
require 'facets/hash/op.rb'
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
require 'test/unit'
|
18
|
-
|
19
|
-
class TestHashOperate < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def test_op_and_hash
|
22
|
-
a = { :a => 1, :b => 2 }
|
23
|
-
b = { :a => 1 }
|
24
|
-
r = { :a => 1 }
|
25
|
-
assert_equal( r, a & b )
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_op_and_hash_subarray
|
29
|
-
a = { :a => [1], :b => [2] }
|
30
|
-
b = { :a => [1] }
|
31
|
-
r = { :a => [1] }
|
32
|
-
assert_equal( r, a & b )
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_op_and_array
|
36
|
-
a = { :a => 1, :b => 2 }
|
37
|
-
b = [ :a ]
|
38
|
-
r = { :a => 1 }
|
39
|
-
assert_equal( r, a & b )
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_shift_update
|
43
|
-
a = { :a => 1, :b => 2, :c => 3 }
|
44
|
-
b = { :a => 0, :d => 4 }
|
45
|
-
e = { :a => 0, :b => 2, :c => 3, :d => 4 }
|
46
|
-
assert_equal( e, a << b )
|
47
|
-
end
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for facets/hash/op.rb
|
48
8
|
|
9
|
+
require 'facets/hash/op.rb'
|
10
|
+
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
class TestHashOperate < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_op_and_hash
|
16
|
+
a = { :a => 1, :b => 2 }
|
17
|
+
b = { :a => 1 }
|
18
|
+
r = { :a => 1 }
|
19
|
+
assert_equal( r, a & b )
|
49
20
|
end
|
50
21
|
|
22
|
+
def test_op_and_hash_subarray
|
23
|
+
a = { :a => [1], :b => [2] }
|
24
|
+
b = { :a => [1] }
|
25
|
+
r = { :a => [1] }
|
26
|
+
assert_equal( r, a & b )
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_op_and_array
|
30
|
+
a = { :a => 1, :b => 2 }
|
31
|
+
b = [ :a ]
|
32
|
+
r = { :a => 1 }
|
33
|
+
assert_equal( r, a & b )
|
34
|
+
end
|
51
35
|
|
36
|
+
def test_shift_update
|
37
|
+
a = { :a => 1, :b => 2, :c => 3 }
|
38
|
+
b = { :a => 0, :d => 4 }
|
39
|
+
e = { :a => 0, :b => 2, :c => 3, :d => 4 }
|
40
|
+
assert_equal( e, a << b )
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_op_minus_array
|
44
|
+
a = { :a => 1, :b => 2, :c => 3 }
|
45
|
+
b = [ :a ]
|
46
|
+
e = { :b => 2, :c => 3 }
|
47
|
+
assert_equal( e, a - b )
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_op_minus_hash
|
51
|
+
a = { :a => 1, :b => 2, :c => 3 }
|
52
|
+
b = { :a => 1, :d => 4 }
|
53
|
+
e = { :b => 2, :c => 3 }
|
54
|
+
assert_equal( e, a - b )
|
55
|
+
end
|
52
56
|
|
57
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: facets
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 2.0.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 2.0.4
|
7
|
+
date: 2007-11-04 00:00:00 -04:00
|
8
8
|
summary: Premium Core Extensions and Standard Additions
|
9
9
|
require_paths:
|
10
10
|
- lib/methods
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- AUTHORS
|
35
35
|
- LICENSE
|
36
36
|
- README
|
37
|
+
- RELEASE
|
37
38
|
- demo
|
38
39
|
- demo/bench
|
39
40
|
- demo/bench/enumerable
|
@@ -758,7 +759,8 @@ files:
|
|
758
759
|
- lib/more/facets/yaml.rb
|
759
760
|
- lib/more/facets/ziputils.rb
|
760
761
|
- meta
|
761
|
-
- meta/facets-2.0.
|
762
|
+
- meta/facets-2.0.4.roll
|
763
|
+
- meta/icli.yaml
|
762
764
|
- meta/manifest.txt
|
763
765
|
- task
|
764
766
|
- task/clean
|
@@ -766,11 +768,11 @@ files:
|
|
766
768
|
- task/config/general.yaml
|
767
769
|
- task/config/rdoc.yaml
|
768
770
|
- task/crosstest
|
769
|
-
- task/extest
|
770
771
|
- task/groups
|
771
772
|
- task/install
|
772
773
|
- task/isotest
|
773
774
|
- task/loadtest
|
775
|
+
- task/log
|
774
776
|
- task/methods
|
775
777
|
- task/prepare
|
776
778
|
- task/publish
|
data/task/extest
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ratch
|
2
|
-
|
3
|
-
# Extract embedded tests.
|
4
|
-
|
5
|
-
# Extract unit tests. This task scans every package script
|
6
|
-
# looking for sections of the form:
|
7
|
-
#
|
8
|
-
# =begin test
|
9
|
-
# ...
|
10
|
-
# =end
|
11
|
-
#
|
12
|
-
# With appropriate headers, it copies these sections to files
|
13
|
-
# in your project's test/ dir, which then can be run using the
|
14
|
-
# Ratchet test task. The exact directory layout of the files to
|
15
|
-
# be tested is reflected in the test directory. You can then
|
16
|
-
# use project.rb's test task to run the tests.
|
17
|
-
#
|
18
|
-
# files Files to extract ['lib/**/*.rb']
|
19
|
-
# output Test directory ['test/']
|
20
|
-
|
21
|
-
main :extest do
|
22
|
-
extract_tests # Deal with arg once rathc has better support fot it.
|
23
|
-
end
|
24
|
-
|
25
|
-
# Extract tests for scripts.
|
26
|
-
|
27
|
-
def extract_tests(files=nil)
|
28
|
-
output = 'test/embedded' # Don't think output should be setable.
|
29
|
-
|
30
|
-
files = files || 'lib/**/*.rb'
|
31
|
-
files = 'lib/**/*.rb' if TrueClass == files
|
32
|
-
files = [files].flatten.compact
|
33
|
-
|
34
|
-
filelist = files.collect{ |f| Dir.glob(f) }
|
35
|
-
filelist.flatten!
|
36
|
-
if filelist.empty?
|
37
|
-
puts "No scripts found from which to extract tests."
|
38
|
-
return
|
39
|
-
end
|
40
|
-
|
41
|
-
mkdir_p(output) unless directory?(output)
|
42
|
-
|
43
|
-
#vrunner = VerbosityRunner.new("Extracting", verbosity?)
|
44
|
-
#vrunner.setup(filelist.size)
|
45
|
-
|
46
|
-
filelist.each do |file|
|
47
|
-
#vrunner.prepare(file)
|
48
|
-
|
49
|
-
testing = extract_test_from_file( file )
|
50
|
-
if testing.strip.empty?
|
51
|
-
status = "[NONE]"
|
52
|
-
else
|
53
|
-
complete_test = create_test(testing, file)
|
54
|
-
libpath = File.dirname(file)
|
55
|
-
testfile = "test_" + File.basename(file)
|
56
|
-
fp = File.join(output, libpath, testfile)
|
57
|
-
unless directory?( File.dirname(fp))
|
58
|
-
mkdir_p(File.dirname(fp))
|
59
|
-
end
|
60
|
-
if dryrun?
|
61
|
-
puts "write #{fp}"
|
62
|
-
else
|
63
|
-
File.open(fp, "w"){ |fw| fw << complete_test }
|
64
|
-
end
|
65
|
-
status = "[TEST]"
|
66
|
-
end
|
67
|
-
|
68
|
-
#vrunner.complete(file, status)
|
69
|
-
end
|
70
|
-
|
71
|
-
#vrunner.finish(
|
72
|
-
# :normal => "#{filelist.size} files had tests extracted.",
|
73
|
-
# :check => false
|
74
|
-
#)
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
# Extract test from a file's testing comments.
|
80
|
-
|
81
|
-
def extract_test_from_file( file )
|
82
|
-
return nil if ! File.file?( file )
|
83
|
-
tests = ""; inside = false
|
84
|
-
fstr = File.read( file )
|
85
|
-
fstr.split(/\n/).each do |l|
|
86
|
-
if l =~ /^=begin[ ]*test/i
|
87
|
-
tests << "\n"
|
88
|
-
inside = true
|
89
|
-
next
|
90
|
-
elsif inside and l =~ /^=[ ]*end/
|
91
|
-
inside = false
|
92
|
-
next
|
93
|
-
end
|
94
|
-
if inside
|
95
|
-
tests << l << "\n"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
tests
|
99
|
-
end
|
100
|
-
|
101
|
-
# Generate the test.
|
102
|
-
|
103
|
-
def create_test( testing, file )
|
104
|
-
fp = file.split(/[\/]/)
|
105
|
-
if fp[0] == 'lib'
|
106
|
-
reqf = "require '#{fp[1..-1].join('/')}'"
|
107
|
-
else
|
108
|
-
reqf = ''
|
109
|
-
end
|
110
|
-
str = []
|
111
|
-
str << " # _____ _"
|
112
|
-
str << " # |_ _|__ ___| |_"
|
113
|
-
str << " # | |/ _ \\/ __| __|"
|
114
|
-
str << " # | | __/\\__ \\ |"
|
115
|
-
str << " # |_|\\___||___/\\__|"
|
116
|
-
str << " #"
|
117
|
-
str << " # for #{file}"
|
118
|
-
str << " #"
|
119
|
-
str << " # Extracted #{Time.now}"
|
120
|
-
str << " # w/ Test Extraction Ratchet"
|
121
|
-
str << " #"
|
122
|
-
str << ""
|
123
|
-
str << " #{reqf}"
|
124
|
-
str << ""
|
125
|
-
str << testing
|
126
|
-
str << "\n"
|
127
|
-
str = str.join("\n")
|
128
|
-
str
|
129
|
-
end
|