chars 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ === 0.1.1 / 2009-04-01
2
+
3
+ * Renamed CharSet#=~ to CharSet#===.
4
+ * Added an alias from CharSet#=~ to CharSet#===.
5
+
1
6
  === 0.1.0 / 2009-03-16
2
7
 
3
8
  * Initial release.
@@ -1,6 +1,7 @@
1
1
  History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
+ TODO.txt
4
5
  Rakefile
5
6
  lib/chars.rb
6
7
  lib/chars/char_set.rb
data/README.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  = Chars
2
2
 
3
3
  * http://chars.rubyforge.org/
4
- * http://github.com/postmodern/chars
4
+ * http://github.com/postmodern/chars/
5
5
  * Postmodern (postmodern.mod3 at gmail.com)
6
6
 
7
7
  == DESCRIPTION:
@@ -37,16 +37,22 @@ recognizing text and generating random text from specific character sets.
37
37
 
38
38
  == EXAMPLES:
39
39
 
40
- * Determine wether a byte belongs to a character set:
40
+ * Determine whether a byte belongs to a character set:
41
41
 
42
42
  0x41.alpha?
43
43
  # => true
44
44
 
45
- * Determine wether a String belongs to a character set:
45
+ * Determine whether a String belongs to a character set:
46
46
 
47
47
  "22e1c0".hex?
48
48
  # => true
49
49
 
50
+ * Find all sub-strings that belong to a character set within a String:
51
+
52
+ ls = File.read('/bin/ls')
53
+ Chars.printable.strings_in(ls)
54
+ # => ["/lib64/ld-linux-x86-64.so.2", "KIq/", "5J~!", "%L~!", ...]
55
+
50
56
  * Return a random character from the set of all characters:
51
57
 
52
58
  Chars.all.random_char
@@ -0,0 +1,13 @@
1
+ == TODO:
2
+
3
+ === 0.1.2:
4
+
5
+ * Remove CharSet#=~.
6
+
7
+ === 0.2.0:
8
+
9
+ * Implement unicode CharSets.
10
+ * Rewrite CharSet#===.
11
+ * Rewrite CharSet#strings_in.
12
+ * Add unicode sets to Chars.
13
+
@@ -162,7 +162,7 @@ module Chars
162
162
  index = 0
163
163
 
164
164
  while index <= (data.length - min_length)
165
- if self =~ data[index...(index + min_length)]
165
+ if self === data[index...(index + min_length)]
166
166
  sub_index = (index + min_length)
167
167
 
168
168
  while self.include_char?(data[sub_index..sub_index])
@@ -189,23 +189,25 @@ module Chars
189
189
 
190
190
  alias + |
191
191
 
192
- #
193
- # Returns +true+ if all of the bytes within the specified _string_
194
- # are included in the character set, returns +false+ otherwise.
195
- #
196
- # Chars.alpha =~ "hello"
197
- # # => true
198
- #
199
- def =~(string)
200
- return false unless string.respond_to?(:each_byte)
201
-
202
- string.each_byte do |b|
203
- return false unless include?(b)
204
- end
192
+ #
193
+ # Returns +true+ if all of the bytes within the specified _string_
194
+ # are included in the character set, returns +false+ otherwise.
195
+ #
196
+ # Chars.alpha === "hello"
197
+ # # => true
198
+ #
199
+ def ===(string)
200
+ return false unless string.respond_to?(:each_byte)
205
201
 
206
- return true
202
+ string.each_byte do |b|
203
+ return false unless include?(b)
207
204
  end
208
205
 
206
+ return true
207
+ end
208
+
209
+ alias =~ ===
210
+
209
211
  #
210
212
  # Inspects the character set.
211
213
  #
@@ -3,63 +3,63 @@ require 'chars/chars'
3
3
  class String
4
4
 
5
5
  def numeric?
6
- Chars::NUMERIC =~ self
6
+ Chars::NUMERIC === self
7
7
  end
8
8
 
9
9
  def octal?
10
- Chars::OCTAL =~ self
10
+ Chars::OCTAL === self
11
11
  end
12
12
 
13
13
  def uppercase_hex?
14
- Chars::UPPERCASE_HEXADECIMAL =~ self
14
+ Chars::UPPERCASE_HEXADECIMAL === self
15
15
  end
16
16
 
17
17
  def lowercase_hex?
18
- Chars::LOWERCASE_HEXADECIMAL =~ self
18
+ Chars::LOWERCASE_HEXADECIMAL === self
19
19
  end
20
20
 
21
21
  def hex?
22
- Chars::HEXADECIMAL =~ self
22
+ Chars::HEXADECIMAL === self
23
23
  end
24
24
 
25
25
  def uppercase_alpha?
26
- Chars::UPPERCASE_ALPHA =~ self
26
+ Chars::UPPERCASE_ALPHA === self
27
27
  end
28
28
 
29
29
  def lowercase_alpha?
30
- Chars::LOWERCASE_ALPHA =~ self
30
+ Chars::LOWERCASE_ALPHA === self
31
31
  end
32
32
 
33
33
  def alpha?
34
- Chars::ALPHA =~ self
34
+ Chars::ALPHA === self
35
35
  end
36
36
 
37
37
  def alpha_numeric?
38
- Chars::ALPHA_NUMERIC =~ self
38
+ Chars::ALPHA_NUMERIC === self
39
39
  end
40
40
 
41
41
  def punctuation?
42
- Chars::PUNCTUATION =~ self
42
+ Chars::PUNCTUATION === self
43
43
  end
44
44
 
45
45
  def symbolic?
46
- Chars::SYMBOLS =~ self
46
+ Chars::SYMBOLS === self
47
47
  end
48
48
 
49
49
  def space?
50
- Chars::SPACE =~ self
50
+ Chars::SPACE === self
51
51
  end
52
52
 
53
53
  def printable?
54
- Chars::PRINTABLE =~ self
54
+ Chars::PRINTABLE === self
55
55
  end
56
56
 
57
57
  def control?
58
- Chars::CONTROL =~ self
58
+ Chars::CONTROL === self
59
59
  end
60
60
 
61
61
  def ascii?
62
- Chars::ASCII =~ self
62
+ Chars::ASCII === self
63
63
  end
64
64
 
65
65
  end
@@ -1,4 +1,4 @@
1
1
  module Chars
2
2
  # Chars version
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
@@ -180,7 +180,7 @@ describe Chars::CharSet do
180
180
  end
181
181
 
182
182
  it "should determine if a String is made up of the characters from the char set" do
183
- (@char_set =~ "AABCBAA").should == true
184
- (@char_set =~ "AADDEE").should_not == true
183
+ (@char_set === "AABCBAA").should == true
184
+ (@char_set === "AADDEE").should_not == true
185
185
  end
186
186
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-16 00:00:00 -07:00
12
+ date: 2009-04-12 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.10.0
23
+ version: 1.12.1
24
24
  version:
25
25
  description: Chars is a Ruby library for working with various character sets, recognizing text and generating random text from specific character sets.
26
26
  email:
@@ -33,10 +33,12 @@ extra_rdoc_files:
33
33
  - History.txt
34
34
  - Manifest.txt
35
35
  - README.txt
36
+ - TODO.txt
36
37
  files:
37
38
  - History.txt
38
39
  - Manifest.txt
39
40
  - README.txt
41
+ - TODO.txt
40
42
  - Rakefile
41
43
  - lib/chars.rb
42
44
  - lib/chars/char_set.rb