Skip to content

Commit

Permalink
Modernize gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 10, 2020
1 parent be65b4d commit 260576f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 53 deletions.
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--format documentation
--color
--require spec_helper
--warnings
24 changes: 15 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
language: ruby
sudo: false
rvm:
- 2.2.4
- 2.3.2
- 2.4.0
- ruby-head
- rbx-3.65
env: COVERAGE=true
dist: xenial
cache: bundler

matrix:
include:
- rvm: 2.4
- rvm: 2.5
- rvm: 2.6
- rvm: 2.6
env: COVERAGE=PartialSummary,Coveralls
- rvm: 2.7
- rvm: truffleruby
- rvm: jruby-head
- rvm: ruby-head
allow_failures:
- rvm: rbx-3.65
- rvm: truffleruby
- rvm: ruby-head
- rvm: jruby-head
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in utopia.gemspec
gemspec

group :test do
gem 'simplecov'
gem 'coveralls', require: false
end
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Provides a policy for Rack middleware which should be frozen by default to prevent mutability bugs in a multi-threaded environment.

[![Build Status](https://secure.travis-ci.org/ioquatix/rack-freeze.svg)](http://travis-ci.org/ioquatix/rack-freeze)
**In Rack 2.1+, you can use `Builder::freeze_app` instead of this gem.**

[![Build Status](https://travis-ci.com/ioquatix/rack-freeze.svg)](https://travis-ci.com/ioquatix/rack-freeze)
[![Code Climate](https://codeclimate.com/github/ioquatix/rack-freeze.svg)](https://codeclimate.com/github/ioquatix/rack-freeze)
[![Coverage Status](https://coveralls.io/repos/ioquatix/rack-freeze/badge.svg)](https://coveralls.io/r/ioquatix/rack-freeze)

Expand Down Expand Up @@ -100,7 +102,7 @@ end

Released under the MIT license.

Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com).

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new

task :default => :spec
5 changes: 3 additions & 2 deletions lib/rack/freeze/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
# THE SOFTWARE.

require 'rack/builder'

require_relative 'freezer'

module Rack
module Freeze
module Builder
def use(klass, *args, &block)
super Freezer.new(klass), *args, &block
def use(klass, *arguments, &block)
super Freezer.new(klass), *arguments, &block
end

def run(app)
Expand Down
6 changes: 4 additions & 2 deletions lib/rack/freeze/freezer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require "ruby2_keywords"

module Rack
module Freeze
class Freezer
Expand All @@ -29,8 +31,8 @@ def to_s
"#{self.class}<#{@klass}>"
end

def new(*args, &block)
@klass.new(*args, &block).freeze
ruby2_keywords def new(*arguments, &block)
@klass.new(*arguments, &block).freeze
end
end
end
Expand Down
26 changes: 14 additions & 12 deletions rack-freeze.gemspec
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# coding: utf-8
require_relative 'lib/rack/freeze/version'

Gem::Specification.new do |spec|
spec.name = "rack-freeze"
spec.version = Rack::Freeze::VERSION
spec.authors = ["Samuel Williams"]
spec.email = ["samuel.williams@oriontransfer.co.nz"]

spec.summary = "Provides a policy for frozen rack middleware."
spec.homepage = "https://github.com/ioquatix/rack-freeze"

spec.files = `git ls-files -z`.split("\x0").reject do |f|
spec.name = "rack-freeze"
spec.version = Rack::Freeze::VERSION
spec.authors = ["Samuel Williams"]
spec.email = ["samuel.williams@oriontransfer.co.nz"]
spec.summary = "Provides a policy for frozen rack middleware."
spec.homepage = "https://github.com/ioquatix/rack-freeze"
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.require_paths = ["lib"]

spec.add_dependency "rack", "~> 2.0"

spec.add_development_dependency "bundler", "~> 1.14"

spec.add_dependency "ruby2_keywords"

spec.add_development_dependency "covered"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
end
2 changes: 2 additions & 0 deletions spec/rack/freeze/builder.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

require 'rack/freeze'

RSpec.shared_examples_for "frozen middleware" do
it "should be entirely frozen" do
current = builder.to_app
Expand Down
21 changes: 2 additions & 19 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@

if ENV['COVERAGE']
begin
require 'simplecov'

SimpleCov.start do
add_filter "/spec/"
end

if ENV['TRAVIS']
require 'coveralls'
Coveralls.wear!
end
rescue LoadError
warn "Could not load simplecov: #{$!}"
end
end

require "bundler/setup"
require "rack/freeze"
require 'covered/rspec'
require 'bundler/setup'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down

0 comments on commit 260576f

Please sign in to comment.