mustermann-contrib 3.0.4 → 3.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c0c40b0826ffa45cc63ae438017ecee316750c370d6bfeac1470c3c9f00fbbd
4
- data.tar.gz: 1312ab31f470e624148c3bb26bc020db1723940b161b85c080a05cc8e1b2b787
3
+ metadata.gz: d3990aa843c8c57b75fc5e7a5a8fa0b0d56f6f46c6a8e4ad8a5b408066b3ee96
4
+ data.tar.gz: 82b5f3729b4ae440bb94be9117558bd83dbead5b07599254dc3255104cab3f5e
5
5
  SHA512:
6
- metadata.gz: 75a1d17dfba9808fb7b2c2c5cfeb2ef76622f09aba6d90dc373b6f712cd4e9493624713ec42113d529dffb5dd363d4e54ddf6ad8990cfccacc2503ed639aec6b
7
- data.tar.gz: 845a5141b2260ed0b6182bcf98ebd2c7279a32dbee50fe916301e20477815e8c793721009af74440577eedfa40a37ac61d6227551840580fec7dcc8ea820a593
6
+ metadata.gz: bd18842741789080329166170db2b904af298f2bd80e797e259bb02740aab45ea313f3009f0570079db11cf0d3728b38fb8833c94004b52f43123a27835a3035
7
+ data.tar.gz: 7d7a909d1970370e86097380bbd0ca47c04e2d34ef2e41ed10d2da1ce60a21976e3b7a814b2d549cd4cbdcee6f6ba3398ba1922a524c7e8d87b0d88336c1c8b3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustermann-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.4
19
+ version: 3.1.0
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
- version: 3.0.4
26
+ version: 3.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hansi
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -46,9 +46,6 @@ extra_rdoc_files: []
46
46
  files:
47
47
  - LICENSE
48
48
  - README.md
49
- - examples/highlighting.rb
50
- - highlighting.png
51
- - irb.png
52
49
  - lib/mustermann/cake.rb
53
50
  - lib/mustermann/express.rb
54
51
  - lib/mustermann/file_utils.rb
@@ -56,14 +53,12 @@ files:
56
53
  - lib/mustermann/fileutils.rb
57
54
  - lib/mustermann/flask.rb
58
55
  - lib/mustermann/pyramid.rb
59
- - lib/mustermann/rails.rb
60
56
  - lib/mustermann/shell.rb
61
57
  - lib/mustermann/simple.rb
62
58
  - lib/mustermann/string_scanner.rb
63
59
  - lib/mustermann/strscan.rb
64
60
  - lib/mustermann/template.rb
65
61
  - lib/mustermann/uri_template.rb
66
- - lib/mustermann/versions.rb
67
62
  - lib/mustermann/visualizer.rb
68
63
  - lib/mustermann/visualizer/highlight.rb
69
64
  - lib/mustermann/visualizer/highlighter.rb
@@ -80,22 +75,6 @@ files:
80
75
  - lib/mustermann/visualizer/renderer/sexp.rb
81
76
  - lib/mustermann/visualizer/tree.rb
82
77
  - lib/mustermann/visualizer/tree_renderer.rb
83
- - mustermann-contrib.gemspec
84
- - spec/cake_spec.rb
85
- - spec/express_spec.rb
86
- - spec/file_utils_spec.rb
87
- - spec/flask_spec.rb
88
- - spec/flask_subclass_spec.rb
89
- - spec/pattern_extension_spec.rb
90
- - spec/pyramid_spec.rb
91
- - spec/rails_spec.rb
92
- - spec/shell_spec.rb
93
- - spec/simple_spec.rb
94
- - spec/string_scanner_spec.rb
95
- - spec/template_spec.rb
96
- - spec/visualizer_spec.rb
97
- - theme.png
98
- - tree.png
99
78
  homepage: https://github.com/sinatra/mustermann
100
79
  licenses:
101
80
  - MIT
@@ -107,14 +86,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
86
  requirements:
108
87
  - - ">="
109
88
  - !ruby/object:Gem::Version
110
- version: 2.6.0
89
+ version: 2.7.0
111
90
  required_rubygems_version: !ruby/object:Gem::Requirement
112
91
  requirements:
113
92
  - - ">="
114
93
  - !ruby/object:Gem::Version
115
94
  version: '0'
116
95
  requirements: []
117
- rubygems_version: 3.6.9
96
+ rubygems_version: 4.0.6
118
97
  specification_version: 4
119
98
  summary: Collection of extensions for Mustermann
