riel 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/riel/filetype.rb +1 -1
- data/lib/riel/rcfile.rb +23 -18
- data/test/riel/rcfile_test.rb +30 -26
- data/test/riel/regexp_test.rb +1 -1
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 556377e46b194e614f127b38aed69a4a219c7649
|
4
|
+
data.tar.gz: f8dcbbd034dca93cd8951c472b6a08a0f01921a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08816409b9098824794181fbb0169bca37ea211e0da34cc5d052d02a6ed34b37284bb3c9932c0440dfcf1a36a95ce36d2c2c287b4f56126dbfb43417ed58808b'
|
7
|
+
data.tar.gz: 2af4733c75275ceb397aa619269846a51bde309f568177d62a6560c83aaeb331747cfd91d7e229027b516d7fe3c68afc72c520a3f5952c77859c79f2b1ba06e5
|
data/lib/riel/filetype.rb
CHANGED
data/lib/riel/rcfile.rb
CHANGED
@@ -1,31 +1,36 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
# Represents a resource file, where '#' is used to comment to end of lines, and
|
5
|
-
#
|
4
|
+
# Represents a resource file, where '#' is used to comment to end of lines, and name/value pairs are
|
5
|
+
# separated by '=' or ':'.
|
6
6
|
|
7
7
|
class RCFile
|
8
8
|
attr_reader :settings
|
9
9
|
|
10
|
-
# Reads the RC file, if it exists, and if a block is passed, calls the block
|
11
|
-
#
|
12
|
-
# <code>settings</code>.
|
10
|
+
# Reads the RC file, if it exists, and if a block is passed, calls the block with each name/value
|
11
|
+
# pair, which are also accessible via <code>settings</code>.
|
13
12
|
|
14
|
-
def initialize
|
13
|
+
def initialize args = Hash.new, &blk
|
15
14
|
@settings = Array.new
|
15
|
+
|
16
|
+
unless lines = args[:lines]
|
17
|
+
if fname = args[:filename]
|
18
|
+
lines = IO::readlines fname
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
cmtre = Regexp.new '\s*#.*'
|
23
|
+
nvre = Regexp.new '\s*[=:]\s*'
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
name
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if blk
|
27
|
-
blk.call name, value
|
28
|
-
end
|
25
|
+
lines.each do |line|
|
26
|
+
line.sub! cmtre, ''
|
27
|
+
name, value = line.split nvre
|
28
|
+
if name && value
|
29
|
+
name.strip!
|
30
|
+
value.strip!
|
31
|
+
@settings << [ name, value ]
|
32
|
+
if blk
|
33
|
+
blk.call name, value
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/test/riel/rcfile_test.rb
CHANGED
@@ -3,36 +3,40 @@
|
|
3
3
|
|
4
4
|
require 'test/unit'
|
5
5
|
require 'riel/rcfile'
|
6
|
-
require '
|
6
|
+
require 'paramesan'
|
7
7
|
|
8
8
|
class RCFileTestCase < Test::Unit::TestCase
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
separators.each do |sep|
|
21
|
-
leading_spaces.each do |lsp|
|
22
|
-
trailing_spaces.each do |tsp|
|
23
|
-
comments.each do |cmt|
|
24
|
-
tf.puts "#{lsp}name#{num}#{sep}value#{num}#{tsp}#{cmt}"
|
25
|
-
num += 1
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
9
|
+
include Paramesan
|
10
|
+
|
11
|
+
def self.build_params
|
12
|
+
kv = [ "k", "v" ]
|
13
|
+
kvary = [ kv ]
|
14
|
+
|
15
|
+
Array.new.tap do |params|
|
16
|
+
params << [ Array.new, Array.new ]
|
17
|
+
params << [ Array.new, [ "" ] ]
|
18
|
+
[ "k:v", "k: v", "k :v", "k=v", "k= v", "k =v", "k:v ", " k:v" ].each do |line|
|
19
|
+
params << [ kvary, [ line ] ]
|
29
20
|
end
|
21
|
+
params << [ kvary, [ "", "k:v" ] ]
|
22
|
+
params << [ kvary, [ "# comment", "k:v" ] ]
|
23
|
+
params << [ kvary, [ " # comment", "k:v" ] ]
|
24
|
+
params << [ Array.new, [ "k:#v" ] ]
|
25
|
+
params << [ [ [ "k", "v" ] ], [ "k:v#x" ] ]
|
26
|
+
params << [ [ [ "k", "v" ], [ "k2", "v2" ] ], [ "k:v", "k2:v2" ] ]
|
30
27
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
end
|
29
|
+
|
30
|
+
param_test build_params do |exp, lines|
|
31
|
+
rc = RCFile.new lines: lines
|
32
|
+
assert_equal exp, rc.settings, "lines: #{lines}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_block
|
36
|
+
called = Array.new
|
37
|
+
RCFile.new(lines: [ "k:v" ]) do |key, value|
|
38
|
+
called << [ key, value ]
|
36
39
|
end
|
40
|
+
assert_equal [ [ "k", "v" ] ], called
|
37
41
|
end
|
38
42
|
end
|
data/test/riel/regexp_test.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Pace
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.1.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paramesan
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: This library extends the core Ruby libraries.
|
28
42
|
email: jeugenepace@gmail.com
|
29
43
|
executables: []
|
@@ -31,6 +45,7 @@ extensions: []
|
|
31
45
|
extra_rdoc_files:
|
32
46
|
- README.md
|
33
47
|
files:
|
48
|
+
- README.md
|
34
49
|
- lib/riel.rb
|
35
50
|
- lib/riel/command.rb
|
36
51
|
- lib/riel/date.rb
|
@@ -71,8 +86,7 @@ files:
|
|
71
86
|
- test/riel/string_test.rb
|
72
87
|
- test/riel/tempfile_test.rb
|
73
88
|
- test/riel/timer_test.rb
|
74
|
-
|
75
|
-
homepage: http://www.incava.org/projects/riel
|
89
|
+
homepage: http://www.github.com/jpace/riel
|
76
90
|
licenses: []
|
77
91
|
metadata: {}
|
78
92
|
post_install_message:
|
@@ -81,17 +95,17 @@ require_paths:
|
|
81
95
|
- lib
|
82
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
97
|
requirements:
|
84
|
-
- -
|
98
|
+
- - ">="
|
85
99
|
- !ruby/object:Gem::Version
|
86
100
|
version: '0'
|
87
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
102
|
requirements:
|
89
|
-
- -
|
103
|
+
- - ">="
|
90
104
|
- !ruby/object:Gem::Version
|
91
105
|
version: '0'
|
92
106
|
requirements: []
|
93
107
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.6.3
|
95
109
|
signing_key:
|
96
110
|
specification_version: 4
|
97
111
|
summary: Extensions to core Ruby code.
|