crack 0.4.3 → 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
- SHA1:
3
- metadata.gz: 076bd2189e609553cc54c0d7a0df561877aad93c
4
- data.tar.gz: 65af599615f770ea3f5f863995030172c80ac9d7
2
+ SHA256:
3
+ metadata.gz: 1c2e3d73dfa6cd7bd7d5fce46da53bc0ddb982d80b3059e209e76e8804071dc5
4
+ data.tar.gz: cb04c6ccc702f19eec009dc498608dce146ecf9fd4668f872e4c8e28d3710250
5
5
  SHA512:
6
- metadata.gz: 274580659c4370342b059a43f3bc0e728fd5afbddab109a6a4e83def03e2eaabca50b9e52df2a84b8d74e9ac7142876bae31ed90b4310ba646135f7ae48c7b1f
7
- data.tar.gz: 85cf0d85e0d6628c4c59ac8826df44f5b040d57e272f56fc242e6ae6beaebe7469459c791ea2bb58c938dc7ef713f9316b04b525df7ca562a92a8ede4b9663fa
6
+ metadata.gz: 607266ba718e21b4667162cbbbafccb149dcfb90710ab176061227dfecc03818cfdee492b1942d8408c6aab7b0532dadf0c97538963987ce623f03bcef20a6ca
7
+ data.tar.gz: '09853d769af33d9b0cf1681df8b3547a9a2f1917a9a0673d2c94194bc6fc5a7b99abdd86914d3a62c8f61ab89ac56d3a4d25b4f8ddd6e6441f19da270a57aa29'
data/History CHANGED
@@ -1,9 +1,30 @@
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
+
1
20
  == 0.1.7 2010-02-19
2
21
  * 1 minor patch
3
22
  * Added patch from @purp for ISO 8601 date/time format
23
+
4
24
  == 0.1.6 2010-01-31
5
25
  * 1 minor patch
6
26
  * Added Crack::VERSION constant - http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
27
+
7
28
  == 0.1.5 2010-01-27
8
29
  * 1 minor patch
9
30
  * Strings that begin with dates shouldn't be parsed as such (sandro)
@@ -16,10 +37,10 @@
16
37
  * 2 minor patches
17
38
  * Correct unnormalization of attribute values (der-flo)
18
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)
19
-
40
+
20
41
  == 0.1.1 2009-03-31
21
42
  * 1 minor patch
22
43
  * Parsing empty or blank xml now returns empty hash instead of raising error.
23
44
 
24
45
  == 0.1.0 2009-03-28
25
- * Initial release.
46
+ * Initial release.
data/README.md CHANGED
@@ -1,25 +1,26 @@
1
1
  # crack
2
2
 