120
99
  test_files: []
@@ -1,35 +0,0 @@
1
- require 'bundler/setup'
2
- require 'mustermann/visualizer'
3
-
4
- Hansi.mode = ARGV[0].to_i if ARGV.any?
5
-
6
- def self.example(type, *patterns)
7
- print Hansi.render(:bold, " #{type}: ".ljust(14))
8
- patterns.each do |pattern|
9
- pattern = Mustermann.new(pattern, type: type)
10
- space_after = pattern.to_s.size > 24 ? " " : " " * (25 - pattern.to_s.size)
11
- highlight = Mustermann::Visualizer.highlight(pattern, inspect: true)
12
- print highlight.to_ansi + space_after
13
- end
14
- puts
15
- end
16
-
17
- puts
18
- example(:cake, '/:prefix/**')
19
- example(:express, '/:prefix+/:id(\d+)', '/:page/:slug+')
20
- example(:flask, '/<prefix>/<int:id>', '/user/<int(min=0):id>')
21
- example(:identity, '/image.png')
22
- example(:pyramid, '/{prefix:.*}/{id}', '/{page}/*slug')
23
- example(:rails, '/:slug(.:ext)')
24
- example(:regexp, '/(?<slug>[^/]+)', '/(?:page|user)/(\d+)')
25
- example(:shell, '/**/*', '/\{a,b\}/{a,b}')
26
- example(:simple, '/:page/*slug')
27
- example(:sinatra, '/:page/*slug', '/users/{id}?')
28
- example(:template, '/{+pre}/{page}{?q,p}', '/users/{id}?')
29
- puts
30
-
31
- example(:composition)
32
- composite = Mustermann.new("/{a}", "/{b}/{c}")
33
- puts " " + composite.to_ansi
34
- puts " " + (Mustermann.new("/") ^ composite).to_ansi
35
- puts
data/highlighting.png DELETED
Binary file
data/irb.png DELETED
Binary file
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mustermann'
3
- require 'mustermann/ast/pattern'
4
- require 'mustermann/versions'
5
-
6
- module Mustermann
7
- # Rails style pattern implementation.
8
- #
9
- # @example
10
- # Mustermann.new('/:foo', type: :rails) === '/bar' # => true
11
- #
12
- # @see Mustermann::Pattern
13
- # @see file:README.md#rails Syntax description in the README
14
- class Rails < AST::Pattern
15
- extend Versions
16
- register :rails
17
-
18
- # first parser, no optional parts
19
- version('2.3') do
20
- on(nil) { |c| unexpected(c) }
21
- on(?*) { |c| node(:named_splat) { scan(/\w+/) } }
22
- on(?:) { |c| node(:capture) { scan(/\w+/) } }
23
- end
24
-
25
- # rack-mount
26
- version('3.0', '3.1') do
27
- on(?)) { |c| unexpected(c) }
28
- on(?() { |c| node(:optional, node(:group) { read unless scan(?)) }) }
29
- on(?\\) { |c| node(:char, expect(/./)) }
30
- end
31
-
32
- # stand-alone journey
33
- version('3.2') do
34
- on(?|) { |c| raise ParseError, "the implementation of | is broken in ActionDispatch, cannot compile compatible pattern" }
35
- on(?\\) { |c| node(:char, c) }
36
- end
37
-
38
- # embedded journey, broken (ignored) escapes
39
- version('4.0', '4.1') { on(?\\) { |c| read } }
40
-
41
- # escapes got fixed in 4.2
42
- version('4.2') { on(?\\) { |c| node(:char, expect(/./)) } }
43
-
44
- # Rails 5.0 fixes |
45
- version('5.0') { on(?|) { |c| node(:or) }}
46
- end
47
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
- module Mustermann
3
- # Mixin that adds support for multiple versions of the same type.
4
- # @see Mustermann::Rails
5
- # @!visibility private
6
- module Versions
7
- # Checks if class has mulitple versions available and picks one that matches the version option.
8
- # @!visibility private
9
- def new(*args, version: nil, **options)
10
- return super(*args, **options) unless versions.any?
11
- self[version].new(*args, **options)
12
- end
13
-
14
- # @return [Hash] version to subclass mapping.
15
- # @!visibility private
16
- def versions
17
- @versions ||= {}
18
- end
19
-
20
- # Defines a new version.
21
- # @!visibility private
22
- def version(*list, inherit_from: nil, &block)
23
- superclass = self[inherit_from] || self
24
- subclass = Class.new(superclass, &block)
25
- list.each { |v| versions[v] = subclass }
26
- end
27
-
28
- # Resolve a subclass for a given version string.
29
- # @!visibility private
30
- def [](version)
31
- return versions.values.last unless version
32
- detected = versions.detect { |v,_| version.start_with?(v) }
33
- raise ArgumentError, 'unsupported version %p' % version unless detected
34
- detected.last
35
- end
36
-
37
- # @!visibility private
38
- def name
39
- super || superclass.name
40
- end
41
-
42
- # @!visibility private
43
- def inspect
44
- name
45
- end
46
- end
47
- end
@@ -1,18 +0,0 @@
1
- $:.unshift File.expand_path("../../mustermann/lib", __FILE__)
2
- require "mustermann/version"
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "mustermann-contrib"
6
- s.version = Mustermann::VERSION
7
- s.authors = ["Konstantin Haase", "Zachary Scott"]
8
- s.email = "sinatrarb@googlegroups.com"
9
- s.homepage = "https://github.com/sinatra/mustermann"
10
- s.summary = %q{Collection of extensions for Mustermann}
11
- s.description = %q{Adds many plugins to Mustermann}
12
- s.license = 'MIT'
13
- s.required_ruby_version = '>= 2.6.0'
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.add_dependency 'mustermann', Mustermann::VERSION
17
- s.add_dependency 'hansi', '~> 0.2.0'
18
- end
data/spec/cake_spec.rb DELETED
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'support'
3
- require 'mustermann/cake'
4
-
5
- describe Mustermann::Cake do
6
- extend Support::Pattern
7
-
8
- pattern '' do
9
- it { should match('') }
10
- it { should_not match('/') }
11
-
12
- it { should expand.to('') }
13
- it { should_not expand(a: 1) }
14
-
15
- it { should generate_template('') }
16
-
17
- it { should respond_to(:expand) }
18
- it { should respond_to(:to_templates) }
19
- end
20
-
21
- pattern '/' do
22
- it { should match('/') }
23
- it { should_not match('/foo') }
24
-
25
- it { should expand.to('/') }
26
- it { should_not expand(a: 1) }
27
- end
28
-
29
- pattern '/foo' do
30
- it { should match('/foo') }
31
- it { should_not match('/bar') }
32
- it { should_not match('/foo.bar') }
33
-
34
- it { should expand.to('/foo') }
35
- it { should_not expand(a: 1) }
36
- end
37
-
38
- pattern '/foo/bar' do
39
- it { should match('/foo/bar') }
40
- it { should_not match('/foo%2Fbar') }
41
- it { should_not match('/foo%2fbar') }
42
-
43
- it { should expand.to('/foo/bar') }
44
- it { should_not expand(a: 1) }
45
- end
46
-
47
- pattern '/:foo' do
48
- it { should match('/foo') .capturing foo: 'foo' }
49
- it { should match('/bar') .capturing foo: 'bar' }
50
- it { should match('/foo.bar') .capturing foo: 'foo.bar' }
51
- it { should match('/%0Afoo') .capturing foo: '%0Afoo' }
52
- it { should match('/foo%2Fbar') .capturing foo: 'foo%2Fbar' }
53
-
54
- it { should_not match('/foo?') }
55
- it { should_not match('/foo/bar') }
56
- it { should_not match('/') }
57
- it { should_not match('/foo/') }
58
-
59
- example { pattern.params('/foo') .should be == {"foo" => "foo"} }
60
- example { pattern.params('/f%20o') .should be == {"foo" => "f o"} }
61
- example { pattern.params('').should be_nil }
62
-
63
- it { should expand(foo: 'bar') .to('/bar') }
64
- it { should expand(foo: 'b r') .to('/b%20r') }
65
- it { should expand(foo: 'foo/bar') .to('/foo%2Fbar') }
66
-
67
- it { should_not expand(foo: 'foo', bar: 'bar') }
68
- it { should_not expand(bar: 'bar') }
69
- it { should_not expand }
70
-
71
- it { should generate_template('/{foo}') }
72
- end
73
-
74
- pattern '/*' do
75
- it { should match('/') }
76
- it { should match('/foo') }
77
- it { should match('/foo/bar') }
78
-
79
- example { pattern.params('/foo/bar') .should be == {"splat" => ["foo", "bar"]}}
80
- it { should generate_template('/{+splat}') }
81
- end
82
-
83
- pattern '/**' do
84
- it { should match('/') .capturing splat: '' }
85
- it { should match('/foo') .capturing splat: 'foo' }
86
- it { should match('/foo/bar') .capturing splat: 'foo/bar' }
87
-
88
- example { pattern.params('/foo/bar') .should be == {"splat" => ["foo/bar"]} }
89
- it { should generate_template('/{+splat}') }
90
- end
91
- end
data/spec/express_spec.rb DELETED
@@ -1,210 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'support'
3
- require 'mustermann/express'
4
-
5
- describe Mustermann::Express do
6
- extend Support::Pattern
7
-
8
- pattern '' do
9
- it { should match('') }
10
- it { should_not match('/') }
11
-
12
- it { should expand.to('') }
13
- it { should_not expand(a: 1) }
14
-
15
- it { should generate_template('') }
16
-
17
- it { should respond_to(:expand) }
18
- it { should respond_to(:to_templates) }
19
- end
20
-
21
- pattern '/' do
22
- it { should match('/') }
23
- it { should_not match('/foo') }
24
-
25
- it { should expand.to('/') }
26
- it { should_not expand(a: 1) }
27
- end
28
-
29
- pattern '/foo' do
30
- it { should match('/foo') }
31
- it { should_not match('/bar') }
32
- it { should_not match('/foo.bar') }
33
-
34
- it { should expand.to('/foo') }
35
- it { should_not expand(a: 1) }
36
- end
37
-
38
- pattern '/foo/bar' do
39
- it { should match('/foo/bar') }
40
- it { should_not match('/foo%2Fbar') }
41
- it { should_not match('/foo%2fbar') }
42
-
43
- it { should expand.to('/foo/bar') }
44
- it { should_not expand(a: 1) }
45
- end
46
-
47
- pattern '/:foo' do
48
- it { should match('/foo') .capturing foo: 'foo' }
49
- it { should match('/bar') .capturing foo: 'bar' }
50
- it { should match('/foo.bar') .capturing foo: 'foo.bar' }
51
- it { should match('/%0Afoo') .capturing foo: '%0Afoo' }
52
- it { should match('/foo%2Fbar') .capturing foo: 'foo%2Fbar' }
53
-
54
- it { should_not match('/foo?') }
55
- it { should_not match('/foo/bar') }
56
- it { should_not match('/') }
57
- it { should_not match('/foo/') }
58
-
59
- example { pattern.params('/foo') .should be == {"foo" => "foo"} }
60
- example { pattern.params('/f%20o') .should be == {"foo" => "f o"} }
61
- example { pattern.params('').should be_nil }
62
-
63
- it { should expand(foo: 'bar') .to('/bar') }
64
- it { should expand(foo: 'b r') .to('/b%20r') }
65
- it { should expand(foo: 'foo/bar') .to('/foo%2Fbar') }
66
-
67
- it { should_not expand(foo: 'foo', bar: 'bar') }
68
- it { should_not expand(bar: 'bar') }
69
- it { should_not expand }
70
-
71
- it { should generate_template('/{foo}') }
72
- end
73
-
74
- pattern '/:foo+' do
75
- it { should_not match('/') }
76
- it { should match('/foo') .capturing foo: 'foo' }
77
- it { should match('/foo/bar') .capturing foo: 'foo/bar' }
78
-
79
- it { should expand .to('/') }
80
- it { should expand(foo: nil) .to('/') }
81
- it { should expand(foo: '') .to('/') }
82
- it { should expand(foo: 'foo') .to('/foo') }
83
- it { should expand(foo: 'foo/bar') .to('/foo/bar') }
84
- it { should expand(foo: 'foo.bar') .to('/foo.bar') }
85
-
86
- it { should generate_template('/{+foo}') }
87
- end
88
-
89
- pattern '/:foo?' do
90
- it { should match('/foo') .capturing foo: 'foo' }
91
- it { should match('/bar') .capturing foo: 'bar' }
92
- it { should match('/foo.bar') .capturing foo: 'foo.bar' }
93
- it { should match('/%0Afoo') .capturing foo: '%0Afoo' }
94
- it { should match('/foo%2Fbar') .capturing foo: 'foo%2Fbar' }
95
- it { should match('/') }
96
-
97
- it { should_not match('/foo?') }
98
- it { should_not match('/foo/bar') }
99
- it { should_not match('/foo/') }
100
-
101
- example { pattern.params('/foo') .should be == {"foo" => "foo"} }
102
- example { pattern.params('/f%20o') .should be == {"foo" => "f o"} }
103
- example { pattern.params('/') .should be == {"foo" => nil } }
104
-
105
- it { should expand(foo: 'bar') .to('/bar') }
106
- it { should expand(foo: 'b r') .to('/b%20r') }
107
- it { should expand(foo: 'foo/bar') .to('/foo%2Fbar') }
108
- it { should expand .to('/') }
109
-
110
- it { should_not expand(foo: 'foo', bar: 'bar') }
111
- it { should_not expand(bar: 'bar') }
112
-
113
- it { should generate_template('/{foo}') }
114
- it { should generate_template('/') }
115
- end
116
-
117
- pattern '/:foo*' do
118
- it { should match('/') .capturing foo: '' }
119
- it { should match('/foo') .capturing foo: 'foo' }
120
- it { should match('/foo/bar') .capturing foo: 'foo/bar' }
121
-
122
- it { should expand .to('/') }
123
- it { should expand(foo: nil) .to('/') }
124
- it { should expand(foo: '') .to('/') }
125
- it { should expand(foo: 'foo') .to('/foo') }
126
- it { should expand(foo: 'foo/bar') .to('/foo/bar') }
127
- it { should expand(foo: 'foo.bar') .to('/foo.bar') }
128
-
129
- it { should generate_template('/{+foo}') }
130
- end
131
-
132
- pattern '/:foo(.*)' do
133
- it { should match('/') .capturing foo: '' }
134
- it { should match('/foo') .capturing foo: 'foo' }
135
- it { should match('/foo/bar') .capturing foo: 'foo/bar' }
136
-
137
- it { should expand(foo: '') .to('/') }
138
- it { should expand(foo: 'foo') .to('/foo') }
139
- it { should expand(foo: 'foo/bar') .to('/foo/bar') }
140
- it { should expand(foo: 'foo.bar') .to('/foo.bar') }
141
-
142
- it { should generate_template('/{foo}') }
143
- end
144
-
145
- pattern '/:foo(\d+)' do
146
- it { should_not match('/') }
147
- it { should_not match('/foo') }
148
- it { should match('/15') .capturing foo: '15' }
149
- it { should generate_template('/{foo}') }
150
- end
151
-
152
- pattern '/:foo(\d+|bar)' do
153
- it { should_not match('/') }
154
- it { should_not match('/foo') }
155
- it { should match('/15') .capturing foo: '15' }
156
- it { should match('/bar') .capturing foo: 'bar' }
157
- it { should generate_template('/{foo}') }
158
- end
159
-
160
- pattern '/:foo(\))' do
161
- it { should_not match('/') }
162
- it { should_not match('/foo') }
163
- it { should match('/)').capturing foo: ')' }
164
- it { should generate_template('/{foo}') }
165
- end
166
-
167
- pattern '/:foo(prefix(\d+|bar))' do
168
- it { should_not match('/prefix') }
169
- it { should_not match('/prefixfoo') }
170
- it { should match('/prefix15') .capturing foo: 'prefix15' }
171
- it { should match('/prefixbar') .capturing foo: 'prefixbar' }
172
- it { should generate_template('/{foo}') }
173
- end
174
-
175
- pattern '/(.+)' do
176
- it { should_not match('/') }
177
- it { should match('/foo') .capturing splat: 'foo' }
178
- it { should match('/foo/bar') .capturing splat: 'foo/bar' }
179
- it { should generate_template('/{+splat}') }
180
- end
181
-
182
- pattern '/(foo(a|b))' do
183
- it { should_not match('/') }
184
- it { should match('/fooa') .capturing splat: 'fooa' }
185
- it { should match('/foob') .capturing splat: 'foob' }
186
- it { should generate_template('/{+splat}') }
187
- end
188
-
189
- context 'invalid syntax' do
190
- example 'unexpected closing parenthesis' do
191
- expect { Mustermann::Express.new('foo)bar') }.
192
- to raise_error(Mustermann::ParseError, 'unexpected ) while parsing "foo)bar"')
193
- end
194
-
195
- example 'missing closing parenthesis' do
196
- expect { Mustermann::Express.new('foo(bar') }.
197
- to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo(bar"')
198
- end
199
-
200
- example 'unexpected ?' do
201
- expect { Mustermann::Express.new('foo?bar') }.
202
- to raise_error(Mustermann::ParseError, 'unexpected ? while parsing "foo?bar"')
203
- end
204
-
205
- example 'unexpected *' do
206
- expect { Mustermann::Express.new('foo*bar') }.
207
- to raise_error(Mustermann::ParseError, 'unexpected * while parsing "foo*bar"')
208
- end
209
- end
210
- end
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'support'
3
- require 'mustermann/file_utils'
4
-
5
- describe Mustermann::FileUtils do
6
- subject(:utils) { Mustermann::FileUtils }
7
- include FileUtils
8
-
9
- before do
10
- @pwd = Dir.pwd
11
- @tmp_dir = File.join(__dir__, 'tmp')
12
-
13
- mkdir_p(@tmp_dir)
14
- chdir(@tmp_dir)
15
-
16
- touch("foo.txt")
17
- touch("foo.rb")
18
- touch("bar.txt")
19
- touch("bar.rb")
20
- end
21
-
22
- after do
23
- chdir(@pwd) if @pwd
24
- rm_rf(@tmp_dir) if @tmp_dir
25
- end
26
-
27
- describe :glob_pattern do
28
- example { utils.glob_pattern('/:foo') .should be == '/*' }
29
- example { utils.glob_pattern('/*foo') .should be == '/**/*' }
30
- example { utils.glob_pattern('/(ab|c)?/:foo/d/*bar') .should be == '/{{ab,c},}/*/d/**/*' }
31
- example { utils.glob_pattern('/a', '/b') .should be == '{/a,/b}' }
32
- example { utils.glob_pattern('**/*', type: :shell) .should be == '**/*' }
33
- example { utils.glob_pattern(/can't parse this/) .should be == '**/*' }
34
- example { utils.glob_pattern('/foo', type: :identity) .should be == '/foo' }
35
- example { utils.glob_pattern('/fo*', type: :identity) .should be == '/fo\\*' }
36
- end
37
-
38
- describe :glob do
39
- example do
40
- utils.glob(":name.txt").sort.should be == ['bar.txt', 'foo.txt']
41
- end
42
-
43
- example do
44
- extensions = []
45
- utils.glob("foo.:ext") { |file, params| extensions << params['ext'] }
46
- extensions.sort.should be == ['rb', 'txt']
47
- end
48
-
49
- example do
50
- utils.glob(":name.:ext", capture: { ext: 'rb', name: 'foo' }).should be == ['foo.rb']
51
- end
52
- end
53
-
54
- describe :glob_map do
55
- example do
56
- utils.glob_map({':name.rb' => ':name/init.rb'}).should be == {
57
- "bar.rb" => "bar/init.rb",
58
- "foo.rb" => "foo/init.rb"
59
- }
60
- end
61
-
62
- example do
63
- result = {}
64
- returned = utils.glob_map({':name.rb' => ':name/init.rb'}) { |k, v| result[v] = k.upcase }
65
- returned.sort .should be == ["BAR.RB", "FOO.RB"]
66
- result["bar/init.rb"] .should be == "BAR.RB"
67
- end
68
- end
69
-
70
- describe :cp do
71
- example do
72
- utils.cp({':name.rb' => ':name.ruby', ':name.txt' => ':name.md'})
73
- File.should be_exist('foo.ruby')
74
- File.should be_exist('bar.md')
75
- File.should be_exist('bar.txt')
76
- end
77
- end
78
-
79
- describe :cp_r do
80
- example do
81
- mkdir_p "foo/bar"
82
- utils.cp_r({'foo/:name' => :name})
83
- File.should be_directory('bar')
84
- end
85
- end
86
-
87
- describe :mv do
88
- example do
89
- utils.mv({':name.rb' => ':name.ruby', ':name.txt' => ':name.md'})
90
- File.should be_exist('foo.ruby')
91
- File.should be_exist('bar.md')
92
- File.should_not be_exist('bar.txt')
93
- end
94
- end
95
-
96
- describe :ln do
97
- example do
98
- utils.ln({':name.rb' => ':name.ruby', ':name.txt' => ':name.md'})
99
- File.should be_exist('foo.ruby')
100
- File.should be_exist('bar.md')
101
- File.should be_exist('bar.txt')
102
- end
103
- end
104
-
105
- describe :ln_s do
106
- example do
107
- utils.ln_s({':name.rb' => ':name.ruby', ':name.txt' => ':name.md'})
108
- File.should be_symlink('foo.ruby')
109
- File.should be_symlink('bar.md')
110
- File.should be_exist('bar.txt')
111
- end
112
- end
113
-
114
- describe :ln_sf do
115
- example do
116
- utils.ln_sf({':name.rb' => ':name.txt'})
117
- File.should be_symlink('foo.txt')
118
- end
119
- end
120
- end