ruby_sscanf 0.2.3 → 0.2.4

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: a3637116ff8d600da08dc6dbdda7176f920e2b7c
4
- data.tar.gz: 2f1d07cacd079a28c3d57e572e6f5d8392d5664f
3
+ metadata.gz: 39d5948584a8362aff629ef8e2e69d4e0ecf1db6
4
+ data.tar.gz: 34886c12fb70ee94405aa2bdbc1ee31effdb9aa2
5
5
  SHA512:
6
- metadata.gz: 8e761ffadd60be04a4bfd62c96476a3bd2c7d06cd0f94aadf30b76ade72205617b3efa340c4dac26615fc82f290c200b70d13b4bb2d60a0a96a293511e7bc39e
7
- data.tar.gz: 9473f807205c1539e1960a9c8b6bbeeaa367ec816c2edf358fa0bd10e02174677520fecc7d26764c3444d33f8250c774fe92c6c901b3324c35ff84a1b8eda4c2
6
+ metadata.gz: 8d35f7a9492d9560a62bdeb05aa271ea2925854d875f1cc0809c992bf7089a4c8744ca26434986e939e4b9d7bfd55b3d025d16fe1112c693bbf2599e54e913cf
7
+ data.tar.gz: cf7b631bb392d898cd3c737c52ea195720522cfe13b2ed28109557c24e37a2d46182a165702bad545c56d226442285efd151607ec0a7d500cf85ff582c6401cb
data/README.md CHANGED
@@ -8,6 +8,7 @@ It is noteworthy that this gem never was intended to be 100% compatible with
8
8
  the built in scanf library. Some differences are:
9
9
  * It deals only with strings and not IO objects.
10
10
  * It adds formats for rational, complex, and quoted string data.
11
+ * It adds formats with embedded regular expression specifications.
11
12
  * It adopts a more uniform approach to eating (or not eating) superfluous spaces.
12
13
  * Unsigned integer data are not allowed to be negative.
13
14
 
@@ -27,6 +28,8 @@ Or install it yourself as:
27
28
 
28
29
  $ gem install ruby_sscanf
29
30
 