3
- [![Build Status](https://travis-ci.org/jnunemaker/crack.svg?branch=master)](https://travis-ci.org/jnunemaker/crack)
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)
4
6
 
5
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.
6
8
 
7
9
  ## compatibility
8
10
 
9
- * ruby 1.8.7
10
- * ruby 1.9+ (3 failures related to time parsing, would love it if someone could figure them out)
11
+ * Ruby 2.x
12
+ * Ruby 3.x
11
13
 
12
14
  ## note on patches/pull requests
13
15
 
14
16
  * Fork the project.
15
17
  * Make your feature addition or bug fix.
16
18
  * Add tests for it. This is important so I don't break it in a future version unintentionally.
17
- * `script/test` - this will bootstrap and run the tests
18
- * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
19
- * Send me a pull request. Bonus points for topic branches.
19
+ * Run the tests with `rake test`
20
+ * Open a Pull Request with the changes
20
21
 
21
22
  ## usage
22
-
23
+
23
24
  ```ruby
24
25
  gem 'crack' # in Gemfile
25
26
  require 'crack' # for xml and json
@@ -28,7 +29,7 @@ require 'crack/xml' # for just xml
28
29
  ```
29
30
 
30
31
  ## examples
31
-
32
+
32
33
  ```ruby
33
34
  Crack::XML.parse("<tag>This is the contents</tag>")
34
35
  # => {'tag' => 'This is the contents'}
@@ -40,7 +41,3 @@ Crack::JSON.parse('{"tag":"This is the contents"}')
40
41
  ## Copyright
41
42
 
42
43
  Copyright (c) 2009 John Nunemaker. See LICENSE for details.
43
-
44
- ## Docs
45
-
46
- http://rdoc.info/projects/jnunemaker/crack
data/lib/crack/json.rb CHANGED
@@ -3,34 +3,33 @@
3
3
  # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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
- require 'safe_yaml/load'
7
6
  require 'strscan'
7
+ require 'psych'
8
8
 
9
9
  module Crack
10
10
  class JSON
11
11
  def self.parser_exceptions
12
- @parser_exceptions ||= begin
13
- exceptions = [ArgumentError]
14
-
15
- if const_defined?(:Psych)
16
- if Psych.const_defined?(:SyntaxError)
17
- exceptions << Psych::SyntaxError
18
- end
19
- end
20
-
21
- exceptions
22
- end
12
+ @parser_exceptions ||= [ArgumentError, Psych::SyntaxError]
23
13
  end
24
14
 
25
- def self.parse(json)
26
- args = [unescape(convert_json_to_yaml(json))]
27
- args << nil if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
28
- args << { :whitelisted_tags => ['!ruby/regexp'] }
29
-
30
- SafeYAML.load(*args)
31
-
32
- rescue *parser_exceptions
33
- raise ParseError, "Invalid JSON string"
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
34
33
  end
35
34
 
36
35
  protected
@@ -101,9 +100,12 @@ module Crack
101
100
  (date_starts + date_ends).each { |i| output[i-1] = ' ' }
102
101
  else
103
102
  extra_chars_to_be_added = 0
103
+ timestamp_marker = '!!timestamp '
104
+ timestamp_marker_size = timestamp_marker.size
105
+
104
106
  date_starts.each do |i|
105
- output[i-2+extra_chars_to_be_added] = '!!timestamp '
106
- 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
107
109
  end
108
110
  end
109
111
  end
data/lib/crack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Crack
2
- VERSION = "0.4.3"
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,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2024-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: safe_yaml
14
+ name: bigdecimal
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rexml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Really simple JSON and XML parsing, ripped from Merb and Rails.
28
42
  email:
29
43
  - nunemaker@gmail.com
@@ -31,35 +45,23 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
34
- - ".gitignore"
35
- - ".travis.yml"
36
- - Gemfile
37
48
  - History
38
49
  - LICENSE
39
50
  - README.md
40
- - crack.gemspec
41
51
  - lib/crack.rb
42
52
  - lib/crack/json.rb
43
53
  - lib/crack/util.rb
44
54
  - lib/crack/version.rb
45
55
  - lib/crack/xml.rb
46
- - script/bootstrap
47
- - script/release
48
- - script/test
49
- - test/data/large_dataset.json
50
- - test/data/twittersearch-firefox.json
51
- - test/data/twittersearch-ie.json
52
- - test/hash_test.rb
53
- - test/json_test.rb
54
- - test/parser_test.rb
55
- - test/string_test.rb
56
- - test/test_helper.rb
57
- - test/xml_test.rb
58
- homepage: http://github.com/jnunemaker/crack
56
+ homepage: https://github.com/jnunemaker/crack
59
57
  licenses:
60
58
  - MIT
61
- metadata: {}
62
- post_install_message:
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'
64
+ post_install_message:
63
65
  rdoc_options: []
64
66
  require_paths:
65
67
  - lib
@@ -67,25 +69,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
69
  requirements:
68
70
  - - ">="
69
71
  - !ruby/object:Gem::Version
70
- version: '0'
72
+ version: '2.0'
71
73
  required_rubygems_version: !ruby/object:Gem::Requirement
72
74
  requirements:
73
75
  - - ">="
74
76
  - !ruby/object:Gem::Version
75
77
  version: '0'
76
78
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.2.2
79
- signing_key:
79
+ rubygems_version: 3.3.7
80
+ signing_key:
80
81
  specification_version: 4
81
82
  summary: Really simple JSON and XML parsing, ripped from Merb and Rails.
82
- test_files:
83
- - test/data/large_dataset.json
84
- - test/data/twittersearch-firefox.json
85
- - test/data/twittersearch-ie.json
86
- - test/hash_test.rb
87
- - test/json_test.rb
88
- - test/parser_test.rb
89
- - test/string_test.rb
90
- - test/test_helper.rb
91
- - test/xml_test.rb
83
+ test_files: []
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg
6
- *.gem
7
- /.bundle
8
- /Gemfile.lock
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.8
4
- - 1.9
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
- - jruby
9
- - rbx
10
- matrix:
11
- allow_failures:
12
- - rvm: 1.8
13
- script: ./script/test
14
- sudo: false
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem "rake"
5
- gem "minitest"
data/crack.gemspec DELETED
@@ -1,20 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/crack/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["John Nunemaker"]
6
- gem.email = ["nunemaker@gmail.com"]
7
- gem.description = %q{Really simple JSON and XML parsing, ripped from Merb and Rails.}
8
- gem.summary = %q{Really simple JSON and XML parsing, ripped from Merb and Rails.}
9
- gem.homepage = "http://github.com/jnunemaker/crack"
10
-
11
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
- gem.files = `git ls-files`.split("\n")
13
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
- gem.name = "crack"
15
- gem.require_paths = ["lib"]
16
- gem.version = Crack::VERSION
17
- gem.license = "MIT"
18
-
19
- gem.add_dependency "safe_yaml", "~> 1.0.0"
20
- end
data/script/bootstrap DELETED
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: bootstrap [bundle options]
3
- #/
4
- #/ Bundle install the dependencies.
5
- #/
6
- #/ Examples:
7
- #/
8
- #/ bootstrap
9
- #/ bootstrap --local
10
- #/
11
-
12
- set -e
13
- cd $(dirname "$0")/..
14
-
15
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
16
- grep '^#/' <"$0"| cut -c4-
17
- exit 0
18
- }
19
-
20
- rm -rf .bundle/{binstubs,config}
21
- bundle install --binstubs .bundle/binstubs --path .bundle --quiet "$@"
data/script/release DELETED
@@ -1,42 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: release
3
- #/
4
- #/ Tag the version in the repo and push the gem.
5
- #/
6
-
7
- set -e
8
- cd $(dirname "$0")/..
9
-
10
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
11
- grep '^#/' <"$0"| cut -c4-
12
- exit 0
13
- }
14
-
15
- gem_name=crack
16
-
17
- # Build a new gem archive.
18
- rm -rf $gem_name-*.gem
19
- gem build -q $gem_name.gemspec
20
-
21
- # Make sure we're on the master branch.
22
- (git branch | grep -q '* master') || {
23
- echo "Only release from the master branch."
24
- exit 1
25
- }
26
-
27
- # Figure out what version we're releasing.
28
- tag=v`ls $gem_name-*.gem | sed "s/^$gem_name-\(.*\)\.gem$/\1/"`
29
-
30
- echo "Releasing $tag"
31
-
32
- # Make sure we haven't released this version before.
33
- git fetch -t origin
34
-
35
- (git tag -l | grep -q "$tag") && {
36
- echo "Whoops, there's already a '${tag}' tag."
37
- exit 1
38
- }
39
-
40
- # Tag it and bag it.
41
- gem push $gem_name-*.gem && git tag "$tag" &&
42
- git push origin master && git push origin "$tag"
data/script/test DELETED
@@ -1,25 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: test [individual test file]
3
- #/
4
- #/ Bootstrap and run all tests or an individual test.
5
- #/
6
- #/ Examples:
7
- #/
8
- #/ # run all tests
9
- #/ test
10
- #/
11
- #/ # run individual test
12
- #/ test test/controller_instrumentation_test.rb
13
- #/
14
-
15
- set -e
16
- cd $(dirname "$0")/..
17
-
18
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
19
- grep '^#/' <"$0"| cut -c4-
20
- exit 0
21
- }
22
-
23
- script/bootstrap && ruby -I lib -I test -r rubygems \
24
- -e 'require "bundler/setup"' \
25
- -e '(ARGV.empty? ? Dir["test/**/*_test.rb"] : ARGV).each { |f| load f }' -- "$@"