Skip to content

Commit

Permalink
Merge branch 'master' into jruby-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kares authored Jun 25, 2020
2 parents 9bd6b71 + ee70abf commit 24b3425
Show file tree
Hide file tree
Showing 33 changed files with 751 additions and 4,536 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Gemfile.lock
*/**/Makefile
*/**/*.o
.byebug_history
*.log
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ language: ruby

# Specify which ruby versions you wish to run your tests on, each version will be used
rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
- 2.7.0-preview3
- ruby-head
- jruby-1.7 # Ruby 1.9.3
- jruby-9.1 # Ruby 2.3
- jruby-9.2 # Ruby 2.5
before_install:
- rvm @global @default do gem uninstall bundler -a -x --silent || true
- gem install bundler -v '<2'
- truffleruby
matrix:
allow_failures:
- rvm: 1.9.3
- rvm: ruby-head
- rvm: jruby-9.1
- rvm: jruby-9.2
- rvm: truffleruby
script: "bundle exec rake"
sudo: false
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changes

## 2019-02-21 (2.2.0)
* Adds support for 2.6 BigDecimal and ruby standard library Set datetype.

## 2017-04-18 (2.1.0)
* Allow passing of `decimal_class` option to specify a class as which to parse
JSON float numbers.
Expand Down
56 changes: 56 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
You can redistribute it and/or modify it under either the terms of the
2-clause BSDL (see the file BSDL), or the conditions below:

1. You may make and give away verbatim copies of the source form of the
software without restriction, provided that you duplicate all of the
original copyright notices and associated disclaimers.

2. You may modify your copy of the software in any way, provided that
you do at least ONE of the following:

a) place your modifications in the Public Domain or otherwise
make them Freely Available, such as by posting said
modifications to Usenet or an equivalent medium, or by allowing
the author to include your modifications in the software.

b) use the modified software only within your corporation or
organization.

c) give non-standard binaries non-standard names, with
instructions on where to get the original software distribution.

d) make other distribution arrangements with the author.

3. You may distribute the software in object code or binary form,
provided that you do at least ONE of the following:

a) distribute the binaries and library files of the software,
together with instructions (in the manual page or equivalent)
on where to get the original distribution.

b) accompany the distribution with the machine-readable source of
the software.

c) give non-standard binaries non-standard names, with
instructions on where to get the original software distribution.

d) make other distribution arrangements with the author.

4. You may modify and include the part of the software into any other
software (possibly commercial). But some files in the distribution
are not written by the author, so that they are not under these terms.

For the list of those files and their copying conditions, see the
file LEGAL.

5. The scripts and library files supplied as input to or produced as
output from the software do not automatically fall under the
copyright of the software, but belong to whomever generated them,
and may be sold commercially, and may be aggregated with this
software.

6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ not been required yet.
The JSON module doesn't extend `Exception` by default. If you convert an `Exception`
object to JSON, it will by default only include the exception message.

To include the full details, you must either load the load the `json/add/core` mentioned
To include the full details, you must either load the `json/add/core` mentioned
above, or specifically load the exception addition:

```ruby
Expand Down Expand Up @@ -207,7 +207,7 @@ JSON representation later. In this case it's `Range`, but any namespace of
the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
used to store the necessary data to configure the object to be deserialised.

If a the key `json_class` is found in a JSON object, the JSON parser checks
If the key `json_class` is found in a JSON object, the JSON parser checks
if the given class responds to the `json_create` class method. If so, it is
called with the JSON object converted to a Ruby hash. So a range can
be deserialised by implementing `Range.json_create` like this:
Expand Down Expand Up @@ -390,6 +390,22 @@ Here are the median comparisons for completeness' sake:
secs/call
```

## Development

### Release

Update the json.gemspec and json-java.gemspec.

```
rbenv shell 2.6.5
rake build
gem push pkg/json-2.3.0.gem
rbenv shell jruby-9.2.9.0
rake build
gem push pkg/json-2.3.0-java.gem
```

## Author

Florian Frank <mailto:flori@ping.de>
Expand All @@ -406,4 +422,4 @@ The latest version of this library can be downloaded at

Online Documentation should be located at

* http://json.rubyforge.org
* https://www.rubydoc.info/gems/json
80 changes: 25 additions & 55 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ class UndocumentedTestTask < Rake::TestTask
def desc(*) end
end

MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
BUNDLE = ENV['BUNDLE'] || %w[bundle].find { |c| system(c, '-v') }
which = lambda { |c|
w = `which #{c}`
break w.chomp unless w.empty?
}

MAKE = ENV['MAKE'] || %w[gmake make].find(&which)
BUNDLE = ENV['BUNDLE'] || %w[bundle].find(&which)
PKG_NAME = 'json'
PKG_TITLE = 'JSON Implementation for Ruby'
PKG_VERSION = File.read('VERSION').chomp
Expand All @@ -47,8 +52,8 @@ JAVA_CLASSES = []
JRUBY_PARSER_JAR = File.expand_path("lib/json/ext/parser.jar")
JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")

RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find(&which)
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find(&which)

