grizzled-ruby 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +15 -0
- data/grizzled-ruby.gemspec +2 -2
- data/grizzled-ruby.iml +9 -0
- data/lib/grizzled/fileutil/includer.rb +12 -6
- data/test/fileutil/tc_includer.rb +31 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1d47485666a44d0c6b8f14c3372af933bfe142d
|
4
|
+
data.tar.gz: fdfab3b4ce6f7cadf7a7fc47764425789e157bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14166d49fd3e5e93adbfd8a5e79ed282d9952561a536096686633a4b2cad858919144163d89633cbd670300efe4447c4001b915f7fe7d1c26aed594c9312c582
|
7
|
+
data.tar.gz: 65ad1894cdd9f6018807b7ee697d96e4807972c29332cc33dcdbc9b71d6c105261090b4fc5c31a1461d2a0c64f9e65e31e9c76e2e23142dcdaead31c8a65a739
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log for Grizzled Ruby
|
2
2
|
|
3
|
+
Version 0.1.9 (28 September, 2015)
|
4
|
+
|
5
|
+
- Updated `Grizzled::FileUtil::Includer` to sort globbed files, by default.
|
6
|
+
|
7
|
+
Version 0.1.8 (8 September, 2015)
|
8
|
+
|
9
|
+
- Updated `Grizzled::FileUtil::Includer` to handle glob paths.
|
10
|
+
- Fixed various tests and tested against Ruby 2.
|
11
|
+
|
3
12
|
Version 0.1.5 (...)
|
4
13
|
|
5
14
|
- Added `WrapMany` class.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
coderay (1.1.0)
|
5
|
+
method_source (0.8.2)
|
6
|
+
power_assert (0.2.4)
|
7
|
+
pry (0.10.2)
|
8
|
+
coderay (~> 1.1.0)
|
9
|
+
method_source (~> 0.8.1)
|
10
|
+
slop (~> 3.4)
|
4
11
|
rake (10.4.2)
|
12
|
+
slop (3.6.0)
|
13
|
+
test-unit (3.1.3)
|
14
|
+
power_assert
|
5
15
|
zip (2.0.2)
|
6
16
|
|
7
17
|
PLATFORMS
|
8
18
|
ruby
|
9
19
|
|
10
20
|
DEPENDENCIES
|
21
|
+
pry
|
11
22
|
rake
|
23
|
+
test-unit
|
12
24
|
zip
|
25
|
+
|
26
|
+
BUNDLED WITH
|
27
|
+
1.10.6
|
data/grizzled-ruby.gemspec
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
|
5
5
|
s.name = 'grizzled-ruby'
|
6
|
-
s.version = '0.1.
|
7
|
-
s.date = '2015-09-
|
6
|
+
s.version = '0.1.9'
|
7
|
+
s.date = '2015-09-28'
|
8
8
|
s.summary = 'Some general-purpose Ruby modules, classes, and tools'
|
9
9
|
s.authors = ['Brian M. Clapper']
|
10
10
|
s.license = 'BSD'
|
data/grizzled-ruby.iml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
|
+
<exclude-output />
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
6
|
+
<orderEntry type="inheritedJdk" />
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
8
|
+
</component>
|
9
|
+
</module>
|
@@ -174,11 +174,14 @@ module Grizzled
|
|
174
174
|
# or URL. Default: ^%include\s"([^"]+)"
|
175
175
|
# allow_glob:: For file names, allow and expand glob expressions.
|
176
176
|
# Doesn't apply to URLs.
|
177
|
+
# sort_glob: true to force a sort of the globbed expression
|
178
|
+
# (default), false not to sort.
|
177
179
|
def initialize(source, options={})
|
178
180
|
@max_nesting = options.fetch(:max_nesting, 100)
|
179
181
|
inc_pattern = options.fetch(:include_pattern, '^%include\s"([^"]+)"')
|
180
182
|
@include_re = /#{inc_pattern}/
|
181
183
|
@allow_glob = options.fetch(:allow_glob, false)
|
184
|
+
@sort_glob = options.fetch(:sort_glob, true)
|
182
185
|
includer_source = source_to_includer_source source
|
183
186
|
@source_uri = includer_source.uri
|
184
187
|
@temp = preprocess includer_source
|
@@ -203,9 +206,9 @@ module Grizzled
|
|
203
206
|
|
204
207
|
def source_to_includer_source(source)
|
205
208
|
if source.class == String
|
206
|
-
open_source(URI::parse(source))
|
209
|
+
open_source(URI::parse(source), source)
|
207
210
|
elsif source.class == File
|
208
|
-
open_source(URI::parse(source.path))
|
211
|
+
open_source(URI::parse(source.path), source.path)
|
209
212
|
elsif source.respond_to? :each_line
|
210
213
|
IncludeSource.new(source, nil)
|
211
214
|
else
|
@@ -261,16 +264,17 @@ module Grizzled
|
|
261
264
|
File.join(::File.dirname(cur_uri.path), source)
|
262
265
|
)
|
263
266
|
uri = FakeURI.new(abs)
|
267
|
+
source = abs
|
264
268
|
end
|
265
269
|
end
|
266
270
|
|
267
|
-
open_source(uri)
|
271
|
+
open_source(uri, source)
|
268
272
|
end
|
269
273
|
|
270
274
|
# Open an input source, based on a parsed URI.
|
271
|
-
def open_source(uri)
|
275
|
+
def open_source(uri, source)
|
272
276
|
case uri.scheme
|
273
|
-
when nil then f = open_path(
|
277
|
+
when nil then f = open_path(source) # assume file/path
|
274
278
|
when 'file' then f = open(uri.path) # open path directly
|
275
279
|
when 'http' then f = open(uri.to_s) # open-uri will handle it
|
276
280
|
when 'https' then f = open(uri.to_s) # open-uri will handle it
|
@@ -284,7 +288,9 @@ module Grizzled
|
|
284
288
|
|
285
289
|
def open_path(path)
|
286
290
|
if @allow_glob
|
287
|
-
|
291
|
+
globs = Dir.glob(path)
|
292
|
+
globs.sort! if @sort_glob
|
293
|
+
FileIterator.new(globs)
|
288
294
|
else
|
289
295
|
File.open(path)
|
290
296
|
end
|
@@ -65,8 +65,8 @@ EOF
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
69
|
-
temps = ["/tmp/foo.txt", "/tmp/
|
68
|
+
def test_glob_unsorted
|
69
|
+
temps = ["/tmp/foo.txt", "/tmp/boo1.txt", "/tmp/foo2.txt"]
|
70
70
|
main = File.open(temps[0], "w")
|
71
71
|
temp1 = File.open(temps[1], "w")
|
72
72
|
temp2 = File.open(temps[2], "w")
|
@@ -84,18 +84,44 @@ EOF2
|
|
84
84
|
temp1.close
|
85
85
|
temp2.close
|
86
86
|
File.open(main, "w") do |f|
|
87
|
-
f.write('%include "
|
87
|
+
f.write('%include "./?oo[0-9]*.txt"' + "\n")
|
88
88
|
end
|
89
89
|
|
90
|
-
|
90
|
+
main = File.open(temps[0])
|
91
|
+
inc = Includer.new(main, allow_glob: true, sort_glob: false)
|
91
92
|
contents = inc.read
|
92
|
-
|
93
|
+
assert_true(contents.include?("one-1\ntwo-1"))
|
93
94
|
ensure
|
94
95
|
[main, temp1, temp2].each { |f| f.close unless f.closed? }
|
95
96
|
temps.each { |path| File.delete(path) }
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
100
|
+
def test_glob_sorted
|
101
|
+
temps = ['/tmp/glob_z.txt', '/tmp/glob_a.txt', '/tmp/glob_m.txt']
|
102
|
+
main = "/tmp/glob_main.txt"
|
103
|
+
begin
|
104
|
+
temps.each do |t|
|
105
|
+
File.open(t, "w") do |f|
|
106
|
+
f.write("In #{t}\n")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
File.open(main, "w") do |f|
|
110
|
+
f.write('%include "/tmp/glob_?.txt"' + "\n")
|
111
|
+
end
|
112
|
+
|
113
|
+
contents = File.open(main) do |f|
|
114
|
+
Includer.new(f, allow_glob: true).read
|
115
|
+
end
|
116
|
+
expected = temps.sort.map { |s| "In #{s}\n" }.join('')
|
117
|
+
puts("contents=#{contents}")
|
118
|
+
puts("expected=#{expected}")
|
119
|
+
assert_equal(expected, contents)
|
120
|
+
ensure
|
121
|
+
(temps + [main]).each { |path| File.delete(path) }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
99
125
|
private
|
100
126
|
|
101
127
|
def make_include_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grizzled-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian M. Clapper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zip
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- README.md
|
45
45
|
- Rakefile
|
46
46
|
- grizzled-ruby.gemspec
|
47
|
+
- grizzled-ruby.iml
|
47
48
|
- lib/grizzled.rb
|
48
49
|
- lib/grizzled/dir.rb
|
49
50
|
- lib/grizzled/fileutil.rb
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
version: '0'
|
81
82
|
requirements: []
|
82
83
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.4.5.1
|
84
85
|
signing_key:
|
85
86
|
specification_version: 4
|
86
87
|
summary: Some general-purpose Ruby modules, classes, and tools
|