From bc118a14d11e914dce91aedf6d5d103b38ab75c3 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Tue, 30 May 2017 17:50:02 +0200 Subject: [PATCH] Stop generating gemspec file. (#181) * Because the generating is confusing us including contributors. * The reason of new file lib/rack/test/version.rb is because of preventing an error when "rack/test" is loaded recursively in gemspec file. * Add release way to README again because that is useful for people who do release. --- .travis.yml | 8 +++ Gemfile | 13 +---- Gemfile.rack-1.x | 7 --- README.md | 6 +++ Thorfile | 70 +------------------------ lib/rack/test.rb | 3 +- lib/rack/test/version.rb | 5 ++ rack-test.gemspec | 108 ++++++++++----------------------------- 8 files changed, 52 insertions(+), 168 deletions(-) create mode 100644 lib/rack/test/version.rb diff --git a/.travis.yml b/.travis.yml index cd70dea6..3e66ee13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,15 @@ before_install: - which bundle || gem install bundler script: - bundle list + # Unit test - bundle exec rake + # Release test + - bundle exec thor :build + - ls -l pkg/rack-test-*.gem + - gem install pkg/rack-test-*.gem + - gem list rack-test + - ruby -e 'require "rack/test"' + - gem specification pkg/rack-test-*.gem --ruby rvm: - 2.2.7 - 2.3.4 diff --git a/Gemfile b/Gemfile index 02f3d405..401d11cf 100644 --- a/Gemfile +++ b/Gemfile @@ -2,14 +2,5 @@ source 'https://rubygems.org' gemspec -# Development dependency -gem 'rake' -gem 'rspec' -# To use rack 2 -gem 'sinatra', '~> 2.0' -# Keep version < 1 to supress deprecated warning temporary. -gem 'codeclimate-test-reporter', '< 1', :require => false - -# For Thorfile. Run "bundle exec thor help" to see the help. -gem 'thor' -gem 'git' +# Runtime dependency +gem 'rack', '~> 2.0' diff --git a/Gemfile.rack-1.x b/Gemfile.rack-1.x index 61c5da26..750bb3ab 100644 --- a/Gemfile.rack-1.x +++ b/Gemfile.rack-1.x @@ -4,10 +4,3 @@ gemspec # Runtime dependency gem 'rack', '< 2' - -# Development dependency -gem 'rake' -gem 'rspec' -gem 'sinatra' -# Keep version < 1 to supress deprecated warning temporary. -gem 'codeclimate-test-reporter', '< 1', :require => false diff --git a/README.md b/README.md index 16e62fcf..f8cc1b5e 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,9 @@ Contributions are welcome. Please make sure to: * Write tests for the new or changed behaviour * Provide an explanation/motivation in your commit message / PR message * Ensure History.txt is updated + +## Releasing + +* Ensure History.txt is up-to-date +* Bump VERSION in lib/rack/test/version.rb +* bundle exec thor :release diff --git a/Thorfile b/Thorfile index 0765b285..7401e87d 100644 --- a/Thorfile +++ b/Thorfile @@ -1,54 +1,4 @@ module GemHelpers - - def generate_gemspec - $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib"))) - require "rack/test" - - Gem::Specification.new do |s| - s.name = "rack-test" - s.version = Rack::Test::VERSION - s.author = "Bryan Helmkamp" - s.email = "bryan@brynary.com" - s.license = "MIT" - s.homepage = "http://github.com/rack-test/rack-test" - s.summary = "Simple testing API built on Rack" - s.description = <<-EOS.strip -Rack::Test is a small, simple testing API for Rack apps. It can be used on its -own or as a reusable starting point for Web frameworks and testing libraries -to build on. Most of its initial functionality is an extraction of Merb 1.0's -request helpers feature. - EOS - s.rubyforge_project = "rack-test" - - require "git" - repo = Git.open(".") - - s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files) - s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files) - - s.has_rdoc = true - s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt] - - s.add_dependency "rack", ">= 1.0" - end - end - - def normalize_files(array) - # only keep files, no directories, and sort - array.select do |path| - File.file?(path) - end.sort - end - - # Adds extra space when outputting an array. This helps create better version - # control diffs, because otherwise it is all on the same line. - def prettyify_array(gemspec_ruby, array_name) - gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match| - leadin, files = match[0..-2].split("[") - leadin + "[\n #{files.split(",").join(",\n ")}\n ]" - end - end - def read_gemspec @read_gemspec ||= eval(File.read("rack-test.gemspec")) end @@ -62,21 +12,6 @@ end class Default < Thor include GemHelpers - desc "gemspec", "Regenerate rack-test.gemspec" - def gemspec - File.open("rack-test.gemspec", "w") do |file| - gemspec_ruby = generate_gemspec.to_ruby - gemspec_ruby = prettyify_array(gemspec_ruby, :files) - gemspec_ruby = prettyify_array(gemspec_ruby, :test_files) - gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files) - - file.write gemspec_ruby - end - - puts "Wrote gemspec to rack-test.gemspec" - read_gemspec.validate - end - desc "build", "Build a rack-test gem" def build sh "gem build rack-test.gemspec" @@ -89,9 +24,8 @@ class Default < Thor sh "gem install --local pkg/#{read_gemspec.file_name}" end - desc "release", "Release the current branch to GitHub and Gemcutter" + desc "release", "Release the current branch to GitHub and RubyGems.org" def release - gemspec build Release.new.tag Release.new.gem @@ -108,7 +42,7 @@ class Release < Thor sh "git push origin #{release_tag}" end - desc "gem", "Push the gem to Gemcutter" + desc "gem", "Push the gem to RubyGems.org" def gem sh "gem push pkg/#{read_gemspec.file_name}" end diff --git a/lib/rack/test.rb b/lib/rack/test.rb index fed790f0..b7288c62 100644 --- a/lib/rack/test.rb +++ b/lib/rack/test.rb @@ -6,11 +6,10 @@ require "rack/test/utils" require "rack/test/methods" require "rack/test/uploaded_file" +require "rack/test/version" module Rack module Test - VERSION = "0.6.3" - DEFAULT_HOST = "example.org" MULTIPART_BOUNDARY = "----------XnJLe9ZIbbGUYtzPQJ16u1" diff --git a/lib/rack/test/version.rb b/lib/rack/test/version.rb new file mode 100644 index 00000000..3a51a866 --- /dev/null +++ b/lib/rack/test/version.rb @@ -0,0 +1,5 @@ +module Rack + module Test + VERSION = "0.6.3" + end +end diff --git a/rack-test.gemspec b/rack-test.gemspec index 317615bb..8d0d76ac 100644 --- a/rack-test.gemspec +++ b/rack-test.gemspec @@ -1,84 +1,32 @@ # -*- encoding: utf-8 -*- -# stub: rack-test 0.6.3 ruby lib -Gem::Specification.new do |s| - s.name = "rack-test" - s.version = "0.6.3" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] - s.authors = ["Bryan Helmkamp"] - s.date = "2017-05-08" - s.description = "Rack::Test is a small, simple testing API for Rack apps. It can be used on its\nown or as a reusable starting point for Web frameworks and testing libraries\nto build on. Most of its initial functionality is an extraction of Merb 1.0's\nrequest helpers feature." - s.email = "bryan@brynary.com" - s.extra_rdoc_files = [ - "README.rdoc", - "MIT-LICENSE.txt" - ] - s.files = [ - ".document", - ".gitignore", - ".travis.yml", - "Gemfile", - "Gemfile.rack-1.x", - "History.txt", - "MIT-LICENSE.txt", - "README.rdoc", - "Rakefile", - "Thorfile", - "lib/rack/mock_session.rb", - "lib/rack/test.rb", - "lib/rack/test/cookie_jar.rb", - "lib/rack/test/methods.rb", - "lib/rack/test/mock_digest_request.rb", - "lib/rack/test/uploaded_file.rb", - "lib/rack/test/utils.rb", - "rack-test.gemspec", - "spec/fixtures/bar.txt", - "spec/fixtures/config.ru", - "spec/fixtures/fake_app.rb", - "spec/fixtures/foo.txt", - "spec/rack/test/cookie_jar_spec.rb", - "spec/rack/test/cookie_object_spec.rb", - "spec/rack/test/cookie_spec.rb", - "spec/rack/test/digest_auth_spec.rb", - "spec/rack/test/multipart_spec.rb", - "spec/rack/test/uploaded_file_spec.rb", - "spec/rack/test/utils_spec.rb", - "spec/rack/test_spec.rb", - "spec/spec_helper.rb", - "spec/support/matchers/body.rb", - "spec/support/matchers/challenge.rb" - ] - s.homepage = "http://github.com/rack-test/rack-test" - s.licenses = ["MIT"] - s.rubyforge_project = "rack-test" - s.rubygems_version = "2.4.5.2" - s.summary = "Simple testing API built on Rack" - s.test_files = [ - "spec/fixtures/fake_app.rb", - "spec/rack/test/cookie_jar_spec.rb", - "spec/rack/test/cookie_object_spec.rb", - "spec/rack/test/cookie_spec.rb", - "spec/rack/test/digest_auth_spec.rb", - "spec/rack/test/multipart_spec.rb", - "spec/rack/test/uploaded_file_spec.rb", - "spec/rack/test/utils_spec.rb", - "spec/rack/test_spec.rb", - "spec/spec_helper.rb", - "spec/support/matchers/body.rb", - "spec/support/matchers/challenge.rb" - ] +$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) +require 'rack/test/version' - if s.respond_to? :specification_version then - s.specification_version = 4 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 1.0"]) - else - s.add_dependency(%q, [">= 1.0"]) - end - else - s.add_dependency(%q, [">= 1.0"]) - end +Gem::Specification.new do |s| + s.name = 'rack-test' + s.version = Rack::Test::VERSION + s.platform = Gem::Platform::RUBY + s.author = 'Bryan Helmkamp' + s.email = 'bryan@brynary.com' + s.license = 'MIT' + s.homepage = 'http://github.com/rack-test/rack-test' + s.summary = 'Simple testing API built on Rack' + s.description = <<-EOS.strip +Rack::Test is a small, simple testing API for Rack apps. It can be used on its +own or as a reusable starting point for Web frameworks and testing libraries +to build on. Most of its initial functionality is an extraction of Merb 1.0's +request helpers feature. + EOS + s.require_paths = ['lib'] + s.files = `git ls-files -- lib/*`.split("\n") + + %w[History.md MIT-LICENSE.txt README.md] + s.add_dependency 'rack', '>= 1.0', '< 3' + s.add_development_dependency 'rake', '~> 12.0' + s.add_development_dependency 'rspec', '~> 3.6' + s.add_development_dependency 'sinatra', '>= 1.0', '< 3' + # Keep version < 1 to supress deprecated warning temporary. + s.add_development_dependency 'codeclimate-test-reporter', '~> 0.6' + # For Thorfile. Run "bundle exec thor help" to see the help. + s.add_development_dependency 'thor', '~> 0.19' end