Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
y-yagi authored Aug 25, 2024
2 parents 646dac4 + 472892e commit ec99979
Show file tree
Hide file tree
Showing 25 changed files with 277 additions and 60 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: CI

on:
- push
- pull_request

permissions:
contents: read

jobs:
rspec:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
ruby:
- '3.3'
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
- '2.5'
- '2.4'

services:
mongodb:
image: mongo
ports:
- 27017:27017

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: RSpec & publish code coverage
uses: paambaati/codeclimate-action@v8
env:
CC_TEST_REPORTER_ID: b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915
with:
coverageCommand: bin/rake
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Draper Changelog

## 4.0.2 - 2021-05-27

### Fixes
* Fix kwargs usage for Ruby 3 compatibility [#885](https://github.com/drapergem/draper/pull/885)
* Fix ruby warnings for "ambiguous first argument" [#881](https://github.com/drapergem/draper/pull/881)
* Fix rake warnings in CI [#897](https://github.com/drapergem/draper/pull/897)
* Fix decoration spec [#895](https://github.com/drapergem/draper/pull/895)

### Other Changes
* Migration from Travis CI to GitHub Actions [#893](https://github.com/drapergem/draper/pull/893), [#896](https://github.com/drapergem/draper/pull/896), [#903](https://github.com/drapergem/draper/pull/903)

## 4.0.1 - 2020-03-25

### Fixes
* Check only object's private methods when preventing delegation [#875](https://github.com/drapergem/draper/pull/875)

### Other Changes
* Use `alias` over `alias_method` [#877](https://github.com/drapergem/draper/pull/877)

## 4.0.0 - 2020-02-05

### Breaking Changes
Expand Down
22 changes: 20 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gemspec

platforms :ruby do
if RUBY_VERSION >= "2.5.0"
gem 'sqlite3'
gem 'sqlite3', '~> 1.4'
else
gem 'sqlite3', '~> 1.3.6'
end
Expand All @@ -17,7 +17,25 @@ end

if RUBY_VERSION >= "2.5.0"
gem "rails", "~> 6.0"
gem 'webrick'
else
gem "rails", "~> 5.0"
end
gem "mongoid", github: "mongodb/mongoid"

if RUBY_VERSION >= "2.7.0"
gem "mongoid", github: "mongodb/mongoid"
elsif RUBY_VERSION >= "2.6.0"
gem "mongoid", "~> 8.1"
else
gem "mongoid", "~> 7.2"
end

if RUBY_VERSION >= "3.1.0"
gem "net-imap"
gem "net-pop"
gem "net-smtp"
end

if RUBY_VERSION < "2.5.0"
gem "loofah", "< 2.21.0" # Workaround for `uninitialized constant Nokogiri::HTML4`
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Draper: View Models for Rails

[![TravisCI Build Status](https://travis-ci.org/drapergem/draper.svg?branch=master)](http://travis-ci.org/drapergem/draper)
[![Actions Status](https://github.com/drapergem/draper/workflows/CI/badge.svg?branch=master)](https://github.com/drapergem/draper/actions?query=workflow%3Aci+branch%3Amaster)
[![Code Climate](https://codeclimate.com/github/drapergem/draper.svg)](https://codeclimate.com/github/drapergem/draper)
[![Test Coverage](https://api.codeclimate.com/v1/badges/0d40c43951d516bf6985/test_coverage)](https://codeclimate.com/github/drapergem/draper/test_coverage)
[![Inline docs](http://inch-ci.org/github/drapergem/draper.svg?branch=master)](http://inch-ci.org/github/drapergem/draper)
Expand Down
114 changes: 114 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'bundle' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "rubygems"

m = Module.new do
module_function

def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
end

def env_var_version
ENV["BUNDLER_VERSION"]
end

def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
update_index = i
end
bundler_version
end

def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?

File.expand_path("../../Gemfile", __FILE__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end

def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end

def bundler_version
@bundler_version ||=
env_var_version || cli_arg_version ||
lockfile_version
end

def bundler_requirement
return "#{Gem::Requirement.default}.a" unless bundler_version

bundler_gem_version = Gem::Version.new(bundler_version)

requirement = bundler_gem_version.approximate_recommendation

return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")

requirement += ".a" if bundler_gem_version.prerelease?

requirement
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

activate_bundler
end

def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end

def activation_error_handling
yield
nil
rescue StandardError, LoadError => e
e
end
end

m.load_bundler!

if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end
29 changes: 29 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /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")
6 changes: 3 additions & 3 deletions draper.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.join(__dir__, "lib", "draper", "version")
require_relative 'lib/draper/version'

Gem::Specification.new do |s|
s.name = "draper"
Expand All @@ -12,7 +12,6 @@ Gem::Specification.new do |s|

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.required_ruby_version = '>= 2.2.2'
Expand All @@ -22,6 +21,7 @@ Gem::Specification.new do |s|
s.add_dependency 'request_store', '>= 1.0'
s.add_dependency 'activemodel', '>= 5.0'
s.add_dependency 'activemodel-serializers-xml', '>= 1.0'
s.add_dependency 'ruby2_keywords'

s.add_development_dependency 'ammeter'
s.add_development_dependency 'rake'
Expand All @@ -30,5 +30,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'capybara'
s.add_development_dependency 'active_model_serializers', '>= 0.10'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'simplecov', '0.17.1'
end
2 changes: 2 additions & 0 deletions lib/draper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core_ext/name_error'

require 'ruby2_keywords'

require 'draper/version'
require 'draper/configuration'
require 'draper/view_helpers'
Expand Down
4 changes: 2 additions & 2 deletions lib/draper/automatic_delegation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module AutomaticDelegation
# method calls to `object` as well. Calling `super` will first try to call the method on
# the parent decorator class. If no method exists on the parent class, it will then try
# to call the method on the `object`.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
return super unless delegatable?(method)

object.send(method, *args, &block)
Expand All @@ -27,7 +27,7 @@ def delegatable?(method)

module ClassMethods
# Proxies missing class methods to the source class.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
return super unless delegatable?(method)

object_class.send(method, *args, &block)
Expand Down
3 changes: 2 additions & 1 deletion lib/draper/helper_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(view_context)
end

# Sends helper methods to the view context.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
self.class.define_proxy method
send(method, *args, &block)
end
Expand All @@ -31,6 +31,7 @@ def self.define_proxy(name)
define_method name do |*args, &block|
view_context.send(name, *args, &block)
end
ruby2_keywords name
end
end
end
2 changes: 1 addition & 1 deletion lib/draper/lazy_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Draper
# bazillion methods.
module LazyHelpers
# Sends missing methods to the {HelperProxy}.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
helpers.send(method, *args, &block)
rescue NoMethodError
super
Expand Down
2 changes: 1 addition & 1 deletion lib/draper/query_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Draper
module QueryMethods
# Proxies missing query methods to the source class if the strategy allows.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
return super unless strategy.allowed? method

object.send(method, *args, &block).decorate(with: decorator_class, context: context)
Expand Down
2 changes: 1 addition & 1 deletion lib/draper/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Draper
VERSION = '4.0.0'
VERSION = '4.0.2'
end
2 changes: 1 addition & 1 deletion lib/draper/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def helpers

# Alias for `helpers.localize`, since localize is something that's used
# quite often. Further aliased to `l` for convenience.
def localize(*args)
ruby2_keywords def localize(*args)
helpers.localize(*args)
end

Expand Down
Loading

0 comments on commit ec99979

Please sign in to comment.