desc "Installing library (pure)"
task :install_pure => :version do
Expand Down Expand Up @@ -84,7 +89,7 @@ if defined?(Gem) and defined?(Gem::PackageTask)

s.require_path = 'lib'
s.add_development_dependency 'rake'
s.add_development_dependency 'test-unit', '~> 2.0'
s.add_development_dependency 'test-unit', '>= 2.0', '< 4.0'

s.extra_rdoc_files << 'README.md'
s.rdoc_options <<
Expand All @@ -95,13 +100,16 @@ if defined?(Gem) and defined?(Gem::PackageTask)
s.email = "flori@ping.de"
s.homepage = "http://flori.github.com/#{PKG_NAME}"
s.license = 'Ruby'
s.required_ruby_version = '>= 1.9'
s.required_ruby_version = '>= 2.0'
end

desc 'Creates a json_pure.gemspec file'
task :gemspec_pure => :version do
File.open('json_pure.gemspec', 'w') do |gemspec|
gemspec.write spec_pure.to_ruby
src = spec_pure.to_ruby
src.gsub!(/# stub:.*/, "# This gemspec is generated automatically using `rake gemspec`.\n" \
"# Do not modify directly.")
gemspec.write src
end
end

Expand All @@ -110,47 +118,8 @@ if defined?(Gem) and defined?(Gem::PackageTask)
pkg.package_files = PKG_FILES
end

spec_ext = Gem::Specification.new do |s|
s.name = 'json'
s.version = PKG_VERSION
s.summary = PKG_TITLE
s.description = "This is a JSON implementation as a Ruby extension in C."

s.files = PKG_FILES

s.extensions = FileList['ext/**/extconf.rb']

s.require_path = 'lib'
s.add_development_dependency 'rake'
s.add_development_dependency 'test-unit', '~> 2.0'

s.extra_rdoc_files << 'README.md'
s.rdoc_options <<
'--title' << 'JSON implemention for Ruby' << '--main' << 'README.md'
s.test_files.concat Dir['./tests/test_*.rb']

s.author = "Florian Frank"
s.email = "flori@ping.de"
s.homepage = "http://flori.github.com/#{PKG_NAME}"
s.license = 'Ruby'
s.required_ruby_version = '>= 1.9'
end

desc 'Creates a json.gemspec file'
task :gemspec_ext => :version do
File.open('json.gemspec', 'w') do |gemspec|
gemspec.write spec_ext.to_ruby
end
end

Gem::PackageTask.new(spec_ext) do |pkg|
pkg.need_tar = true
pkg.package_files = PKG_FILES
end


desc 'Create all gemspec files'
task :gemspec => [ :gemspec_pure, :gemspec_ext ]
desc 'Alias for gemspec_pure'
task :gemspec => [ :gemspec_pure ]
end

desc m = "Writing version information for #{PKG_VERSION}"
Expand All @@ -176,7 +145,8 @@ task :check_env do
end

desc "Testing library (pure ruby)"
task :test_pure => [ :clean, :check_env, :do_test_pure ]
task :test_pure => [ :set_env_pure, :check_env, :do_test_pure ]
task(:set_env_pure) { ENV['JSON'] = 'pure' }

UndocumentedTestTask.new do |t|
t.name = 'do_test_pure'
Expand All @@ -187,10 +157,7 @@ UndocumentedTestTask.new do |t|
end

desc "Testing library (pure ruby and extension)"
task :test do
sh "env JSON=pure #{BUNDLE} exec rake test_pure" or exit 1
sh "env JSON=ext #{BUNDLE} exec rake test_ext" or exit 1
end
task :test => [ :test_pure, :test_ext ]

namespace :gems do
desc 'Install all development gems'
Expand Down Expand Up @@ -238,7 +205,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
obj = src.sub(/\.java\Z/, '.class')
file obj => src do
sh 'javac', '-classpath', classpath, '-source', '1.5', '-target', '1.5', src
sh 'javac', '-classpath', classpath, '-source', '1.6', '-target', '1.6', src
end
JAVA_CLASSES << obj
end
Expand All @@ -257,7 +224,8 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
end

desc "Testing library (jruby)"
task :test_ext => [ :check_env, :create_jar, :do_test_ext ]
task :test_ext => [ :set_env_ext, :create_jar, :check_env, :do_test_ext ]
task(:set_env_ext) { ENV['JSON'] = 'ext' }

UndocumentedTestTask.new do |t|
t.name = 'do_test_ext'
Expand Down Expand Up @@ -363,6 +331,8 @@ else
end
src = File.read("parser.c").gsub(/[ \t]+$/, '')
src.gsub!(/^static const int (JSON_.*=.*);$/, 'enum {\1};')
src.gsub!(/0 <= \(\*p\) && \(\*p\) <= 31/, "0 <= (signed char)(*p) && (*p) <= 31")
src[0, 0] = "/* This file is automatically generated from parser.rl by using ragel */"
File.open("parser.c", "w") {|f| f.print src}
end
end
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.3.0
1 change: 0 additions & 1 deletion data/example.json

This file was deleted.

38 changes: 0 additions & 38 deletions data/index.html

This file was deleted.

Loading

0 comments on commit 24b3425

Please sign in to comment.