coadjutor 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f4578ede5671c7b50802f6a15c625cf039cfadfa
4
+ data.tar.gz: baa9f8c26978e1d5c6ce2a394598ccf1901d6c97
5
+ SHA512:
6
+ metadata.gz: e92c1f56189044856db01f5cb39514d711f29dfd8dd100d93a3a478821abe462dbbf745682ea5425f64c070244fc633f7ad28c30c5ffaaab8ad65f2feaf6afbf
7
+ data.tar.gz: 78b10528d0a7f43246607e147ff81ab68b6d8a891c63fa6869b45ca1f6b086943be2414cdd634d803168defda5b689f4ca7f2ece3026feef8d9e064630d54cbc
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jeff Felchner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Coadjutor
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'coadjutor'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install coadjutor
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/coadjutor/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ require "coadjutor/version"
2
+
3
+ module Coadjutor
4
+ require 'coadjutor/railtie' if defined?(Rails)
5
+ end
@@ -0,0 +1,16 @@
1
+ module CssClassHelper
2
+ def body_class
3
+ classes = []
4
+
5
+ classes << controller.qualified_name
6
+ classes << controller.qualified_action_path
7
+ classes << controller.qualified_full_path
8
+ classes << layout_classes
9
+
10
+ classes.join(' ')
11
+ end
12
+
13
+ def layout_class
14
+ "#{controller.qualified_layout_name}_layout"
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module FlashHelper
2
+ def inline_flash_message(type, message)
3
+ ###
4
+ # We have to do it like this instead of with #content_tag because when
5
+ # used with a decorator, #content_tag is an unknown method
6
+ #
7
+ # TODO: If Draper ever fixes this problem, this should be converted to
8
+ # a #content_tag
9
+ #
10
+ return <<-FLASHER.html_safe
11
+ <div class="flash #{type}">
12
+ <p class="flash_message">#{message}</p>
13
+ </div>
14
+ FLASHER
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module JavascriptHelper
2
+ def js_ready(js = nil)
3
+ javascript = '<script type="text/javascript">$(function(){ '.tap do |str|
4
+ (str << js) if js.present?
5
+ str << yield if block_given?
6
+ str << ' });</script>'
7
+ end
8
+
9
+ raw javascript
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module PageTitleHelper
2
+ def page_title(options = {})
3
+ app_name = options[:app_name] || Rails.application.class.to_s.split('::').first
4
+ page_title_symbol = options[:page_title_symbol] || :page_title
5
+ separator = options[:separator] || ' : '
6
+
7
+ if content_for?(page_title_symbol)
8
+ [ app_name, content_for(page_title_symbol) ].join(separator)
9
+ else
10
+ app_name
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ module Coadjutor
2
+ module QualifiedControllerResources
3
+ def qualified_name
4
+ self.controller_path.gsub('/','-')
5
+ end
6
+
7
+ def qualified_action_path
8
+ "#{self.qualified_name}-#{self.action_name}"
9
+ end
10
+
11
+ def qualified_full_path
12
+ self.request.fullpath.underscore.gsub(/[\/=]/, '-').gsub('?', '_')[1..-1]
13
+ end
14
+
15
+ def qualified_layout_name
16
+ self.send(:_layout).gsub('/', '-')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ require 'rails/railtie'
2
+ require 'coadjutor/qualified_controller_resources'
3
+ require 'coadjutor/css_class_helper'
4
+ require 'coadjutor/page_title_helper'
5
+ require 'coadjutor/flash_helper'
6
+ require 'coadjutor/javascript_helper'
7
+ require 'coadjutor/selection_helper'
8
+
9
+ module Coadjutor
10
+ class Railtie < Rails::Railtie
11
+ initializer 'qualified_controller.helper' do |app|
12
+ ActionController::Base.send :include, QualifiedControllerResources
13
+ end
14
+
15
+ initializer 'css_class.helper' do |app|
16
+ ActionView::Base.send :include, CssClassHelper
17
+ end
18
+
19
+ initializer 'page_title.helper' do |app|
20
+ ActionView::Base.send :include, PageTitleHelper
21
+ end
22
+
23
+ initializer 'flash.helper' do |app|
24
+ ActionView::Base.send :include, FlashHelper
25
+ end
26
+
27
+ initializer 'javascript.helper' do |app|
28
+ ActionView::Base.send :include, JavascriptHelper
29
+ end
30
+
31
+ initializer 'selection.helper' do |app|
32
+ ActionView::Base.send :include, SelectionHelper
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module SelectionHelper
2
+ def selected_if_current(path_to_match, current_path = request.fullpath)
3
+ current_path == path_to_match ? 'selected' : ''
4
+ end
5
+
6
+ def selected_if_params_match(params_to_match, options = {:default => {}})
7
+ current_params = request.query_parameters.empty? ? options[:default] : request.query_parameters
8
+
9
+ current_params == params_to_match ? 'selected' : ''
10
+ end
11
+
12
+ def selected_if_url_matches(string_to_match, options = {:default => {}})
13
+ path_with_params = [request.fullpath, request.query_parameters.to_param].select(&:present?).join '?'
14
+ content_to_match = path_with_params == options[:default][:if_path_equals] ? options[:default][:then_match] : path_with_params
15
+
16
+ content_to_match.include?(string_to_match) ? 'selected' : ''
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Coadjutor
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coadjutor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - jfelchner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ description: ''
28
+ email: accounts+git@thekompanee.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files:
32
+ - README.md
33
+ - LICENSE
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/coadjutor.rb
39
+ - lib/coadjutor/css_class_helper.rb
40
+ - lib/coadjutor/flash_helper.rb
41
+ - lib/coadjutor/javascript_helper.rb
42
+ - lib/coadjutor/page_title_helper.rb
43
+ - lib/coadjutor/qualified_controller_resources.rb
44
+ - lib/coadjutor/railtie.rb
45
+ - lib/coadjutor/selection_helper.rb
46
+ - lib/coadjutor/version.rb
47
+ homepage: https://github.com/thekompanee/coadjutor
48
+ licenses: []
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options:
52
+ - "--charset = UTF-8"
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project: coadjutor
67
+ rubygems_version: 2.2.2
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Rails Helpers
71
+ test_files: []