rubysl-abbrev 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 321139ae03de0cd8eb9e1e455a04b6c21ed1649a
4
- data.tar.gz: ee713c5d66e0236052c3627ac616e844ca8a4fdf
3
+ metadata.gz: 6b53112b1e7b1effa76b913fd0de2ca1fd1972e3
4
+ data.tar.gz: e83c7d4f2b9eae42a71200a33f4cec6d0010f39e
5
5
  SHA512:
6
- metadata.gz: 75e9c1bdc0263e556cc128f0d45589e929df12de7e15057a75a7a2ec9231cd090d48279d12aef88e93139e89646b5df085b8030bf6444252743aff875d8e1124
7
- data.tar.gz: c6f52cfd8c009323f021e732a586ec15e5972e1fb60779fcaee85349f6be15bc6e83843961323f1dd6f6abd3c5cc7ccec3e16daf7b8c65630519bc5276aace8f
6
+ metadata.gz: 20a0a301683577b202e7b860c24f8303ad406c6df11c2a82ff287ed5b9db8b0cdb1bf0d258ef201b24337c782f657ae7513d4e14dee6ec32fbb41d98e656fbad
7
+ data.tar.gz: 31fb7ccf0998829f687f10c5d4b0e45fc82cd45757955f48e722fd0ebfcdafa50fd80ebfcc391a17c4e498ae7a307f6e17e735b44b847385f550638f9be4d6db
data/.travis.yml CHANGED
@@ -1,9 +1,14 @@
1
1
  language: ruby
2
- before_install:
3
- - rvm use $RVM --install --binary --fuzzy
4
- - gem update --system
5
- - gem --version
6
- - gem install rubysl-bundler
7
2
  env:
8
- - RVM=rbx-nightly-d21 RUBYLIB=lib
9
- script: bundle exec mspec spec
3
+ - RUBYLIB=lib
4
+ - RUBYLIB=
5
+ script: mspec spec
6
+ rvm:
7
+ - 2.0.0
8
+ - rbx-2.1.1
9
+ matrix:
10
+ exclude:
11
+ - rvm: 2.0.0
12
+ env: RUBYLIB=lib
13
+ - rvm: rbx-2.1.1
14
+ env: RUBYLIB=
data/lib/abbrev.rb CHANGED
@@ -1 +1,3 @@
1
+ STDERR.puts $:.inspect
2
+ raise "oh no you di'nt!"
1
3
  require "rubysl/abbrev"
@@ -7,51 +7,75 @@
7
7
  #
8
8
  # $Idaemons: /home/cvs/rb/abbrev.rb,v 1.2 2001/05/30 09:37:45 knu Exp $
9
9
  # $RoughId: abbrev.rb,v 1.4 2003/10/14 19:45:42 knu Exp $
10
- # $Id: abbrev.rb 31635 2011-05-18 21:19:18Z drbrain $
10
+ # $Id: abbrev.rb 39362 2013-02-21 17:35:32Z zzak $
11
11
  #++
12
12
 
13
- # Calculate the set of unique abbreviations for a given set of strings.
13
+ ##
14
+ # Calculates the set of unique abbreviations for a given set of strings.
14
15
  #
15
16
  # require 'abbrev'
16
17
  # require 'pp'
17
18
  #
18
- # pp Abbrev::abbrev(['ruby', 'rules']).sort
19
+ # pp Abbrev.abbrev(['ruby', 'rules'])
19
20
  #
20
- # <i>Generates:</i>
21
+ # Generates:
21
22
  #
22
- # [["rub", "ruby"],
23
- # ["ruby", "ruby"],
24
- # ["rul", "rules"],
25
- # ["rule", "rules"],
26
- # ["rules", "rules"]]
23
+ # { "rub" => "ruby",
24
+ # "ruby" => "ruby",
25
+ # "rul" => "rules",
26
+ # "rule" => "rules",
27
+ # "rules" => "rules" }
27
28
  #
28
- # Also adds an +abbrev+ method to class +Array+.
29
+ # It also provides an array core extension, Array#abbrev.
30
+ #
31
+ # pp %w{summer winter}.abbrev
32
+ # #=> {"summe"=>"summer",
33
+ # "summ"=>"summer",
34
+ # "sum"=>"summer",
35
+ # "su"=>"summer",
36
+ # "s"=>"summer",
37
+ # "winte"=>"winter",
38
+ # "wint"=>"winter",
39
+ # "win"=>"winter",
40
+ # "wi"=>"winter",
41
+ # "w"=>"winter",
42
+ # "summer"=>"summer",
43
+ # "winter"=>"winter"}
29
44
 
