Skip to content

Commit

Permalink
Merge branch 'main' into fix
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt authored Jul 25, 2024
2 parents a2833d6 + 1f1d070 commit bff3dcb
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 76 deletions.
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
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

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

gemspec

group :development do
gem "standard", require: false
end
40 changes: 23 additions & 17 deletions certs/parndt.pem
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
-----BEGIN CERTIFICATE-----
MIIDhjCCAm6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBNMQ0wCwYDVQQDDARnZW1z
MIIEhjCCAu6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBNMQ0wCwYDVQQDDARnZW1z
MREwDwYKCZImiZPyLGQBGRYBcDEVMBMGCgmSJomT8ixkARkWBWFybmR0MRIwEAYK
CZImiZPyLGQBGRYCaW8wHhcNMTcwNzI1MTMxMjIwWhcNMTgwNzI1MTMxMjIwWjBN
CZImiZPyLGQBGRYCaW8wHhcNMjQwNzI1MDkzMTM3WhcNMjUwNzI1MDkzMTM3WjBN
MQ0wCwYDVQQDDARnZW1zMREwDwYKCZImiZPyLGQBGRYBcDEVMBMGCgmSJom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XKJavQ8xZ/nwGF
VXf+6/IyX9OrQwL2uw0b+1NiR2gFpOLcOy2ixKdua13S9CWRRsR3VJve+PIyycC7
aLV+FI9i9b1YUXG2gDKqLOkF/FNBWNckAmGj7kYkdLG76G5aRGP0HvfKbIiQ3HTC
jAtsfxiSgc0fAw==
-----END CERTIFICATE-----
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Decorators Changelog
## 2.0.6

* Created branch 'main'
* Updated railties dependency to "railties", ">= 4.0.0", "< 7.2"
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.4}
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", "< 6"
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
9 changes: 5 additions & 4 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 Down Expand Up @@ -35,22 +35,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
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Decorators Plugin [![Build Status](https://secure.travis-ci.org/parndt/decorators.png?branch=master)](http://travis-ci.org/parndt/decorators)
# Decorators Plugin

This is a very simple plugin that adds support for decorators to your Rails application.
Effectively all that this does is allow you to register paths in which to search
Expand Down Expand Up @@ -26,7 +26,7 @@ The important parts are being inside a sub directory of `app/decorators` and hav
In your Gemfile, add the gem:

```ruby
gem 'decorators', '~> 2.0.3'
gem 'decorators', '~> 2.0.6'
```

Now, run `bundle install` and the gem should install.
Expand Down
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"

0 comments on commit bff3dcb

Please sign in to comment.