coadjutor 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/coadjutor.rb +1 -1
- data/lib/coadjutor/authentication_helper.rb +4 -1
- data/lib/coadjutor/flash_helper.rb +1 -1
- data/lib/coadjutor/javascript_helper.rb +2 -2
- data/lib/coadjutor/page_title_helper.rb +7 -2
- data/lib/coadjutor/qualified_controller_resources.rb +9 -5
- data/lib/coadjutor/railtie.rb +8 -8
- data/lib/coadjutor/selection_helper.rb +15 -5
- data/lib/coadjutor/verifiable_model.rb +2 -3
- data/lib/coadjutor/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d37d3fc605732c53d3795011ce98edbeebb59b
|
4
|
+
data.tar.gz: f1fecf922bec134a43cb09c5dea4bbc354e3d842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fade50b362148f80e8cd6955f65746e84b6316182d4c954e607a50c84a9dd5fc890c34e46b6da6c60f8e5a8f0adb9916d0ac9f9d200bde5d46227528b380b3e8
|
7
|
+
data.tar.gz: b75254e880b4a6d66ee47591283108a1b89cd730a720afc961fff577e6a62bcbf87a0a4f126a5be3c85c2f7e2c0d48a11821559e9bcbc7ddc8827b4d09317940
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/coadjutor.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module AuthenticationHelper
|
2
|
+
# rubocop:disable Style/GuardClause
|
2
3
|
def authenticate_with_basic_auth
|
3
4
|
if Chamber.env.basic_auth.enabled?
|
4
5
|
authenticate_or_request_with_http_basic do |username, password|
|
5
|
-
username == Chamber.env.basic_auth.username &&
|
6
|
+
username == Chamber.env.basic_auth.username &&
|
7
|
+
password == Chamber.env.basic_auth.password
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
11
|
+
# rubocop:enable Style/GuardClause
|
9
12
|
end
|
@@ -2,8 +2,8 @@ module JavascriptHelper
|
|
2
2
|
def js_ready(js = nil)
|
3
3
|
javascript = '<script type="text/javascript">$(function(){ '.tap do |str|
|
4
4
|
(str << js) if js.present?
|
5
|
-
|
6
|
-
|
5
|
+
str << yield if block_given?
|
6
|
+
str << ' });</script>'
|
7
7
|
end
|
8
8
|
|
9
9
|
raw javascript
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module PageTitleHelper
|
2
2
|
def page_title(options = {})
|
3
|
-
app_name = options[:app_name] || Rails.
|
3
|
+
app_name = options[:app_name] || Rails.
|
4
|
+
application.
|
5
|
+
class.
|
6
|
+
to_s.
|
7
|
+
split('::').
|
8
|
+
first
|
4
9
|
page_title_symbol = options[:page_title_symbol] || :page_title
|
5
10
|
separator = options[:separator] || ' : '
|
6
11
|
|
7
12
|
if content_for?(page_title_symbol)
|
8
|
-
[
|
13
|
+
[app_name, content_for(page_title_symbol)].join(separator)
|
9
14
|
else
|
10
15
|
app_name
|
11
16
|
end
|
@@ -1,20 +1,24 @@
|
|
1
1
|
module Coadjutor
|
2
2
|
module QualifiedControllerResources
|
3
3
|
def qualified_name
|
4
|
-
|
4
|
+
controller_path.gsub('/', '-')
|
5
5
|
end
|
6
6
|
|
7
7
|
def qualified_action_path
|
8
|
-
"#{
|
8
|
+
"#{qualified_name}-#{action_name}"
|
9
9
|
end
|
10
10
|
|
11
11
|
def qualified_full_path
|
12
|
-
|
12
|
+
request.fullpath.underscore.gsub(%r{[/=]}, '-').gsub('?', '_')[1..-1]
|
13
13
|
end
|
14
14
|
|
15
15
|
def qualified_layout_basename
|
16
|
-
identifier =
|
17
|
-
layout_path = defined?(Rails.root)
|
16
|
+
identifier = send(:_layout).identifier
|
17
|
+
layout_path = if defined?(Rails.root)
|
18
|
+
identifier.sub("#{Rails.root}/", '')
|
19
|
+
else
|
20
|
+
identifier
|
21
|
+
end
|
18
22
|
layout_filename = layout_path.sub('app/views/layouts/', '')
|
19
23
|
|
20
24
|
layout_filename[/([^\.]+)/, 1]
|
data/lib/coadjutor/railtie.rb
CHANGED
@@ -10,35 +10,35 @@ require 'coadjutor/selection_helper'
|
|
10
10
|
|
11
11
|
module Coadjutor
|
12
12
|
class Railtie < Rails::Railtie
|
13
|
-
initializer 'qualified_controller.helper' do |
|
13
|
+
initializer 'qualified_controller.helper' do |_app|
|
14
14
|
ActionController::Base.send :include, QualifiedControllerResources
|
15
15
|
end
|
16
16
|
|
17
|
-
initializer 'authentication.helper' do |
|
17
|
+
initializer 'authentication.helper' do |_app|
|
18
18
|
ActionController::Base.send :include, AuthenticationHelper
|
19
19
|
end
|
20
20
|
|
21
|
-
initializer 'verifiable_model.helper' do |
|
21
|
+
initializer 'verifiable_model.helper' do |_app|
|
22
22
|
ActionController::Base.send :include, VerifiableModel
|
23
23
|
end
|
24
24
|
|
25
|
-
initializer 'css_class.helper' do |
|
25
|
+
initializer 'css_class.helper' do |_app|
|
26
26
|
ActionView::Base.send :include, CssClassHelper
|
27
27
|
end
|
28
28
|
|
29
|
-
initializer 'page_title.helper' do |
|
29
|
+
initializer 'page_title.helper' do |_app|
|
30
30
|
ActionView::Base.send :include, PageTitleHelper
|
31
31
|
end
|
32
32
|
|
33
|
-
initializer 'flash.helper' do |
|
33
|
+
initializer 'flash.helper' do |_app|
|
34
34
|
ActionView::Base.send :include, FlashHelper
|
35
35
|
end
|
36
36
|
|
37
|
-
initializer 'javascript.helper' do |
|
37
|
+
initializer 'javascript.helper' do |_app|
|
38
38
|
ActionView::Base.send :include, JavascriptHelper
|
39
39
|
end
|
40
40
|
|
41
|
-
initializer 'selection.helper' do |
|
41
|
+
initializer 'selection.helper' do |_app|
|
42
42
|
ActionView::Base.send :include, SelectionHelper
|
43
43
|
end
|
44
44
|
end
|
@@ -3,15 +3,25 @@ module SelectionHelper
|
|
3
3
|
current_path == path_to_match ? 'selected' : ''
|
4
4
|
end
|
5
5
|
|
6
|
-
def selected_if_params_match(params_to_match, options = {:
|
7
|
-
current_params = request.query_parameters.empty?
|
6
|
+
def selected_if_params_match(params_to_match, options = { default: {} })
|
7
|
+
current_params = if request.query_parameters.empty?
|
8
|
+
options[:default]
|
9
|
+
else
|
10
|
+
request.query_parameters
|
11
|
+
end
|
8
12
|
|
9
13
|
current_params == params_to_match ? 'selected' : ''
|
10
14
|
end
|
11
15
|
|
12
|
-
def selected_if_url_matches(string_to_match, options = {:
|
13
|
-
path_with_params = [request.fullpath, request.query_parameters.to_param].
|
14
|
-
|
16
|
+
def selected_if_url_matches(string_to_match, options = { default: {} })
|
17
|
+
path_with_params = [request.fullpath, request.query_parameters.to_param].
|
18
|
+
select(&:present?).
|
19
|
+
join '?'
|
20
|
+
content_to_match = if path_with_params == options[:default][:if_path_equals]
|
21
|
+
options[:default][:then_match]
|
22
|
+
else
|
23
|
+
path_with_params
|
24
|
+
end
|
15
25
|
|
16
26
|
content_to_match.include?(string_to_match) ? 'selected' : ''
|
17
27
|
end
|
@@ -4,15 +4,14 @@ module VerifiableModel
|
|
4
4
|
module ClassMethods
|
5
5
|
def verify_model_exists(model = nil, options = {})
|
6
6
|
exceptions = options[:except] || %i{create index}
|
7
|
-
model
|
8
|
-
name[/::(\w+)Controller\z/, 1].
|
7
|
+
model ||= name[/::(\w+)Controller\z/, 1].
|
9
8
|
singularize.
|
10
9
|
downcase
|
11
10
|
|
12
11
|
before_action except: exceptions do
|
13
12
|
model_instance = public_send(model)
|
14
13
|
|
15
|
-
|
14
|
+
fail HumanError::Errors::ResourceNotFoundError.new(
|
16
15
|
resource_name: model,
|
17
16
|
resource_id: params[:id],
|
18
17
|
) unless model_instance.persisted?
|
data/lib/coadjutor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coadjutor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
41
55
|
description: ''
|
42
56
|
email: accounts+git@thekompanee.com
|
43
57
|
executables: []
|
@@ -80,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
94
|
version: '0'
|
81
95
|
requirements: []
|
82
96
|
rubyforge_project: coadjutor
|
83
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.6
|
84
98
|
signing_key:
|
85
99
|
specification_version: 4
|
86
100
|
summary: Rails Helpers
|