31
+ The ruby_sscanf gem itself is found at: ( https://rubygems.org/gems/ruby_sscanf )
32
+
30
33
  ## Usage
31
34
 
32
35
  The basic usage for sscanf is:
@@ -98,8 +101,10 @@ leading '0x' or '0X'.
98
101
  * [^chars] - Scan for a contiguous string of characters not in the set [^chars]
99
102
  * /regex/ - Scan for a string matching the regular expression. This may be
100
103
  followed by one or more optional flags. Supported flags are i, m, and x.
104
+ Limitation: zero width (positive or negative) look behind assertions (?<= )
105
+ and (?<! ) are not supported at this time.
101
106
 
102
- ## Examples
107
+ #### Examples
103
108
  Here are a few exmaples of the sscanf method in action.
104
109
 
105
110
  ```ruby
@@ -156,9 +161,12 @@ returns ["a", "b", "c"]
156
161
 
157
162
  "a abbccc acbcad".sscanf "%/A/i %/a+b+c+/ %/([ab][cd])+/"
158
163
  returns ["a", "abbccc", "acbcad"]
164
+
165
+ " 1234i ".sscanf(" %/\\d+/\\i")
166
+ returns ["1234"]
159
167
  ```
160
168
 
161
- ## Getting unparsed text
169
+ #### Getting unparsed text
162
170
  When a string is parsed, there may be some text at the end of the string that
163
171
  is not parsed. It is possible to retrieve this text using the following:
164
172
 
@@ -166,6 +174,13 @@ is not parsed. It is possible to retrieve this text using the following:
166
174
  String.sscanf_unparsed
167
175
  ```
168
176
 
177
+ ## Demo
178
+
179
+ A test bed for experimenting with the ruby_sscanf gem is available as a rake
180
+ task:
181
+
182
+ $ rake console
183
+
169
184
  ## Benchmarks
170
185
 
171
186
  I ran a test just to make sure that ruby_sscanf was not terribly
@@ -174,28 +189,28 @@ pleased to see that in fact ruby_sscanf was faster. Here are the results:
174
189
 
175
190
  Warming up --------------------------------------
176
191
  Scan strings with ruby_sscanf
177
- 1.768k i/100ms
192
+ 1.734k i/100ms
178
193
  Scan strings with scanf
179
- 310.000 i/100ms
194
+ 309.000 i/100ms
180
195
  Calculating -------------------------------------
181
196
  Scan strings with ruby_sscanf
182
- 18.355k5.8%) i/s - 91.936k
197
+ 17.926k0.6%) i/s - 90.168k
183
198
  Scan strings with scanf
184
- 3.145k7.2%) i/s - 15.810k
199
+ 3.123k0.6%) i/s - 15.759k
185
200
 
186
201
  Comparison:
187
- Scan strings with ruby_sscanf: 18354.7 i/s
188
- Scan strings with scanf: 3145.0 i/s - 5.84x slower
202
+ Scan strings with ruby_sscanf: 17925.7 i/s
203
+ Scan strings with scanf: 3123.0 i/s - 5.74x slower
189
204
 
190
205
  This benchmark test was run under:
191
206
  * ruby 2.1.6p336 (2015-04-13 revision 50298) [i386-mingw32]
192
- * format_engine version = 0.6.0
207
+ * format_engine version = 0.7.2
193
208
 
194
209
  ## Contributing
195
210
 
196
211
  #### Plan A
197
212
 
198
- 1. Fork it ( https://github.com/PeterCamilleri/format_engine/fork )
213
+ 1. Fork it ( https://github.com/PeterCamilleri/ruby_sscanf/fork )
199
214
  2. Create your feature branch (`git checkout -b my-new-feature`)
200
215
  3. Commit your changes (`git commit -am 'Add some feature'`)
201
216
  4. Push to the branch (`git push origin my-new-feature`)
@@ -204,8 +219,5 @@ This benchmark test was run under:
204
219
  #### Plan B
205
220
 
206
221
  Go to the GitHub repository and raise an issue calling attention to some
207
- aspect that could use some TLC or a suggestion or idea. Apply labels to
208
- the issue that match the point you are trying to make. Then follow your
209
- issue and keep up-to-date as it is worked on. Or not as pleases you.
210
- All input are greatly appreciated.
222
+ aspect that could use some TLC or a suggestion or an idea.
211
223
 
data/irbt.rb ADDED
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+ # An IRB + ruby_sscanf test bed
3
+
4
+ require 'irb'
5
+
6
+ puts "Starting an IRB console with ruby_sscanf loaded."
7
+
8
+ if ARGV[0] == 'local'
9
+ require_relative 'lib/ruby_sscanf'
10
+ puts "ruby_sscanf loaded locally: #{RubySscanf::VERSION}"
11
+
12
+ ARGV.shift
13
+ else
14
+ require 'ruby_sscanf'
15
+ puts "ruby_sscanf loaded from gem: #{RubySscanf::VERSION}"
16
+ end
17
+
18
+ IRB.start
@@ -1,5 +1,5 @@
1
1
  #The ruby_sscanf doesn't really live here.
2
2
  module RubySscanf
3
3
  #The gem's version.
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
@@ -34,16 +34,9 @@ task :reek do |t|
34
34
  `reek --no-color lib > reek.txt`
35
35
  end
36
36
 
37
- desc "Run an IRB Session with format_engine loaded."
37
+ desc "Fire up an IRB session with ruby_sscanf preloaded."
38
38
  task :console do
39
- require 'irb'
40
- require 'irb/completion'
41
- require './lib/ruby_sscanf'
42
- puts "Starting an IRB console with ruby_sscanf."
43
- puts "Use 'quit' to exit."
44
- puts
45
- ARGV.clear
46
- IRB.start
39
+ system "ruby irbt.rb local"
47
40
  end
48
41
 
49
42
  desc "What version of code is this?"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_sscanf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: format_engine
@@ -105,11 +105,12 @@ files:
105
105
  - Gemfile
106
106
  - LICENSE.txt
107
107
  - README.md
108
- - Rakefile
109
108
  - bench/bench.rb
109
+ - irbt.rb
110
110
  - lib/ruby_sscanf.rb
111
111
  - lib/ruby_sscanf/engine.rb
112
112
  - lib/ruby_sscanf/version.rb
113
+ - rakefile.rb
113
114
  - ruby_sscanf.gemspec
114
115
  - tests/scan_tests.rb
115
116
  homepage: http://teuthida-technologies.com/