Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform gem maintenance tasks #23

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches:
- main
pull_request:
jobs:
test:
strategy:
matrix:
ruby: [ '3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4' ]
fail-fast: false
runs-on: ubuntu-latest
name: ${{ matrix.ruby }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rspec

env:
BUNDLE_JOBS: 4
BUNDLE_PATH: vendor/bundle
CI: true
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gemspec
gem 'rubocop', group: 'development', require: false

group :development do
gem "standard", require: false
end
48 changes: 25 additions & 23 deletions certs/parndt.pem
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
-----BEGIN CERTIFICATE-----
MIIEMjCCApqgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhnZW1z
L0RDPXAvREM9YXJuZHQvREM9aW8wHhcNMTgxMDI5MDk0MjQ5WhcNMTkxMDI5MDk0
MjQ5WjAjMSEwHwYDVQQDDBhnZW1zL0RDPXAvREM9YXJuZHQvREM9aW8wggGiMA0G
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQClF0/voptshDoTILF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YP43s4Nd0gx/ryHSR3EMBoGA1UdEQQTMBGBD2dlbXNA
cC5hcm5kdC5pbzAaBgNVHRIEEzARgQ9nZW1zQHAuYXJuZHQuaW8wDQYJKoZIhvcN
AQELBQADggGBAAw69VoNOTd5HQOQczs0zm+p5bZw3e+EFiDy/N9o8Lv5rHfyGhA5
f+faBqfxQHDB3VSEFtCnoVFsCUaC1AdRzWztqS40x5GgQRwcM2llTwMYv5C++gC2
xPchTvi5FgDI++a05isObUvtNZ/wrZYBhy75ofzGAAMfuB/+XzsGbsOxSwZVlCne
YLkPa26euounYtKRGLz+X9YD4vDHP5VwsrqsvACMwVGHv+MIM3TQ3TvVrQ7QR9Ov
yUmuDhnAXep8omj9HyiukfqIdTsIMZK8nMcJH4wXC7mjjOBoyRtMwsQIT8OpwSP9
A7++64WBwTLbbGSCMCdw8X1kmmaZjaPrNkJ4wNaeJPZPPgDmL1XKJavQ8xZ/nwGF
VXf+6/IyX9OrQwL2uw0b+1NiR2gFpOLcOy2ixKdua13S9CWRRsR3VJve+PIyycC7
aLV+FI9i9b1YUXG2gDKqLOkF/FNBWNckAmGj7kYkdLG76G5aRGP0HvfKbIiQ3HTC
jAtsfxiSgc0fAw==
-----END CERTIFICATE-----
28 changes: 14 additions & 14 deletions decorators.gemspec
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = %q{decorators}
s.version = %q{2.0.6}
s.description = %q{Manages the process of loading decorators into your Rails application.}
s.summary = %q{Rails decorators plugin.}
s.email = %q{[email protected]}
s.homepage = %q{https://github.com/parndt/decorators}
s.authors = ["Philip Arndt"]
s.license = %q{MIT}
s.require_paths = %w(lib)
s.platform = Gem::Platform::RUBY
s.name = "decorators"
s.version = "2.0.6"
s.description = "Manages the process of loading decorators into your Rails application."
s.summary = "Rails decorators plugin."
s.email = "[email protected]"
s.homepage = "https://github.com/parndt/decorators"
s.authors = ["Philip Arndt"]
s.license = "MIT"
s.require_paths = %w[lib]

s.files = %w[
s.files = %w[
lib/decorators.rb
lib/decorators/paths.rb
lib/decorators/railtie.rb
license.md
readme.md
]

s.add_dependency "railties", ">= 4.0.0", "< 7.2"
s.add_dependency "railties", ">= 4.0.0", "< 7.2"
s.add_development_dependency "rspec", "~> 3.5", ">= 3.5.0"

s.cert_chain = ["certs/parndt.pem"]
if $0 =~ /gem\z/ && ARGV.include?("build") && ARGV.include?(__FILE__)
s.cert_chain = ["certs/parndt.pem"]
if $0.end_with?("gem") && ARGV.include?("build") && ARGV.include?(__FILE__)
s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
end
end
10 changes: 5 additions & 5 deletions lib/decorators.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Decorators
require 'decorators/paths'
require "decorators/paths"

class << self
def load!(cache_classes)
Expand All @@ -23,23 +23,23 @@ def register!(*paths_to_register)
end

protected

def paths
@paths ||= Paths.new
end

def apply_decorators_pattern_to_path(path)
path.join *pattern
path.join(*pattern)
end

def find_decorators_in_path(path)
Dir[apply_decorators_pattern_to_path(path)]
end

def pattern
['app', 'decorators', '*', '**', '*_decorator.rb']
["app", "decorators", "*", "**", "*_decorator.rb"]
end
end

end

require 'decorators/railtie'
require "decorators/railtie"
5 changes: 2 additions & 3 deletions lib/decorators/paths.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
require 'pathname'
require "pathname"

module Decorators
class Paths

attr_reader :registered

def initialize(*args)
@registered = Array.new(*args)
end

def register!(path)
@registered << Pathname.new(path)
end

end
end
4 changes: 1 addition & 3 deletions lib/decorators/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require 'rails'
require "rails"

module Decorators
class Railtie < Rails::Railtie

config.before_initialize do |app|
loader = proc { Decorators.load!(app.config.cache_classes) }

Expand All @@ -12,6 +11,5 @@ class Railtie < Rails::Railtie
app.config.to_prepare(&loader)
end
end

end
end
14 changes: 7 additions & 7 deletions spec/decorators/path_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
require 'spec_helper'
require "spec_helper"

describe Decorators::Paths do
context "initialized without arguments" do
let(:paths) {Decorators::Paths.new}
let(:paths) { Decorators::Paths.new }

it 'initialize empty array' do
it "initialize empty array" do
expect(paths.registered).to eq([])
end

it 'adds path to registered paths' do
it "adds path to registered paths" do
paths.register! "mypath"
expect(paths.registered).to eq([Pathname.new("mypath")])
end
end

context "initialized with arguments" do
let(:paths) {Decorators::Paths.new([Pathname("initpath")])}
let(:paths) { Decorators::Paths.new([Pathname("initpath")]) }

it 'initialize array with argument path' do
it "initialize array with argument path" do
expect(paths.registered).to eq([Pathname.new("initpath")])
end

it 'adds path to registered paths' do
it "adds path to registered paths" do
paths.register! "mypath"
expect(paths.registered.count).to eq(2)
expect(paths.registered.last).to eq(Pathname.new("mypath"))
Expand Down
19 changes: 9 additions & 10 deletions spec/decorators_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
require 'spec_helper'
require_relative 'support/decorate_me.rb'
require "spec_helper"
require_relative "support/decorate_me"

describe Decorators do
before do
Decorators.register! File.expand_path('../support', __FILE__)
Decorators.register! File.expand_path("../support", __FILE__)
Decorators.load! true
end

let(:decorated_class) { DecorateMe.new }
it 'register decorators' do
it "register decorators" do
decorators = [
decorator_path('decorate_me_decorator'),
decorator_path('another_decorator')
decorator_path("decorate_me_decorator"),
decorator_path("another_decorator")
]
bad_decorators = [
decorator_path('../do_not_load_this_decorator')
decorator_path("../do_not_load_this_decorator")
]
decorators.each do |decorator|
expect(Decorators.decorators).to include(decorator)
Expand All @@ -26,12 +26,11 @@
end
end

it 'decorates class with same file name' do
it "decorates class with same file name" do
expect(decorated_class.kiwi).to eq("parndt")
end

it 'decorates class with different file name' do
it "decorates class with different file name" do
expect(decorated_class.am_i_decorated?).to eq(true)
end
end

7 changes: 3 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config.run_all_when_everything_filtered = true
config.filter_run :focus

config.order = 'random'
config.order = "random"
end

def decorator_path(name)
Expand All @@ -13,10 +13,9 @@ def decorator_path(name)
unless Kernel.respond_to?(:require_relative)
module Kernel
def require_relative(path)
require File.join(File.dirname(caller[0]), path.to_str)
require File.join(File.dirname(caller(1..1).first), path.to_str)
end
end
end

require_relative '../lib/decorators'

require_relative "../lib/decorators"