diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 880cb11..76ec04f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,18 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, jruby, truffleruby ] + ruby: + - 2.4 + - 2.5 + - 2.6 + - 2.7 + - 3.0 + - 3.1 + - 3.2 + - 3.3 + - jruby + - truffleruby + steps: - uses: actions/checkout@v4 @@ -24,7 +35,7 @@ jobs: bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Build and test with RSpec - run: bundle exec rake spec + run: bin/rspec - name: Publish code coverage uses: paambaati/codeclimate-action@v2.7.5 # Locking to specific version b/c: https://github.com/paambaati/codeclimate-action/issues/142 diff --git a/Gemfile b/Gemfile index f0bc7e1..d8968f0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,10 @@ +# frozen_string_literal: true + source "https://rubygems.org" # Specify your gem's dependencies in dumb_delegator.gemspec gemspec +gem "rake", "~> 13.0" +gem "rspec", "~> 3.9" gem "simplecov", group: :test, require: nil -gem "pry-byebug", group: [:development, :test], platforms: [:ruby] diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..4eb7d7b --- /dev/null +++ b/bin/rake @@ -0,0 +1,27 @@ +#!/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. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000..cb53ebe --- /dev/null +++ b/bin/rspec @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/dumb_delegator.gemspec b/dumb_delegator.gemspec index 3b9ad90..1f72054 100644 --- a/dumb_delegator.gemspec +++ b/dumb_delegator.gemspec @@ -1,31 +1,36 @@ require File.expand_path("../lib/dumb_delegator/version", __FILE__) -Gem::Specification.new do |gem| - gem.name = "dumb_delegator" - gem.version = DumbDelegator::VERSION - gem.required_ruby_version = ">= 2.4.0" - gem.authors = ["Andy Lindeman", "Steven Harman"] - gem.email = ["alindeman@gmail.com", "steven@harmanly.com"] - gem.licenses = ["MIT"] - gem.summary = "Delegator class that delegates ALL the things" - gem.description = <<~EOD +Gem::Specification.new do |spec| + spec.name = "dumb_delegator" + spec.version = DumbDelegator::VERSION + spec.required_ruby_version = ">= 2.4.0" + spec.authors = ["Andy Lindeman", "Steven Harman"] + spec.email = ["alindeman@gmail.com", "steven@harmanly.com"] + spec.licenses = ["MIT"] + spec.summary = "Delegator class that delegates ALL the things" + spec.description = <<~EOD Delegator and SimpleDelegator in Ruby's stdlib are useful, but they pull in most of Kernel. This is not appropriate for many uses; for instance, delegation to Rails Models. DumbDelegator, on the other hand, delegates nearly everything to the wrapped object. EOD - gem.homepage = "https://github.com/stevenharman/dumb_delegator" + spec.homepage = "https://github.com/stevenharman/dumb_delegator" - gem.metadata = { + spec.metadata = { "changelog_uri" => "https://github.com/stevenharman/dumb_delegator/blob/master/CHANGELOG.md", "documentation_uri" => "https://rubydoc.info/gems/dumb_delegator", + "homepage_uri" => spec.homepage, "source_code_uri" => "https://github.com/stevenharman/dumb_delegator" } - gem.files = `git ls-files`.split($\) - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.require_paths = ["lib"] - - gem.add_development_dependency "pry" - gem.add_development_dependency "rake", "~> 13.0" - gem.add_development_dependency "rspec", "~> 3.9" + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + spec.files = Dir.chdir(__dir__) do + `git ls-files -z`.split("\x0").reject do |f| + (File.expand_path(f) == __FILE__) || + f.start_with?(*%w[bin/ spec/ .git .github Gemfile]) + end + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] end diff --git a/lib/dumb_delegator.rb b/lib/dumb_delegator.rb index 581e329..03b0b1f 100644 --- a/lib/dumb_delegator.rb +++ b/lib/dumb_delegator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "dumb_delegator/triple_equal_ext" require "dumb_delegator/version" diff --git a/lib/dumb_delegator/triple_equal_ext.rb b/lib/dumb_delegator/triple_equal_ext.rb index 4320d4d..81322ac 100644 --- a/lib/dumb_delegator/triple_equal_ext.rb +++ b/lib/dumb_delegator/triple_equal_ext.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DumbDelegator < ::BasicObject ## # This optional extension enables a Class/Module to support +case+ statements. diff --git a/lib/dumb_delegator/version.rb b/lib/dumb_delegator/version.rb index 58d0ba4..f8c8bb5 100644 --- a/lib/dumb_delegator/version.rb +++ b/lib/dumb_delegator/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DumbDelegator < ::BasicObject VERSION = "1.1.0" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 32cde4f..ea2e388 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,6 @@ SimpleCov.start end -require "pry" require File.expand_path("../lib/dumb_delegator", File.dirname(__FILE__)) RSpec.configure do |config|