stringglob 0.0.1 → 0.0.2

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/lib/stringglob.rb CHANGED
@@ -1,34 +1,41 @@
1
1
  ## Ruby StringGlob: Generate a Regexp object from a glob(3) pattern
2
- ## (Port Text::Glob 0.08 from Perl to Ruby)
3
- ## Copyright (c) 2002, 2003, 2006, 2007 Richard Clamp. All Rights Reserved.
4
- ## Copyright (c) 2009-2011 SATOH Fumiyasu @ OSS Technology Inc.
5
- ## <http://www.osstech.co.jp/>
6
2
  ##
7
- ## License: This module is free software; you can redistribute it and/or
8
- ## modify it under the same terms as Ruby itself
9
- ## Date: 2011-06-21, since 2009-07-15
3
+ ## Author:: SATOH Fumiyasu
4
+ ## Copyright:: (c) 2007-2011 SATOH Fumiyasu @ OSS Technology, Corp.
5
+ ## License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ ## Date:: 2011-06-21, since 2009-07-15
7
+ ##
8
+
9
+ ## This is a Ruby version of Perl Text::Glob 0.08
10
+ ## Copyright (c) 2002, 2003, 2006, 2007 Richard Clamp. All Rights Reserved.
10
11
 
11
12
  require "stringglob/version"
12
13
 
14
+ ## Generate a Regexp object from a glob(3) pattern
13
15
  module StringGlob
16
+ ## Ignore case
14
17
  IGNORE_CASE = 1 << 0
15
- NO_STRICT_LEADING_DOT = 1 << 1
16
- NO_STRICT_WILDCARD_SLASH = 1 << 2
18
+ ## Leading star '*' mathces leading dot '.'
19
+ STAR_MATCHES_LEADING_DOT = 1 << 1
20
+ ## Star '*' mathces slash '/'
21
+ STAR_MATCHES_SLASH = 1 << 2
17
22
 
23
+ ## Returns a Regex object which is the equivalent of the globbing pattern.
18
24
  def regexp(glob, opt = 0, code = nil)
19
25
  re = regexp_string(glob, opt)
20
26
  return Regexp.new("\\A#{re}\\z", nil, code)
21
27
  end
22
28
  module_function :regexp
23
29
 
30
+ ## Returns a regexp String object which is the equivalent of the globbing pattern.
24
31
  def regexp_string(glob, opt = 0)
25
32
  re_str = ''
26
33
  in_curlies = 0
27
34
  escaping = false
28
35
  first_byte = true
29
36
  asterisk = false
30
- strict_leading_dot = (opt & NO_STRICT_LEADING_DOT == 0)
31
- strict_wildcard_slash = (opt & NO_STRICT_WILDCARD_SLASH == 0)
37
+ strict_leading_dot = (opt & STAR_MATCHES_LEADING_DOT == 0)
38
+ strict_wildcard_slash = (opt & STAR_MATCHES_SLASH == 0)
32
39
  glob.scan(/./m) do |glob_c|
33
40
  if first_byte
34
41
  if strict_leading_dot
@@ -1,3 +1,3 @@
1
1
  module StringGlob
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2" ## :nodoc:
3
3
  end
@@ -39,21 +39,21 @@ class StringGlobTest < Test::Unit::TestCase
39
39
  ## strict . rule match
40
40
  assert_not_nil SG.regexp('.*.foo').match('.file.foo')
41
41
  ## relaxed . rule
42
- assert_not_nil SG.regexp('*.foo', SG::NO_STRICT_LEADING_DOT).match('.file.foo')
42
+ assert_not_nil SG.regexp('*.foo', SG::STAR_MATCHES_LEADING_DOT).match('.file.foo')
43
43
 
44
44
  ## strict wildcard / fail
45
45
  assert_nil SG.regexp('*.fo?').match('foo/file.fob')
46
46
  ## strict wildcard / match
47
47
  assert_not_nil SG.regexp('*/*.fo?').match('foo/file.fob')
48
48
  ## relaxed wildcard /
49
- assert_not_nil SG.regexp('*.fo?', SG::NO_STRICT_WILDCARD_SLASH).match('foo/file.fob')
49
+ assert_not_nil SG.regexp('*.fo?', SG::STAR_MATCHES_SLASH).match('foo/file.fob')
50
50
 
51
51
  ## more strict wildcard / fail
52
52
  assert_nil SG.regexp('foo/*.foo').match('foo/.foo')
53
53
  ## more strict wildcard / match
54
54
  assert_not_nil SG.regexp('foo/.f*').match('foo/.foo')
55
55
  ## relaxed wildcard /
56
- assert_not_nil SG.regexp('*.foo', SG::NO_STRICT_WILDCARD_SLASH).match('foo/.foo')
56
+ assert_not_nil SG.regexp('*.foo', SG::STAR_MATCHES_SLASH).match('foo/.foo')
57
57
 
58
58
  ## properly escape +
59
59
  assert_not_nil SG.regexp('f+.foo').match('f+.foo')
metadata CHANGED
@@ -1,33 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: stringglob
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - SATOH Fumiyasu
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-26 00:00:00 Z
12
+ date: 2011-10-31 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: Generate a Regexp object from a glob(3) pattern
22
- email:
15
+ email:
23
16
  - fumiyas@osstech.co.jp
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
19
  extra_rdoc_files: []
29
-
30
- files:
20
+ files:
31
21
  - .gitignore
32
22
  - Gemfile
33
23
  - Rakefile
@@ -35,38 +25,29 @@ files:
35
25
  - lib/stringglob/version.rb
36
26
  - stringglob.gemspec
37
27
  - test/test_stringglob.rb
38
- homepage: ""
28
+ homepage: ''
39
29
  licenses: []
40
-
41
30
  post_install_message:
42
31
  rdoc_options: []
43
-
44
- require_paths:
32
+ require_paths:
45
33
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
34
+ required_ruby_version: !ruby/object:Gem::Requirement
47
35
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- hash: 3
52
- segments:
53
- - 0
54
- version: "0"
55
- required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
41
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
64
46
  requirements: []
65
-
66
47
  rubyforge_project: stringglob
67
- rubygems_version: 1.7.2
48
+ rubygems_version: 1.8.10
68
49
  signing_key:
69
50
  specification_version: 3
70
51
  summary: Generate a Regexp object from a glob(3) pattern
71
- test_files:
52
+ test_files:
72
53
  - test/test_stringglob.rb