Skip to content

Commit

Permalink
Update Gem config for modern times
Browse files Browse the repository at this point in the history
Moving dev dependencies into the Gemfile, removing pry (b/c we have
ruby-debug now), adding frozen_string_literal, etc…
  • Loading branch information
stevenharman committed Dec 17, 2024
1 parent a0ec8e9 commit f8df9f4
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 22 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected] # Locking to specific version b/c: https://github.com/paambaati/codeclimate-action/issues/142
Expand Down
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -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]
27 changes: 27 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -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")
27 changes: 27 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -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")
41 changes: 23 additions & 18 deletions dumb_delegator.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ["[email protected]", "[email protected]"]
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 = ["[email protected]", "[email protected]"]
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
2 changes: 2 additions & 0 deletions lib/dumb_delegator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "dumb_delegator/triple_equal_ext"
require "dumb_delegator/version"

Expand Down
2 changes: 2 additions & 0 deletions lib/dumb_delegator/triple_equal_ext.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class DumbDelegator < ::BasicObject
##
# This optional extension enables a Class/Module to support +case+ statements.
Expand Down
2 changes: 2 additions & 0 deletions lib/dumb_delegator/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class DumbDelegator < ::BasicObject
VERSION = "1.1.0"
end
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
SimpleCov.start
end

require "pry"
require File.expand_path("../lib/dumb_delegator", File.dirname(__FILE__))

RSpec.configure do |config|
Expand Down

0 comments on commit f8df9f4

Please sign in to comment.