30
45
  module Abbrev
31
46
 
32
47
  # Given a set of strings, calculate the set of unambiguous
33
48
  # abbreviations for those strings, and return a hash where the keys
34
49
  # are all the possible abbreviations and the values are the full
35
- # strings. Thus, given input of "car" and "cone", the keys pointing
36
- # to "car" would be "ca" and "car", while those pointing to "cone"
37
- # would be "co", "con", and "cone".
50
+ # strings.
51
+ #
52
+ # Thus, given +words+ is "car" and "cone", the keys pointing to "car" would
53
+ # be "ca" and "car", while those pointing to "cone" would be "co", "con", and
54
+ # "cone".
55
+ #
56
+ # require 'abbrev'
57
+ #
58
+ # Abbrev.abbrev(['car', 'cone'])
59
+ # #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"}
38
60
  #
39
61
  # The optional +pattern+ parameter is a pattern or a string. Only
40
- # those input strings matching the pattern, or begging the string,
41
- # are considered for inclusion in the output hash
42
-
62
+ # input strings that match the pattern or start with the string
63
+ # are included in the output hash.
64
+ #
65
+ # Abbrev.abbrev(%w{car box cone}, /b/)
66
+ # #=> {"bo"=>"box", "b"=>"box", "box"=>"box"}
43
67
  def abbrev(words, pattern = nil)
44
68
  table = {}
45
69
  seen = Hash.new(0)
46
70
 
47
71
  if pattern.is_a?(String)
48
- pattern = /^#{Regexp.quote(pattern)}/ # regard as a prefix
72
+ pattern = /\A#{Regexp.quote(pattern)}/ # regard as a prefix
49
73
  end
50
74
 
51
75
  words.each do |word|
52
- next if (abbrev = word).empty?
53
- while (len = abbrev.rindex(/[\w\W]\z/)) > 0
54
- abbrev = word[0,len]
76
+ next if word.empty?
77
+ word.size.downto(1) { |len|
78
+ abbrev = word[0...len]
55
79
 
56
80
  next if pattern && pattern !~ abbrev
57
81
 
@@ -63,7 +87,7 @@ module Abbrev
63
87
  else
64
88
  break
65
89
  end
66
- end
90
+ }
67
91
  end
68
92
 
69
93
  words.each do |word|
@@ -80,12 +104,22 @@ end
80
104
 
81
105
  class Array
82
106
  # Calculates the set of unambiguous abbreviations for the strings in
83
- # +self+. If passed a pattern or a string, only the strings matching
84
- # the pattern or starting with the string are considered.
107
+ # +self+.
108
+ #
109
+ # require 'abbrev'
110
+ # %w{ car cone }.abbrev
111
+ # #=> {"ca" => "car", "con"=>"cone", "co" => "cone",
112
+ # "car"=>"car", "cone" => "cone"}
113
+ #
114
+ # The optional +pattern+ parameter is a pattern or a string. Only
115
+ # input strings that match the pattern or start with the string
116
+ # are included in the output hash.
117
+ #
118
+ # %w{ fast boat day }.abbrev(/^.a/)
119
+ # #=> {"fas"=>"fast", "fa"=>"fast", "da"=>"day",
120
+ # "fast"=>"fast", "day"=>"day"}
85
121
  #
86
- # %w{ car cone }.abbrev #=> { "ca" => "car", "car" => "car",
87
- # "co" => "cone", "con" => cone",
88
- # "cone" => "cone" }
122
+ # See also Abbrev.abbrev
89
123
  def abbrev(pattern = nil)
90
124
  Abbrev::abbrev(self, pattern)
91
125
  end
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module Abbrev
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysl-abbrev
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2013-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
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.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubysl-prettyprint
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.0'
69
69
  description: Ruby standard library abbrev.
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
78
  - Gemfile
79
79
  - LICENSE
80
80
  - README.md
@@ -95,12 +95,12 @@ require_paths:
95
95
  - lib
96
96
  required_ruby_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ~>
98
+ - - "~>"
99
99
  - !ruby/object:Gem::Version
100
100
  version: '2.0'
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []