crack 0.4.5 → 0.4.6

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
  SHA256:
3
- metadata.gz: e6d7eabbf55c05bb0d5ad82fa7ba5bda9ffd9d59afa880eb113c17c3045aaa4f
4
- data.tar.gz: af13a8caa99d12d057f7ec55c1f9142f0bae6f3ec7ad59c06fbd8cf2be259ef8
3
+ metadata.gz: 1c2e3d73dfa6cd7bd7d5fce46da53bc0ddb982d80b3059e209e76e8804071dc5
4
+ data.tar.gz: cb04c6ccc702f19eec009dc498608dce146ecf9fd4668f872e4c8e28d3710250
5
5
  SHA512:
6
- metadata.gz: 936f41453b1fe901f44315a4634f489ef57c567287cd88a90534e0afd53bac92ade2376d52558405777c8b8e40beba9b3562c2ab2d887f515bc84d268b268cd2
7
- data.tar.gz: c1993458cf230034223899dd739ea6611cc1eb962f1785421ab6fd43d390828288cc6ba1604f9477a5c41e1db915542455bb35dd12d2503a78c571090cbf9501
6
+ metadata.gz: 607266ba718e21b4667162cbbbafccb149dcfb90710ab176061227dfecc03818cfdee492b1942d8408c6aab7b0532dadf0c97538963987ce623f03bcef20a6ca
7
+ data.tar.gz: '09853d769af33d9b0cf1681df8b3547a9a2f1917a9a0673d2c94194bc6fc5a7b99abdd86914d3a62c8f61ab89ac56d3a4d25b4f8ddd6e6441f19da270a57aa29'
data/History ADDED
@@ -0,0 +1,46 @@
1
+ == 0.4.6 2024-01-29
2
+
3
+ * minor patches
4
+ * Ruby 3.1, 3.2, 3.3 support
5
+ * Ship LICENSE file
6
+ * Add BigDecimal to gem dependency
7
+ * Move CI to Github Actions
8
+ * Fix parse issue with consecutive dates
9
+
10
+ == 0.4.5 2020-12-26
11
+
12
+ * 1 minor patch
13
+ * Add REXML as gem runtime dependency
14
+
15
+ == 0.4.4 2020-09-17
16
+
17
+ * 1 minor patch
18
+ * Remove safe_yaml
19
+
20
+ == 0.1.7 2010-02-19
21
+ * 1 minor patch
22
+ * Added patch from @purp for ISO 8601 date/time format
23
+
24
+ == 0.1.6 2010-01-31
25
+ * 1 minor patch
26
+ * Added Crack::VERSION constant - http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
27
+
28
+ == 0.1.5 2010-01-27
29
+ * 1 minor patch
30
+ * Strings that begin with dates shouldn't be parsed as such (sandro)
31
+
32
+ == 0.1.3 2009-06-22
33
+ * 1 minor patch
34
+ * Parsing a text node with attributes stores them in the attributes method (tamalw)
35
+
36
+ == 0.1.2 2009-04-21
37
+ * 2 minor patches
38
+ * Correct unnormalization of attribute values (der-flo)
39
+ * Fix error in parsing YAML in the case where a hash value ends with backslashes, and there are subsequent values in the hash (deadprogrammer)
40
+
41
+ == 0.1.1 2009-03-31
42
+ * 1 minor patch
43
+ * Parsing empty or blank xml now returns empty hash instead of raising error.
44
+
45
+ == 0.1.0 2009-03-28
46
+ * Initial release.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # crack
2
+
3
+ [![Test](https://github.com/jnunemaker/crack/actions/workflows/test.yml/badge.svg)](https://github.com/jnunemaker/crack/actions/workflows/test.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/crack.svg)](https://badge.fury.io/rb/crack)
5
+ ![downloads](https://img.shields.io/gem/dt/crack?label=downloads)
6
+
7
+ Really simple JSON and XML parsing, ripped from Merb and Rails. The XML parser is ripped from Merb and the JSON parser is ripped from Rails. I take no credit, just packaged them for all to enjoy and easily use.
8
+
9
+ ## compatibility
10
+
11
+ * Ruby 2.x
12
+ * Ruby 3.x
13
+
14
+ ## note on patches/pull requests
15
+
16
+ * Fork the project.
17
+ * Make your feature addition or bug fix.
18
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
19
+ * Run the tests with `rake test`
20
+ * Open a Pull Request with the changes
21
+
22
+ ## usage
23
+
24
+ ```ruby
25
+ gem 'crack' # in Gemfile
26
+ require 'crack' # for xml and json
27
+ require 'crack/json' # for just json
28
+ require 'crack/xml' # for just xml
29
+ ```
30
+
31
+ ## examples
32
+
33
+ ```ruby
34
+ Crack::XML.parse("<tag>This is the contents</tag>")
35
+ # => {'tag' => 'This is the contents'}
36
+
37
+ Crack::JSON.parse('{"tag":"This is the contents"}')
38
+ # => {'tag' => 'This is the contents'}
39
+ ```
40
+
41
+ ## Copyright
42
+
43
+ Copyright (c) 2009 John Nunemaker. See LICENSE for details.
data/lib/crack/json.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5
5
 
6
6
  require 'strscan'
7
+ require 'psych'
7
8
 
8
9
  module Crack
9
10
  class JSON
@@ -11,13 +12,24 @@ module Crack
11
12
  @parser_exceptions ||= [ArgumentError, Psych::SyntaxError]
12
13
  end
13
14
 
14
- def self.parse(json)
15
- yaml = unescape(convert_json_to_yaml(json))
16
- YAML.safe_load(yaml, [Regexp, Date, Time])
17
- rescue *parser_exceptions
18
- raise ParseError, "Invalid JSON string"
19
- rescue Psych::DisallowedClass
20
- yaml
15
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
16
+ def self.parse(json)
17
+ yaml = unescape(convert_json_to_yaml(json))
18
+ YAML.safe_load(yaml, permitted_classes: [Regexp, Date, Time])
19
+ rescue *parser_exceptions
20
+ raise ParseError, "Invalid JSON string"
21
+ rescue Psych::DisallowedClass
22
+ yaml
23
+ end
24
+ else # Ruby < 2.6
25
+ def self.parse(json)
26
+ yaml = unescape(convert_json_to_yaml(json))
27
+ YAML.safe_load(yaml, [Regexp, Date, Time])
28
+ rescue *parser_exceptions
29
+ raise ParseError, "Invalid JSON string"
30
+ rescue Psych::DisallowedClass
31
+ yaml
32
+ end
21
33
  end
22
34
 
23
35
  protected
@@ -88,9 +100,12 @@ module Crack
88
100
  (date_starts + date_ends).each { |i| output[i-1] = ' ' }
89
101
  else
90
102
  extra_chars_to_be_added = 0
103
+ timestamp_marker = '!!timestamp '
104
+ timestamp_marker_size = timestamp_marker.size
105
+
91
106
  date_starts.each do |i|
92
- output[i-2+extra_chars_to_be_added] = '!!timestamp '
93
- extra_chars_to_be_added += 10
107
+ output[i-2+extra_chars_to_be_added] = timestamp_marker
108
+ extra_chars_to_be_added += timestamp_marker_size - 1
94
109
  end
95
110
  end
96
111
  end
data/lib/crack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Crack
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
data/lib/crack.rb CHANGED
@@ -2,6 +2,7 @@ module Crack
2
2
  class ParseError < StandardError; end
3
3
  end
4
4
 
5
+ require 'crack/version'
5
6
  require 'crack/util'
6
7
  require 'crack/json'
7
8
  require 'crack/xml'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-27 00:00:00.000000000 Z
11
+ date: 2024-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bigdecimal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rexml
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +45,9 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - History
49
+ - LICENSE
50
+ - README.md
34
51
  - lib/crack.rb
35
52
  - lib/crack/json.rb
36
53
  - lib/crack/util.rb
@@ -39,7 +56,11 @@ files:
39
56
  homepage: https://github.com/jnunemaker/crack
40
57
  licenses:
41
58
  - MIT
42
- metadata: {}
59
+ metadata:
60
+ bug_tracker_uri: https://github.com/jnunemaker/crack/issues
61
+ changelog_uri: https://github.com/jnunemaker/crack/blob/master/History
62
+ source_code_uri: https://github.com/jnunemaker/crack
63
+ rubygems_mfa_required: 'true'
43
64
  post_install_message:
44
65
  rdoc_options: []
45
66
  require_paths:
@@ -48,14 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
69
  requirements:
49
70
  - - ">="
50
71
  - !ruby/object:Gem::Version
51
- version: '0'
72
+ version: '2.0'
52
73
  required_rubygems_version: !ruby/object:Gem::Requirement
53
74
  requirements:
54
75
  - - ">="
55
76
  - !ruby/object:Gem::Version
56
77
  version: '0'
57
78
  requirements: []
58
- rubygems_version: 3.1.4
79
+ rubygems_version: 3.3.7
59
80
  signing_key:
60
81
  specification_version: 4
61
82
  summary: Really simple JSON and XML parsing, ripped from Merb and Rails.