motion-strscan 0.5.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.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +63 -0
  3. data/lib/motion-strscan/string.rb +20 -0
  4. data/lib/motion-strscan/strscan.rb +676 -0
  5. data/lib/motion-strscan/version.rb +3 -0
  6. data/lib/motion-strscan.rb +8 -0
  7. data/spec/helpers/it_behaves_like.rb +27 -0
  8. data/spec/string_spec/_shared/slice.rb +244 -0
  9. data/spec/string_spec/byteslice_spec.rb +21 -0
  10. data/spec/strscan_spec/_shared/bol.rb +25 -0
  11. data/spec/strscan_spec/_shared/concat.rb +31 -0
  12. data/spec/strscan_spec/_shared/eos.rb +17 -0
  13. data/spec/strscan_spec/_shared/extract_range.rb +22 -0
  14. data/spec/strscan_spec/_shared/extract_range_matched.rb +22 -0
  15. data/spec/strscan_spec/_shared/get_byte.rb +28 -0
  16. data/spec/strscan_spec/_shared/matched_size.rb +21 -0
  17. data/spec/strscan_spec/_shared/peek.rb +44 -0
  18. data/spec/strscan_spec/_shared/pos.rb +83 -0
  19. data/spec/strscan_spec/_shared/rest_size.rb +18 -0
  20. data/spec/strscan_spec/_shared/terminate.rb +17 -0
  21. data/spec/strscan_spec/append_spec.rb +7 -0
  22. data/spec/strscan_spec/beginning_of_line_spec.rb +3 -0
  23. data/spec/strscan_spec/bol_spec.rb +3 -0
  24. data/spec/strscan_spec/check_spec.rb +13 -0
  25. data/spec/strscan_spec/check_until_spec.rb +14 -0
  26. data/spec/strscan_spec/clear_spec.rb +21 -0
  27. data/spec/strscan_spec/concat_spec.rb +7 -0
  28. data/spec/strscan_spec/dup_spec.rb +36 -0
  29. data/spec/strscan_spec/element_reference_spec.rb +46 -0
  30. data/spec/strscan_spec/empty_spec.rb +21 -0
  31. data/spec/strscan_spec/eos_spec.rb +3 -0
  32. data/spec/strscan_spec/exist_spec.rb +21 -0
  33. data/spec/strscan_spec/get_byte_spec.rb +3 -0
  34. data/spec/strscan_spec/getbyte_spec.rb +23 -0
  35. data/spec/strscan_spec/getch_spec.rb +41 -0
  36. data/spec/strscan_spec/initialize_spec.rb +25 -0
  37. data/spec/strscan_spec/inspect_spec.rb +17 -0
  38. data/spec/strscan_spec/match_spec.rb +25 -0
  39. data/spec/strscan_spec/matched_size_spec.rb +3 -0
  40. data/spec/strscan_spec/matched_spec.rb +37 -0
  41. data/spec/strscan_spec/matchedsize_spec.rb +23 -0
  42. data/spec/strscan_spec/must_C_version_spec.rb +5 -0
  43. data/spec/strscan_spec/peek_spec.rb +4 -0
  44. data/spec/strscan_spec/peep_spec.rb +21 -0
  45. data/spec/strscan_spec/pointer_spec.rb +7 -0
  46. data/spec/strscan_spec/pos_spec.rb +7 -0
  47. data/spec/strscan_spec/post_match_spec.rb +24 -0
  48. data/spec/strscan_spec/pre_match_spec.rb +37 -0
  49. data/spec/strscan_spec/reset_spec.rb +12 -0
  50. data/spec/strscan_spec/rest_size_spec.rb +3 -0
  51. data/spec/strscan_spec/rest_spec.rb +44 -0
  52. data/spec/strscan_spec/restsize_spec.rb +21 -0
  53. data/spec/strscan_spec/scan_full_spec.rb +27 -0
  54. data/spec/strscan_spec/scan_spec.rb +50 -0
  55. data/spec/strscan_spec/scan_until_spec.rb +20 -0
  56. data/spec/strscan_spec/search_full_spec.rb +27 -0
  57. data/spec/strscan_spec/skip_spec.rb +15 -0
  58. data/spec/strscan_spec/skip_until_spec.rb +15 -0
  59. data/spec/strscan_spec/string_spec.rb +37 -0
  60. data/spec/strscan_spec/terminate_spec.rb +3 -0
  61. data/spec/strscan_spec/unscan_spec.rb +26 -0
  62. metadata +172 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ce76e9365737a21abf4825e2750832c950a6e8f
4
+ data.tar.gz: 9e8c604e70652a9886190f92548debf544a66778
5
+ SHA512:
6
+ metadata.gz: e427425d5b1525c59ccbdc14a540c36f11f741991f5fe867cc5f9dc84a2004b17b2d8917f5fc1122278555d17e1a407017e30ce25f7dc2782a4b1d7fd7e69422
7
+ data.tar.gz: 867b7c8b34e89a51c54ed66a0696174f6f3e23f187e6549d0cccef4e797d98f486782435ed07b9f9436b8cd608a2f43bf76993a0e62a94c4934514086dad9b58
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Implementation of Ruby `strscan` module
2
+
3
+ This gems implements the `StringScanner` class from the `strscan.rb` Ruby standard library for use with RubyMotion.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'motion-strscan'
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install motion-strscan
18
+
19
+ ## Implementation details
20
+
21
+ This is a pure Ruby implementation of `StringScanner` (no Cocoa apis), borrowed from the MacRuby project, with some minor modifications to handle multibyte strings correctly.
22
+
23
+ **Note:** While Ruby uses the Oniguruma regular expression library, RubyMotion uses the ICU library on iOS/OSX, and the Java library on Andriod. There are minor differences, particularly in the handling of `^`
24
+
25
+ For example, ICU will match a `^` only at the beginning of the input, unless you add the `m` flag; then it will match the beginning of the line as well. In Oniguruma, `^` matches the beginning of the line by default.
26
+
27
+ So if you're porting a Ruby libary that uses regular expressions, you need to be aware of these differences.
28
+
29
+ ### Supported Platforms
30
+
31
+ Bot iOS and OS X are supported targets. Will accept contibutions for Andriod support
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch: `git checkout -b my-new-feature`
37
+ 3. Commit your changes: `git commit -am 'Add some feature'`
38
+ 4. Push to the branch: `git push origin my-new-feature`
39
+ 5. Create new Pull Request
40
+
41
+ ## License
42
+
43
+ The MIT License (MIT)
44
+
45
+ Copyright (c) 2015 digitalMoksha
46
+
47
+ Permission is hereby granted, free of charge, to any person obtaining a copy
48
+ of this software and associated documentation files (the "Software"), to deal
49
+ in the Software without restriction, including without limitation the rights
50
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51
+ copies of the Software, and to permit persons to whom the Software is
52
+ furnished to do so, subject to the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be included in
55
+ all copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
63
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ # Implementation of String#byteslice since RubyMotion (at least as of 3.6)
2
+ # does not implement it.
3
+ #------------------------------------------------------------------------------
4
+ class String
5
+
6
+ # To get a byte range out of a possible multibyte string, force encoding to
7
+ # ASCII-8BIT and use regular string slice, then restore the original encoding
8
+ #------------------------------------------------------------------------------
9
+ def byteslice(*args)
10
+ result = nil
11
+ begin
12
+ enc = self.encoding
13
+ self.force_encoding('ASCII-8BIT')
14
+ result = self.slice(*args)
15
+ ensure
16
+ self.force_encoding(enc)
17
+ end
18
+ result ? result.force_encoding(enc) : nil
19
+ end
20
+ end