From 476c53c32af158c2e073c312a22f5aecdc39c5f8 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:17:22 -0600 Subject: [PATCH 01/25] Link to application/json-seq media type definition --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a1178aa..9d2713d 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ network, can be processed in constant memory space this way. * [json](https://github.com/flori/json) * [yajl-ruby](https://github.com/brianmario/yajl-ruby) * [yajl-ffi](https://github.com/dgraham/yajl-ffi) +* [application/json-seq](http://www.rfc-editor.org/rfc/rfc7464.txt) ## License From 9b51f51931849a5b41cec8f0241f0ad20dbb1804 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:18:39 -0600 Subject: [PATCH 02/25] 2017 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 7c8c0d0..2e899bc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2014 David Graham +Copyright (c) 2010-2017 David Graham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 69abb22b7331ca3b7de1ac0683600daa65727128 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:28:21 -0600 Subject: [PATCH 03/25] Add Gemfile --- .gitignore | 12 +++++++++--- Gemfile | 2 ++ bin/console | 14 ++++++++++++++ bin/setup | 7 +++++++ json-stream.gemspec | 6 ++++-- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 Gemfile create mode 100755 bin/console create mode 100755 bin/setup diff --git a/.gitignore b/.gitignore index 08761ad..0cb6eeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ -.ruby-version -.DS_Store -pkg +/.bundle/ +/.yardoc +/Gemfile.lock +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..851fabc --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gemspec diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..5864a6c --- /dev/null +++ b/bin/console @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "json/stream" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +# (If you use this, don't forget to add pry to your Gemfile!) +# require "pry" +# Pry.start + +require "irb" +IRB.start(__FILE__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..54e9ac3 --- /dev/null +++ b/bin/setup @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install diff --git a/json-stream.gemspec b/json-stream.gemspec index 6e9131e..7459a0d 100644 --- a/json-stream.gemspec +++ b/json-stream.gemspec @@ -11,10 +11,12 @@ Gem::Specification.new do |s| s.homepage = 'http://dgraham.github.io/json-stream/' s.license = 'MIT' - s.files = Dir['[A-Z]*', 'json-stream.gemspec', '{lib}/**/*'] - s.test_files = Dir['spec/**/*'] + s.files = Dir['[A-Z]*', 'json-stream.gemspec', '{lib}/**/*'] - ['Gemfile.lock'] s.require_path = 'lib' + s.add_development_dependency 'bundler', '~> 1.14' + s.add_development_dependency 'minitest', '~> 5.10' s.add_development_dependency 'rake', '~> 10.3' + s.required_ruby_version = '>= 1.9.2' end From e0162094fc2b7e994aa7b557e0133a23b68ad909 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:29:30 -0600 Subject: [PATCH 04/25] Create binstubs --- bin/bundler | 17 +++++++++++++++++ bin/rake | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 bin/bundler create mode 100755 bin/rake diff --git a/bin/bundler b/bin/bundler new file mode 100755 index 0000000..d6107f0 --- /dev/null +++ b/bin/bundler @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true +# +# This file was generated by Bundler. +# +# The application 'bundler' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("bundler", "bundler") diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..486010f --- /dev/null +++ b/bin/rake @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true +# +# This file was generated by Bundler. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") From 20cd2eb0c8149f54e39d698a0b7ca8810ab7e899 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:31:34 -0600 Subject: [PATCH 05/25] Add development notes --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9d2713d..4ef985c 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,13 @@ network, can be processed in constant memory space this way. * [yajl-ffi](https://github.com/dgraham/yajl-ffi) * [application/json-seq](http://www.rfc-editor.org/rfc/rfc7464.txt) +## Development + +``` +$ bin/setup +$ bin/rake test +``` + ## License JSON::Stream is released under the MIT license. Check the LICENSE file for details. From 1b3ed3edfbc27bad01934cb9c045e58446e2b13b Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:36:43 -0600 Subject: [PATCH 06/25] Fix MiniTest warnings --- spec/builder_spec.rb | 2 +- spec/parser_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb index a382153..e10507f 100644 --- a/spec/builder_spec.rb +++ b/spec/builder_spec.rb @@ -152,6 +152,6 @@ assert_equal 'rails', subject.result['name'] assert_equal 4223, subject.result['owner']['id'] assert_equal false, subject.result['fork'] - assert_equal nil, subject.result['mirror_url'] + assert_nil subject.result['mirror_url'] end end diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index fb4547e..22e69a1 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -813,7 +813,7 @@ it 'parses a null keyword literal document' do result = JSON::Stream::Parser.parse('null') - assert_equal nil, result + assert_nil result end it 'parses a string literal document' do From 9b81805999f94b47fbdaa5df6dedf78099446e21 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:44:02 -0600 Subject: [PATCH 07/25] Type check against Integer super class Fixes Fixnum deprecation warnings in Ruby 2.4. --- lib/json/stream/parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/json/stream/parser.rb b/lib/json/stream/parser.rb index ca4972f..ed1f89d 100644 --- a/lib/json/stream/parser.rb +++ b/lib/json/stream/parser.rb @@ -220,12 +220,12 @@ def <<(data) if @unicode.size == 4 codepoint = @unicode.slice!(0, 4).hex if codepoint >= 0xD800 && codepoint <= 0xDBFF - error('Expected low surrogate pair half') if @stack[-1].is_a?(Fixnum) + error('Expected low surrogate pair half') if @stack[-1].is_a?(Integer) @state = :start_surrogate_pair @stack.push(codepoint) elsif codepoint >= 0xDC00 && codepoint <= 0xDFFF high = @stack.pop - error('Expected high surrogate pair half') unless high.is_a?(Fixnum) + error('Expected high surrogate pair half') unless high.is_a?(Integer) pair = ((high - 0xD800) * 0x400) + (codepoint - 0xDC00) + 0x10000 @buf << pair @state = :start_string From 9572dc4d2a3d110f93012041272c5b6b02037fb6 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sat, 20 May 2017 20:51:39 -0600 Subject: [PATCH 08/25] Add travis build settings --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4007fa9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +rvm: + - 2.2 + +before_install: + - gem update --system + - gem update bundler + +script: bundle exec rake test +cache: bundler +dist: trusty From a4b5bed25c008800ea25ec7e577388b4f264a4b6 Mon Sep 17 00:00:00 2001 From: David Graham Date: Fri, 29 Sep 2017 19:09:45 -0600 Subject: [PATCH 09/25] Add space after opening block brace --- README.md | 11 +++-------- lib/json/stream/parser.rb | 8 ++++---- spec/parser_spec.rb | 6 +++--- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 4ef985c..97d0757 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Again, while JSON::Stream can be used this way, if we just need to stream the document from disk or the network, we're better off using the yajl-ruby gem. Huge documents arriving over the network in small chunks to an EventMachine -receive_data loop is where JSON::Stream is really useful. Inside an +`receive_data` loop is where JSON::Stream is really useful. Inside an EventMachine::Connection subclass we might have: ```ruby @@ -52,8 +52,8 @@ def post_init end_object { puts "end object" } start_array { puts "start array" } end_array { puts "end array" } - key {|k| puts "key: #{k}" } - value {|v| puts "value: #{v}" } + key { |k| puts "key: #{k}" } + value { |v| puts "value: #{v}" } end end @@ -77,11 +77,6 @@ imagine the callbacks looking for an array named `rows` and processing sets of these row objects in small batches. Millions of rows, streaming over the network, can be processed in constant memory space this way. -## Dependencies - -* ruby >= 1.9.2 -* jruby >= 1.7 - ## Alternatives * [json](https://github.com/flori/json) diff --git a/lib/json/stream/parser.rb b/lib/json/stream/parser.rb index ed1f89d..9131a4f 100644 --- a/lib/json/stream/parser.rb +++ b/lib/json/stream/parser.rb @@ -12,8 +12,8 @@ module Stream # Examples # # parser = JSON::Stream::Parser.new - # parser.key {|key| puts key } - # parser.value {|value| puts value } + # parser.key { |key| puts key } + # parser.value { |value| puts value } # parser << '{"answer":' # parser << ' 42}' class Parser @@ -85,8 +85,8 @@ def self.parse(json) # end_object { puts "end object" } # start_array { puts "start array" } # end_array { puts "end array" } - # key {|k| puts "key: #{k}" } - # value {|v| puts "value: #{v}" } + # key { |k| puts "key: #{k}" } + # value { |v| puts "value: #{v}" } # end def initialize(&block) @state = :start_document diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index 22e69a1..935e6e9 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -857,8 +857,8 @@ end_document { events << :end_document } start_object { events << :start_object } end_object { events << :end_object } - key {|k| events << [:key, k] } - value {|v| events << [:value, v] } + key { |k| events << [:key, k] } + value { |v| events << [:value, v] } end parser << '{"key":12}' expected = [:start_document, :start_object, [:key, "key"], [:value, 12], :end_object, :end_document] @@ -879,7 +879,7 @@ def events(json, parser = nil) parser ||= JSON::Stream::Parser.new collector = Events.new(parser) begin - json.each_byte {|byte| parser << [byte].pack('C') } + json.each_byte { |byte| parser << [byte].pack('C') } rescue JSON::Stream::ParserError collector.error end From a58b44c0a82fdf253924d66ab0d9ec81d31f8748 Mon Sep 17 00:00:00 2001 From: David Graham Date: Fri, 29 Sep 2017 19:29:05 -0600 Subject: [PATCH 10/25] Require Ruby 2.0 or higher The default encoding changed to UTF-8 in Ruby 2.0. --- json-stream.gemspec | 2 +- lib/json/stream/buffer.rb | 2 -- lib/json/stream/builder.rb | 2 -- lib/json/stream/parser.rb | 2 -- lib/json/stream/version.rb | 2 -- spec/buffer_spec.rb | 2 -- spec/builder_spec.rb | 2 -- spec/parser_spec.rb | 2 -- 8 files changed, 1 insertion(+), 15 deletions(-) diff --git a/json-stream.gemspec b/json-stream.gemspec index 7459a0d..b3c5f1d 100644 --- a/json-stream.gemspec +++ b/json-stream.gemspec @@ -18,5 +18,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'minitest', '~> 5.10' s.add_development_dependency 'rake', '~> 10.3' - s.required_ruby_version = '>= 1.9.2' + s.required_ruby_version = '>= 2.0.0' end diff --git a/lib/json/stream/buffer.rb b/lib/json/stream/buffer.rb index 4d05fe4..cbefd8b 100644 --- a/lib/json/stream/buffer.rb +++ b/lib/json/stream/buffer.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module JSON module Stream # A character buffer that expects a UTF-8 encoded stream of bytes. diff --git a/lib/json/stream/builder.rb b/lib/json/stream/builder.rb index 3ecb0f0..2ae341f 100644 --- a/lib/json/stream/builder.rb +++ b/lib/json/stream/builder.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module JSON module Stream # A parser listener that builds a full, in memory, object from a JSON diff --git a/lib/json/stream/parser.rb b/lib/json/stream/parser.rb index 9131a4f..33e7925 100644 --- a/lib/json/stream/parser.rb +++ b/lib/json/stream/parser.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module JSON module Stream # Raised on any invalid JSON text. diff --git a/lib/json/stream/version.rb b/lib/json/stream/version.rb index 8fb44f0..da0e2fa 100644 --- a/lib/json/stream/version.rb +++ b/lib/json/stream/version.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - module JSON module Stream VERSION = '0.2.1' diff --git a/spec/buffer_spec.rb b/spec/buffer_spec.rb index 18bb122..33bcb6c 100644 --- a/spec/buffer_spec.rb +++ b/spec/buffer_spec.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - require 'json/stream' require 'minitest/autorun' diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb index e10507f..7968ce0 100644 --- a/spec/builder_spec.rb +++ b/spec/builder_spec.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - require 'json/stream' require 'minitest/autorun' diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index 935e6e9..ad021f8 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - require 'json/stream' require 'minitest/autorun' From c3512cae83309c492e9cbf712a4ad0afcaa9932c Mon Sep 17 00:00:00 2001 From: David Graham Date: Fri, 29 Sep 2017 19:32:41 -0600 Subject: [PATCH 11/25] Update development dependencies --- json-stream.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json-stream.gemspec b/json-stream.gemspec index b3c5f1d..911af6a 100644 --- a/json-stream.gemspec +++ b/json-stream.gemspec @@ -14,9 +14,9 @@ Gem::Specification.new do |s| s.files = Dir['[A-Z]*', 'json-stream.gemspec', '{lib}/**/*'] - ['Gemfile.lock'] s.require_path = 'lib' - s.add_development_dependency 'bundler', '~> 1.14' + s.add_development_dependency 'bundler', '~> 1.15' s.add_development_dependency 'minitest', '~> 5.10' - s.add_development_dependency 'rake', '~> 10.3' + s.add_development_dependency 'rake', '~> 12.1' s.required_ruby_version = '>= 2.0.0' end From 733cba1517e9b67555df79712bbd5357ac33ed03 Mon Sep 17 00:00:00 2001 From: David Graham Date: Fri, 29 Sep 2017 19:34:43 -0600 Subject: [PATCH 12/25] Test on Ruby 2.3 and 2.4 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4007fa9..3802ed7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: ruby rvm: + - 2.4 + - 2.3 - 2.2 before_install: From 95533c2c1cda0f0e678e2bacad12a78cc42ec6d3 Mon Sep 17 00:00:00 2001 From: David Graham Date: Fri, 29 Sep 2017 19:37:16 -0600 Subject: [PATCH 13/25] Trusty is the default now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3802ed7..facd458 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,3 @@ before_install: script: bundle exec rake test cache: bundler -dist: trusty From 4982a7c3e22ffa77f493ee3d790860d4a0586e8c Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 30 Aug 2020 13:07:49 -0600 Subject: [PATCH 14/25] Use bundler 2.1 --- json-stream.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json-stream.gemspec b/json-stream.gemspec index 911af6a..d5cbbd9 100644 --- a/json-stream.gemspec +++ b/json-stream.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.files = Dir['[A-Z]*', 'json-stream.gemspec', '{lib}/**/*'] - ['Gemfile.lock'] s.require_path = 'lib' - s.add_development_dependency 'bundler', '~> 1.15' + s.add_development_dependency 'bundler', '~> 2.1' s.add_development_dependency 'minitest', '~> 5.10' s.add_development_dependency 'rake', '~> 12.1' From 5727de436cb2fae7459d66d07c2c490e27f60d45 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 30 Aug 2020 13:08:27 -0600 Subject: [PATCH 15/25] Fix minitest deprecation warnings --- spec/buffer_spec.rb | 18 +++++++++--------- spec/parser_spec.rb | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spec/buffer_spec.rb b/spec/buffer_spec.rb index 33bcb6c..d5c97bc 100644 --- a/spec/buffer_spec.rb +++ b/spec/buffer_spec.rb @@ -53,39 +53,39 @@ assert_equal '[', subject << '[' assert_equal '"', subject << '"' assert_equal '', subject << "\xC3" - -> { subject << '"' }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << '"' } end it 'rejects invalid two byte start characters' do - -> { subject << "\xC3\xC3" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xC3\xC3" } end it 'rejects invalid three byte start characters' do - -> { subject << "\xE2\xE2" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xE2\xE2" } end it 'rejects invalid four byte start characters' do - -> { subject << "\xF0\xF0" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xF0\xF0" } end it 'rejects a two byte start with single byte continuation character' do - -> { subject << "\xC3\u0000" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xC3\u0000" } end it 'rejects a three byte start with single byte continuation character' do - -> { subject << "\xE2\u0010" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xE2\u0010" } end it 'rejects a four byte start with single byte continuation character' do - -> { subject << "\xF0a" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xF0a" } end it 'rejects an invalid continuation character' do - -> { subject << "\xA9" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xA9" } end it 'rejects an overlong form' do - -> { subject << "\xC0\x80" }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject << "\xC0\x80" } end describe 'checking for empty buffers' do diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index ad021f8..a273758 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -177,57 +177,57 @@ describe 'finishing the parse' do it 'rejects finish with no json data provided' do - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial null keyword' do subject << 'nul' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial true keyword' do subject << 'tru' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial false keyword' do subject << 'fals' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial float literal' do subject << '42.' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial exponent' do subject << '42e' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects malformed exponent' do subject << '42e+' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial negative number' do subject << '-' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial string literal' do subject << '"test' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial object ending in literal value' do subject << '{"test": 42' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'rejects partial array ending in literal value' do subject << '[42' - -> { subject.finish }.must_raise JSON::Stream::ParserError + assert_raises(JSON::Stream::ParserError) { subject.finish } end it 'does nothing on subsequent finish' do From 7552ffc01296989a8f872b72c829252a0a7e1cc9 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 30 Aug 2020 14:11:54 -0600 Subject: [PATCH 16/25] Build with GitHub Actions --- .github/workflows/ruby.yml | 14 ++++++++++++++ .travis.yml | 12 ------------ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ruby.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..a1d15d3 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,14 @@ +on: [push, pull_request] +name: Build +jobs: + test: + name: rake test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6' + - run: | + gem install bundler --no-document + bundle exec rake test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index facd458..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: ruby -rvm: - - 2.4 - - 2.3 - - 2.2 - -before_install: - - gem update --system - - gem update bundler - -script: bundle exec rake test -cache: bundler From 63a963e6563652a09a5dc5d11f27a9fc84aea65a Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 30 Aug 2020 16:54:12 -0600 Subject: [PATCH 17/25] Run bundle install --- .github/workflows/ruby.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index a1d15d3..d17f520 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -11,4 +11,5 @@ jobs: ruby-version: '2.6' - run: | gem install bundler --no-document + bundle install bundle exec rake test From e0dc200d9d24209f3ac03d0d965901c34e90ac0c Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 31 Jan 2022 14:14:18 +0900 Subject: [PATCH 18/25] ci: Test with Ruby 2.6, 2.7, 3.0, 3.1 and head We need to use ruby/setup-ruby instead of actions/setup-ruby. actions/setup-ruby is deprecated. It doesn't support newer Rubies. See: https://github.com/actions/setup-ruby/commit/e932e7af67fc4a8fc77bd86b744acd4e42fe3543 We can use bundler-cache to run Bundler and cache the result with ruby/setup-ruby: https://github.com/ruby/setup-ruby#bundler --- .github/workflows/ruby.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index d17f520..fd38fb3 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -4,12 +4,20 @@ jobs: test: name: rake test runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: + - head + - "3.1" + - "3.0" + - "2.7" + - "2.6" steps: - uses: actions/checkout@v2 - - uses: actions/setup-ruby@v1 + - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.6' + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true - run: | - gem install bundler --no-document - bundle install bundle exec rake test From 10bc2971009d07393f1f36ad00f5860d0da930fe Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 10:30:59 -0600 Subject: [PATCH 19/25] 0.2.2 --- LICENSE | 2 +- lib/json/stream/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 2e899bc..df4e409 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2017 David Graham +Copyright (c) 2010-2024 David Graham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/json/stream/version.rb b/lib/json/stream/version.rb index da0e2fa..4373f91 100644 --- a/lib/json/stream/version.rb +++ b/lib/json/stream/version.rb @@ -1,5 +1,5 @@ module JSON module Stream - VERSION = '0.2.1' + VERSION = '0.2.2' end end From f61f149401db8f018e3ddd01599f2bd3a33569d8 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 10:40:49 -0600 Subject: [PATCH 20/25] Ignore gem builds --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0cb6eeb..b7e7725 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /pkg/ /spec/reports/ /tmp/ +*.gem From d334afc86384affb25bfd83b1017a3f8f9af9282 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 10:41:27 -0600 Subject: [PATCH 21/25] Test on latest 3.x releases --- .github/workflows/ruby.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index fd38fb3..6d70240 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -9,6 +9,8 @@ jobs: matrix: ruby-version: - head + - "3.3" + - "3.2" - "3.1" - "3.0" - "2.7" From 1f416066a94fbe171c93499bc89c065e134ef436 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 19:36:45 -0600 Subject: [PATCH 22/25] Require Ruby 2.6 or higher --- json-stream.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/json-stream.gemspec b/json-stream.gemspec index d5cbbd9..5a4bbb4 100644 --- a/json-stream.gemspec +++ b/json-stream.gemspec @@ -14,9 +14,9 @@ Gem::Specification.new do |s| s.files = Dir['[A-Z]*', 'json-stream.gemspec', '{lib}/**/*'] - ['Gemfile.lock'] s.require_path = 'lib' - s.add_development_dependency 'bundler', '~> 2.1' - s.add_development_dependency 'minitest', '~> 5.10' - s.add_development_dependency 'rake', '~> 12.1' + s.add_development_dependency 'bundler', '~> 2.4' + s.add_development_dependency 'minitest', '~> 5.22' + s.add_development_dependency 'rake', '~> 13.2' - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 2.6.0' end From 74bb758db3518746d5fef39a8d494031c16af6c9 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 19:44:10 -0600 Subject: [PATCH 23/25] Minimum Bundler version is 2.2 for Ruby 3.0 --- json-stream.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json-stream.gemspec b/json-stream.gemspec index 5a4bbb4..be96941 100644 --- a/json-stream.gemspec +++ b/json-stream.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.files = Dir['[A-Z]*', 'json-stream.gemspec', '{lib}/**/*'] - ['Gemfile.lock'] s.require_path = 'lib' - s.add_development_dependency 'bundler', '~> 2.4' + s.add_development_dependency 'bundler', '~> 2.2' s.add_development_dependency 'minitest', '~> 5.22' s.add_development_dependency 'rake', '~> 13.2' From 58a4f750e3fe80870934fbe252793a23d6290095 Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 19:48:12 -0600 Subject: [PATCH 24/25] Silence deprecation warnings --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 6d70240..84aa696 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,7 +16,7 @@ jobs: - "2.7" - "2.6" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} From 6f3557ccd7344718bc6b5fd8150a80d52f8a481e Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 21 Apr 2024 19:54:26 -0600 Subject: [PATCH 25/25] 1.0.0 Seems stable after 14 years. --- lib/json/stream/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/json/stream/version.rb b/lib/json/stream/version.rb index 4373f91..b062c4d 100644 --- a/lib/json/stream/version.rb +++ b/lib/json/stream/version.rb @@ -1,5 +1,5 @@ module JSON module Stream - VERSION = '0.2.2' + VERSION = '1.0.0' end end