crack 0.4.5 → 1.0.0

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: 28a44247b17a9b12d091022ff49d2b9e553b8c15b22d884fee2dc16d9c4afe33
4
+ data.tar.gz: 6a18d9fa5796fa6442bb45eb9f338f791aa6a9e6f1c976d54c3b5b77fc8461b2
5
5
  SHA512:
6
- metadata.gz: 936f41453b1fe901f44315a4634f489ef57c567287cd88a90534e0afd53bac92ade2376d52558405777c8b8e40beba9b3562c2ab2d887f515bc84d268b268cd2
7
- data.tar.gz: c1993458cf230034223899dd739ea6611cc1eb962f1785421ab6fd43d390828288cc6ba1604f9477a5c41e1db915542455bb35dd12d2503a78c571090cbf9501
6
+ metadata.gz: a5a6ada6304be8fc9d2ccc98f13695a4d4544e6c4074dd3845edcf641ad96ebce064f8ab98197efb4fa38be98d586d2a89148a4054f07948bc56cdd41b5f8c0e
7
+ data.tar.gz: 8544330aba3b136f25c3bbddb55440f5efb9eefd7559cae052950e1b305349b19bb5b931ca2cdefbace6b400a2072c7c621fe11eb69c0a02602904c8542ddfde
data/History ADDED
@@ -0,0 +1,52 @@
1
+ == 1.0.0 2024-02-09
2
+
3
+ This version is identical with the previous one, there's no code changes.
4
+
5
+ Releasing v1.0.0 indicates that the gem has a stable API and it's going to follow semantic versioning.
6
+
7
+ == 0.4.6 2024-01-29
8
+
9
+ * minor patches
10
+ * Ruby 3.1, 3.2, 3.3 support
11
+ * Ship LICENSE file
12
+ * Add BigDecimal to gem dependency
13
+ * Move CI to Github Actions
14
+ * Fix parse issue with consecutive dates
15
+
16
+ == 0.4.5 2020-12-26
17
+
18
+ * 1 minor patch
19
+ * Add REXML as gem runtime dependency
20
+
21
+ == 0.4.4 2020-09-17
22
+
23
+ * 1 minor patch
24
+ * Remove safe_yaml
25
+
26
+ == 0.1.7 2010-02-19
27
+ * 1 minor patch
28
+ * Added patch from @purp for ISO 8601 date/time format
29
+
30
+ == 0.1.6 2010-01-31
31
+ * 1 minor patch
32
+ * Added Crack::VERSION constant - http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
33
+
34
+ == 0.1.5 2010-01-27
35
+ * 1 minor patch
36
+ * Strings that begin with dates shouldn't be parsed as such (sandro)
37
+
38
+ == 0.1.3 2009-06-22
39
+ * 1 minor patch
40
+ * Parsing a text node with attributes stores them in the attributes method (tamalw)
41
+
42
+ == 0.1.2 2009-04-21
43
+ * 2 minor patches
44
+ * Correct unnormalization of attribute values (der-flo)
45
+ * Fix error in parsing YAML in the case where a hash value ends with backslashes, and there are subsequent values in the hash (deadprogrammer)
46
+
47
+ == 0.1.1 2009-03-31
48
+ * 1 minor patch
49
+ * Parsing empty or blank xml now returns empty hash instead of raising error.
50
+
51
+ == 0.1.0 2009-03-28
52
+ * 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 = "1.0.0"
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: 1.0.0
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-02-09 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.