ClsRuby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +26 -0
- data/README +55 -0
- data/THANKS +0 -0
- data/docs/base_formatting_methods +89 -0
- data/docs/base_parsing_methods +79 -0
- data/docs/constructor_params +131 -0
- data/docs/examples/log_single_line_format +3 -0
- data/docs/examples/service_description +3 -0
- data/docs/examples/sms-hist +3 -0
- data/docs/examples/tag_any +3 -0
- data/docs/fragments/custom_tag_field.rb +20 -0
- data/docs/fragments/custom_tag_include.rb +21 -0
- data/docs/fragments/field.cls +2 -0
- data/docs/fragments/include.cls +4 -0
- data/docs/fragments/inherit_tag_params.rb +21 -0
- data/docs/fragments/message.cls +6 -0
- data/docs/fragments/tag_field.rb +24 -0
- data/docs/fragments/tag_message.rb +74 -0
- data/docs/fragments/tags_order.rb +41 -0
- data/docs/principles +402 -0
- data/docs/std_tags_short_description +278 -0
- data/docs/syntax +227 -0
- data/docs/why_cls +178 -0
- data/examples/hex_stream.txt +1 -0
- data/examples/log_single_line_formatter.rb +79 -0
- data/examples/service_description.day_time.cfg +11 -0
- data/examples/service_description.rb +119 -0
- data/examples/sms-hist.rb +164 -0
- data/examples/space_concat.txt +3 -0
- data/examples/tag_any.rb +28 -0
- data/lib/cls-ruby/basic_scalars.rb +270 -0
- data/lib/cls-ruby/constraints/one_of.rb +36 -0
- data/lib/cls-ruby/default_formatter.rb +50 -0
- data/lib/cls-ruby/ex.rb +121 -0
- data/lib/cls-ruby/formatter.rb +31 -0
- data/lib/cls-ruby/lexers/char_classifier.rb +157 -0
- data/lib/cls-ruby/lexers/first_stage.rb +112 -0
- data/lib/cls-ruby/lexers/lexer.rb +74 -0
- data/lib/cls-ruby/oneline_formatter.rb +35 -0
- data/lib/cls-ruby/parser.rb +249 -0
- data/lib/cls-ruby/tag.rb +428 -0
- data/lib/cls-ruby/tag_any.rb +111 -0
- data/lib/cls-ruby/tag_no_value.rb +55 -0
- data/lib/cls-ruby/tag_scalar.rb +197 -0
- data/lib/cls-ruby/tag_scalar_helpers.rb +70 -0
- data/lib/cls-ruby/tag_scalar_vector.rb +148 -0
- data/lib/cls-ruby/tag_vector_of_different_tags.rb +172 -0
- data/lib/cls-ruby/tag_vector_of_tags.rb +116 -0
- data/lib/cls-ruby/vector_of_tags_impl.rb +129 -0
- data/lib/cls-ruby.rb +5 -0
- data/tests/tc_child_tag.rb +51 -0
- data/tests/tc_constraint_one_of.rb +47 -0
- data/tests/tc_format_helper.rb +27 -0
- data/tests/tc_formatters.rb +125 -0
- data/tests/tc_lexer.rb +124 -0
- data/tests/tc_lexer_char_classifier.rb +121 -0
- data/tests/tc_lexer_first_stage.rb +72 -0
- data/tests/tc_parser_simple.rb +93 -0
- data/tests/tc_scalar_parsers.rb +189 -0
- data/tests/tc_tag.rb +68 -0
- data/tests/tc_tag_no_value.rb +46 -0
- data/tests/tc_tag_scalar_int.rb +83 -0
- data/tests/tc_tag_scalar_nonspace_string.rb +46 -0
- data/tests/tc_tag_scalar_string.rb +47 -0
- data/tests/tc_tag_scalar_vector_int.rb +88 -0
- data/tests/tc_tag_scalar_vector_string.rb +48 -0
- data/tests/tc_tag_scalar_vector_string_empty.rb +40 -0
- data/tests/tc_tag_vector_of_different_tags.rb +109 -0
- data/tests/tc_tag_vector_of_tags.rb +103 -0
- data/tests/ts_cls_ruby.rb +7 -0
- metadata +140 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'cls-ruby/parser'
|
6
|
+
require 'cls-ruby/tag_scalar'
|
7
|
+
|
8
|
+
class TC_TagScalarNonspaceString < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@tag = ClsRuby::TagScalar.new :name => 'test',
|
11
|
+
:format => ClsRuby::SCALAR_NONSPACE_STRING
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_normal
|
15
|
+
assert_nothing_raised do
|
16
|
+
ClsRuby::parse_string '{test 1234 }', @tag
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_equal( "1234", @tag.value )
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_no_value
|
23
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
24
|
+
ClsRuby::parse_string( '{test}', @tag )
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_two_tags
|
29
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
30
|
+
ClsRuby::parse_string( '{test 1} {test 2}', @tag )
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_two_values
|
35
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
36
|
+
ClsRuby::parse_string( '{test 1 2}', @tag )
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_string_as_value
|
41
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
42
|
+
ClsRuby::parse_string( '{test "1"}', @tag )
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'cls-ruby/parser'
|
6
|
+
require 'cls-ruby/tag_scalar'
|
7
|
+
require 'cls-ruby/basic_scalars'
|
8
|
+
|
9
|
+
class TC_TagScalarString < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@tag = ClsRuby::TagScalar.new :name => 'test',
|
12
|
+
:format => ClsRuby::SCALAR_STRING
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_normal
|
16
|
+
assert_nothing_raised do
|
17
|
+
ClsRuby::parse_string '{test "1 2 34"}', @tag
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_equal( "1 2 34", @tag.value )
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_no_value
|
24
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
25
|
+
ClsRuby::parse_string( '{test}', @tag )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_two_tags
|
30
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
31
|
+
ClsRuby::parse_string( '{test "1"} {test "2"}', @tag )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_two_values
|
36
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
37
|
+
ClsRuby::parse_string( '{test "1" "2"}', @tag )
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_nonspace_as_value
|
42
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
43
|
+
ClsRuby::parse_string( '{test 1}', @tag )
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
require 'cls-ruby/parser'
|
5
|
+
require 'cls-ruby/tag_scalar_vector'
|
6
|
+
|
7
|
+
class TC_TagScalarVectorInt < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@tag = ClsRuby::TagScalarVector.new :name => 'test',
|
10
|
+
:format => ClsRuby::SCALAR_INT,
|
11
|
+
:constraint => 1..1000
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_normal_single_value
|
15
|
+
assert_nothing_raised do
|
16
|
+
ClsRuby::parse_string '{test 234}', @tag
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_equal( [ 234 ], @tag.value )
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_normal_multi_values
|
23
|
+
assert_nothing_raised do
|
24
|
+
ClsRuby::parse_string '{test 234 345 763 48 1}', @tag
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_equal( [ 234, 345, 763, 48, 1 ], @tag.value )
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_fetch
|
31
|
+
assert_nothing_raised do
|
32
|
+
ClsRuby::parse_string '', @tag
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_equal( false, @tag.tag_defined? )
|
36
|
+
assert_equal( [], @tag.value )
|
37
|
+
assert_equal( [ 345 ], @tag.fetch( [ 345 ] ) )
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_reset
|
41
|
+
test_normal_multi_values
|
42
|
+
@tag.tag_reset
|
43
|
+
test_normal_single_value
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_no_value
|
47
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
48
|
+
ClsRuby::parse_string( '{test}', @tag )
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_two_tags
|
53
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
54
|
+
ClsRuby::parse_string( '{test 1} {test 2}', @tag )
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_string_as_value
|
59
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
60
|
+
ClsRuby::parse_string( '{test "1"}', @tag )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_out_of_range_min
|
65
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
66
|
+
ClsRuby::parse_string( '{test 1 0 2}', @tag )
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_out_of_range_max
|
71
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
72
|
+
ClsRuby::parse_string( '{test 1000 1001 1000}', @tag )
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class TC_AutoDefineTagIntScalarVector < Test::Unit::TestCase
|
78
|
+
def test_autodefine
|
79
|
+
t = ClsRuby::TagScalarVector.new(
|
80
|
+
:name => 'n',
|
81
|
+
:format => ClsRuby::SCALAR_INT,
|
82
|
+
:value => [ 1, 2, 3 ] )
|
83
|
+
assert_equal( true, t.tag_defined? )
|
84
|
+
assert_equal( [ 1, 2, 3 ], t.value )
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'cls-ruby/parser'
|
6
|
+
require 'cls-ruby/tag_scalar_vector'
|
7
|
+
|
8
|
+
class TC_TagScalarVectorString < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@tag = ClsRuby::TagScalarVector.new :name => 'test',
|
11
|
+
:format => ClsRuby::SCALAR_STRING
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_normal_single_value
|
15
|
+
assert_nothing_raised do
|
16
|
+
ClsRuby::parse_string '{test "1 2 34"}', @tag
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_equal( [ "1 2 34" ], @tag.value )
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_normal_multi_values
|
23
|
+
assert_nothing_raised do
|
24
|
+
ClsRuby::parse_string '{test "1 2 34" "222" "3333" }', @tag
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_equal( [ "1 2 34", "222", "3333" ], @tag.value )
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_no_value
|
31
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
32
|
+
ClsRuby::parse_string( '{test}', @tag )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_two_tags
|
37
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
38
|
+
ClsRuby::parse_string( '{test "1"} {test "2"}', @tag )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_nonspace_as_value
|
43
|
+
assert_raise( ClsRuby::ParsingErrorEx ) do
|
44
|
+
ClsRuby::parse_string( '{test 1}', @tag )
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'cls-ruby/parser'
|
6
|
+
require 'cls-ruby/tag_scalar_vector'
|
7
|
+
|
8
|
+
class TC_TagScalarVectorStringEmpty < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@tag = ClsRuby::TagScalarVector.new :name => 'test',
|
11
|
+
:format => ClsRuby::SCALAR_STRING,
|
12
|
+
:can_be_empty => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_normal_single_value
|
16
|
+
assert_nothing_raised do
|
17
|
+
ClsRuby::parse_string '{test "1 2 34"}', @tag
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_equal( [ "1 2 34" ], @tag.value )
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_normal_multi_values
|
24
|
+
assert_nothing_raised do
|
25
|
+
ClsRuby::parse_string '{test "1 2 34" "222" "3333" }', @tag
|
26
|
+
end
|
27
|
+
|
28
|
+
assert_equal( [ "1 2 34", "222", "3333" ], @tag.value )
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_no_value
|
32
|
+
assert_nothing_raised do
|
33
|
+
ClsRuby::parse_string( '{test}', @tag )
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_equal( [], @tag.value )
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'cls-ruby/parser'
|
6
|
+
require 'cls-ruby/tag_scalar'
|
7
|
+
require 'cls-ruby/tag_no_value'
|
8
|
+
require 'cls-ruby/tag_vector_of_different_tags'
|
9
|
+
|
10
|
+
class TC_TagVectorOfDifferentTags < Test::Unit::TestCase
|
11
|
+
|
12
|
+
class Filter
|
13
|
+
INCLUDE = 1
|
14
|
+
EXCLUDE = 2
|
15
|
+
|
16
|
+
attr_reader :type, :regex
|
17
|
+
|
18
|
+
def initialize( type, regex )
|
19
|
+
@type, @regex = type, regex
|
20
|
+
end
|
21
|
+
|
22
|
+
def ==( other )
|
23
|
+
type == other.type && regex == other.regex
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class TagInclude < ClsRuby::TagStringScalar
|
28
|
+
def value
|
29
|
+
Filter.new( Filter::INCLUDE, super )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class TagExclude < ClsRuby::TagStringScalar
|
34
|
+
def value
|
35
|
+
Filter.new( Filter::EXCLUDE, super )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class TagFilter < ClsRuby::TagNoValue
|
40
|
+
child_tag :filters, ClsRuby::TagVectorOfDifferentTags,
|
41
|
+
:nested_tags => [
|
42
|
+
{ :name => 'include', :type => TagInclude },
|
43
|
+
{ :name => 'exclude', :type => TagExclude } ]
|
44
|
+
|
45
|
+
default_tag_params :name => 'filter'
|
46
|
+
|
47
|
+
def filters
|
48
|
+
filters = @filters.collect_values_by( :value )
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup
|
53
|
+
@tag = TagFilter.new( :name => 'filter', :mandatory => true )
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_no_values
|
57
|
+
assert_nothing_raised do
|
58
|
+
ClsRuby::parse_string( "{filter}", @tag )
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_single_include
|
63
|
+
assert_nothing_raised do
|
64
|
+
ClsRuby::parse_string(
|
65
|
+
'{filter {include "AAA"}}', @tag )
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal( [ Filter.new( Filter::INCLUDE, 'AAA' ) ],
|
69
|
+
@tag.filters )
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_single_exclude
|
73
|
+
assert_nothing_raised do
|
74
|
+
ClsRuby::parse_string(
|
75
|
+
'{filter {exclude "AAA"}}', @tag )
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_equal( [ Filter.new( Filter::EXCLUDE, 'AAA' ) ],
|
79
|
+
@tag.filters )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_multi_filters
|
83
|
+
values = [
|
84
|
+
Filter.new( Filter::INCLUDE, 'first' ),
|
85
|
+
Filter.new( Filter::EXCLUDE, 'second' ),
|
86
|
+
Filter.new( Filter::INCLUDE, 'third' ) ]
|
87
|
+
|
88
|
+
str = '{filter ' + values.inject( '' ) do |result, v|
|
89
|
+
result << '{'
|
90
|
+
result << ( Filter::INCLUDE == v.type ? 'include' : 'exclude' )
|
91
|
+
result << ' "' << v.regex << '"}'
|
92
|
+
end + '}'
|
93
|
+
|
94
|
+
assert_nothing_raised do
|
95
|
+
ClsRuby::parse_string( str, @tag )
|
96
|
+
end
|
97
|
+
|
98
|
+
assert_equal( values, @tag.filters )
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_reset
|
102
|
+
test_multi_filters
|
103
|
+
@tag.tag_reset
|
104
|
+
test_single_include
|
105
|
+
@tag.tag_reset
|
106
|
+
test_single_exclude
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
$:.unshift( File.join( File.dirname( __FILE__ ), '../lib' ) )
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'cls-ruby/parser'
|
6
|
+
require 'cls-ruby/tag_scalar'
|
7
|
+
require 'cls-ruby/tag_no_value'
|
8
|
+
require 'cls-ruby/tag_vector_of_tags'
|
9
|
+
|
10
|
+
class TC_TagVectorOfTags < Test::Unit::TestCase
|
11
|
+
class TagField < ClsRuby::TagNoValue
|
12
|
+
Description = Struct.new( :name, :value )
|
13
|
+
|
14
|
+
child_tag :name, ClsRuby::TagScalar, :format => ClsRuby::SCALAR_STRING,
|
15
|
+
:mandatory => true
|
16
|
+
child_tag :value, ClsRuby::TagScalar, :format => ClsRuby::SCALAR_STRING,
|
17
|
+
:mandatory => true
|
18
|
+
|
19
|
+
def description
|
20
|
+
Description.new( @name.value, @value.value )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class TagMessage < ClsRuby::TagNoValue
|
25
|
+
Description = Struct.new( :name, :fields )
|
26
|
+
|
27
|
+
child_tag :name, ClsRuby::TagScalar, :format => ClsRuby::SCALAR_STRING,
|
28
|
+
:mandatory => true
|
29
|
+
child_tag :field, ClsRuby::TagVectorOfTags, :type => TagField
|
30
|
+
|
31
|
+
def description
|
32
|
+
fields = @field.collect_values_by :description
|
33
|
+
|
34
|
+
Description.new( @name.value, fields )
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@tag = TagMessage.new( :name => 'message', :mandatory => true )
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_normal_no_field
|
43
|
+
assert_nothing_raised do
|
44
|
+
ClsRuby::parse_string(
|
45
|
+
%q<
|
46
|
+
{message
|
47
|
+
{name "no_field" }
|
48
|
+
}>,
|
49
|
+
@tag )
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_equal( 'no_field', @tag.description.name )
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_normal_single_field
|
56
|
+
assert_nothing_raised do
|
57
|
+
ClsRuby::parse_string(
|
58
|
+
%q<
|
59
|
+
{message
|
60
|
+
{name "single_field" }
|
61
|
+
{field {name "first"} {value "AAA"}}
|
62
|
+
}>,
|
63
|
+
@tag )
|
64
|
+
end
|
65
|
+
|
66
|
+
assert_equal( 'single_field', @tag.description.name )
|
67
|
+
assert_equal( 'first', @tag.description.fields[0].name )
|
68
|
+
assert_equal( 'AAA', @tag.description.fields[0].value )
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_normal_multi_fields
|
72
|
+
values = [ [ 'a', 'a' ], [ 'b', 'b' ], [ 'c', 'c' ] ]
|
73
|
+
|
74
|
+
assert_nothing_raised do
|
75
|
+
ClsRuby::parse_string(
|
76
|
+
%q<
|
77
|
+
{message
|
78
|
+
{name "multi_fields" }
|
79
|
+
> +
|
80
|
+
values.inject( "" ) do |result, pair|
|
81
|
+
result << "{field {name \"#{pair[0]}\"} {value \"#{pair[1]}\"}}"
|
82
|
+
result
|
83
|
+
end + "}",
|
84
|
+
@tag )
|
85
|
+
end
|
86
|
+
|
87
|
+
assert_equal( 'multi_fields', @tag.description.name )
|
88
|
+
|
89
|
+
expected_values = values.inject( [] ) do |result, pair|
|
90
|
+
result << TagField::Description.new( pair[ 0 ], pair[ 1 ] )
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
assert_equal( expected_values, @tag.description.fields )
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_reset
|
98
|
+
test_normal_multi_fields
|
99
|
+
@tag.tag_reset
|
100
|
+
test_normal_single_field
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: ClsRuby
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-03-14 00:00:00 +03:00
|
8
|
+
summary: Curl Like Syntax for Ruby language
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: eao197@yahoo.com
|
12
|
+
homepage: http://www.rubyforge.com/projects/clsruby
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Yauheni Akhotnikau
|
31
|
+
files:
|
32
|
+
- tests/tc_child_tag.rb
|
33
|
+
- tests/tc_constraint_one_of.rb
|
34
|
+
- tests/tc_formatters.rb
|
35
|
+
- tests/tc_format_helper.rb
|
36
|
+
- tests/tc_lexer.rb
|
37
|
+
- tests/tc_lexer_char_classifier.rb
|
38
|
+
- tests/tc_lexer_first_stage.rb
|
39
|
+
- tests/tc_parser_simple.rb
|
40
|
+
- tests/tc_scalar_parsers.rb
|
41
|
+
- tests/tc_tag.rb
|
42
|
+
- tests/tc_tag_no_value.rb
|
43
|
+
- tests/tc_tag_scalar_int.rb
|
44
|
+
- tests/tc_tag_scalar_nonspace_string.rb
|
45
|
+
- tests/tc_tag_scalar_string.rb
|
46
|
+
- tests/tc_tag_scalar_vector_int.rb
|
47
|
+
- tests/tc_tag_scalar_vector_string.rb
|
48
|
+
- tests/tc_tag_scalar_vector_string_empty.rb
|
49
|
+
- tests/tc_tag_vector_of_different_tags.rb
|
50
|
+
- tests/tc_tag_vector_of_tags.rb
|
51
|
+
- tests/ts_cls_ruby.rb
|
52
|
+
- lib/cls-ruby
|
53
|
+
- lib/cls-ruby.rb
|
54
|
+
- lib/cls-ruby/basic_scalars.rb
|
55
|
+
- lib/cls-ruby/constraints
|
56
|
+
- lib/cls-ruby/default_formatter.rb
|
57
|
+
- lib/cls-ruby/ex.rb
|
58
|
+
- lib/cls-ruby/formatter.rb
|
59
|
+
- lib/cls-ruby/lexers
|
60
|
+
- lib/cls-ruby/oneline_formatter.rb
|
61
|
+
- lib/cls-ruby/parser.rb
|
62
|
+
- lib/cls-ruby/tag.rb
|
63
|
+
- lib/cls-ruby/tag_any.rb
|
64
|
+
- lib/cls-ruby/tag_no_value.rb
|
65
|
+
- lib/cls-ruby/tag_scalar.rb
|
66
|
+
- lib/cls-ruby/tag_scalar_helpers.rb
|
67
|
+
- lib/cls-ruby/tag_scalar_vector.rb
|
68
|
+
- lib/cls-ruby/tag_vector_of_different_tags.rb
|
69
|
+
- lib/cls-ruby/tag_vector_of_tags.rb
|
70
|
+
- lib/cls-ruby/vector_of_tags_impl.rb
|
71
|
+
- lib/cls-ruby/constraints/one_of.rb
|
72
|
+
- lib/cls-ruby/lexers/char_classifier.rb
|
73
|
+
- lib/cls-ruby/lexers/first_stage.rb
|
74
|
+
- lib/cls-ruby/lexers/lexer.rb
|
75
|
+
- docs/base_formatting_methods
|
76
|
+
- docs/base_parsing_methods
|
77
|
+
- docs/constructor_params
|
78
|
+
- docs/examples
|
79
|
+
- docs/fragments
|
80
|
+
- docs/principles
|
81
|
+
- docs/std_tags_short_description
|
82
|
+
- docs/syntax
|
83
|
+
- docs/why_cls
|
84
|
+
- docs/examples/log_single_line_format
|
85
|
+
- docs/examples/service_description
|
86
|
+
- docs/examples/sms-hist
|
87
|
+
- docs/examples/tag_any
|
88
|
+
- docs/fragments/custom_tag_field.rb
|
89
|
+
- docs/fragments/custom_tag_include.rb
|
90
|
+
- docs/fragments/field.cls
|
91
|
+
- docs/fragments/include.cls
|
92
|
+
- docs/fragments/inherit_tag_params.rb
|
93
|
+
- docs/fragments/message.cls
|
94
|
+
- docs/fragments/tags_order.rb
|
95
|
+
- docs/fragments/tag_field.rb
|
96
|
+
- docs/fragments/tag_message.rb
|
97
|
+
- examples/hex_stream.txt
|
98
|
+
- examples/log_single_line_formatter.rb
|
99
|
+
- examples/service_description.day_time.cfg
|
100
|
+
- examples/service_description.rb
|
101
|
+
- examples/sms-hist.rb
|
102
|
+
- examples/space_concat.txt
|
103
|
+
- examples/tag_any.rb
|
104
|
+
- THANKS
|
105
|
+
- README
|
106
|
+
- LICENSE
|
107
|
+
test_files: []
|
108
|
+
|
109
|
+
rdoc_options:
|
110
|
+
- -c
|
111
|
+
- windows-1251
|
112
|
+
- -S
|
113
|
+
- --all
|
114
|
+
- -p
|
115
|
+
- -F
|
116
|
+
- --main
|
117
|
+
- README
|
118
|
+
extra_rdoc_files:
|
119
|
+
- README
|
120
|
+
- LICENSE
|
121
|
+
- docs/base_formatting_methods
|
122
|
+
- docs/base_parsing_methods
|
123
|
+
- docs/constructor_params
|
124
|
+
- docs/examples
|
125
|
+
- docs/principles
|
126
|
+
- docs/std_tags_short_description
|
127
|
+
- docs/syntax
|
128
|
+
- docs/why_cls
|
129
|
+
- docs/examples/log_single_line_format
|
130
|
+
- docs/examples/service_description
|
131
|
+
- docs/examples/sms-hist
|
132
|
+
- docs/examples/tag_any
|
133
|
+
executables: []
|
134
|
+
|
135
|
+
extensions: []
|
136
|
+
|
137
|
+
requirements: []
|
138
|
+
|
139
|
+
dependencies: []
|
140
|
+
|