action_prefixer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f32e3fae91d4ab3e5f35bf4923dba88f9b3052cc
4
+ data.tar.gz: de08bfc8b5cc186944d3a191f8d1789b774bb8e9
5
+ SHA512:
6
+ metadata.gz: 43210b79f66a940082b4504fece3d94dd5d69c77437030e008c18227ba11c8236d647dc6c863deab3207e2ef0394416df3e316e1a317ec0ad65cb8efeb4e4c3d
7
+ data.tar.gz: 04265515af49d3c47724e4fbf508862ffece46790c3e4965b5862d1773214383f5c1a08f5fcdaf5ca41010eb01f9e664301bf48bb4288463f99425321af241f4
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ gemfiles/*.lock
17
+ log/
18
+ tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-06-07 16:44:09 +0900 using RuboCop version 0.30.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ # Configuration parameters: AllowURI, URISchemes.
10
+ Metrics/LineLength:
11
+ Max: 95
12
+
13
+ # Offense count: 5
14
+ Style/Documentation:
15
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ gemfile:
5
+ - gemfiles/rails_40.gemfile
6
+ - gemfiles/rails_41.gemfile
7
+ - gemfiles/rails_42.gemfile
8
+ notifications:
9
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in action_prefixer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 sinsoku
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.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ [![Gem Version](https://badge.fury.io/rb/action_prefixer.svg)](http://badge.fury.io/rb/action_prefixer)
2
+ [![Build Status](https://travis-ci.org/sinsoku/action_prefixer.svg?branch=master)](https://travis-ci.org/sinsoku/action_prefixer)
3
+
4
+ # ActionPrefixer
5
+
6
+ It appends a path to searching partial views.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'action_prefixer'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install action_prefixer
23
+
24
+ ## Usage
25
+
26
+ I’ve seen this:
27
+
28
+ ```
29
+ app/views/users/_header.html.erb
30
+ app/views/users/_footer.html.erb
31
+ app/views/users/_blog.html.erb
32
+ app/views/users/_tag.html.erb
33
+ ...(too long)
34
+ ```
35
+
36
+ ActionPrefixer provides a path for partial views.
37
+
38
+ ```
39
+ app/views/users/_header.html.erb
40
+ app/views/users/_footer.html.erb
41
+ app/views/users/index/_blog.html.erb
42
+ app/views/users/show/_tag.html.erb
43
+ ```
44
+
45
+ Also, invoking the partials is simpler than this approach. Instead of:
46
+
47
+ ```erb
48
+ <%= render 'users/index/blog' %>
49
+ ```
50
+
51
+ This is possible:
52
+
53
+ ```erb
54
+ <%= render 'blog' %>
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it ( https://github.com/[my-github-username]/action_prefixer/fork )
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require 'rubocop/rake_task'
7
+ RuboCop::RakeTask.new
8
+
9
+ task default: [:rubocop, :spec]
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'action_prefixer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'action_prefixer'
8
+ spec.version = ActionPrefixer::VERSION
9
+ spec.authors = ['sinsoku']
10
+ spec.email = ['sinsoku.listy@gmail.com']
11
+ spec.summary = "Let's use with partial files"
12
+ spec.description = 'It appends a path to searching partial views'
13
+ spec.homepage = 'https://github.com/sinsoku/action_prefixer'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'rspec-rails'
25
+ spec.add_development_dependency 'capybara'
26
+ spec.add_development_dependency 'rubocop'
27
+ end
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 4.0.0'
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 4.1.0'
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 4.2.0'
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,3 @@
1
+ module ActionPrefixer
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'action_prefixer/version'
2
+
3
+ module ActionPrefixer
4
+ module ActionPrefixes
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ before_action :expand_lookup_paths
9
+ end
10
+
11
+ def expand_lookup_paths
12
+ lookup_context.prefixes = ["#{controller_path}/#{action_name}"] + lookup_context.prefixes
13
+ end
14
+ end
15
+
16
+ class Railtie < ::Rails::Railtie
17
+ initializer 'action_prefixer' do
18
+ ActiveSupport.on_load(:action_controller) do
19
+ ActionController::Base.send :include, ActionPrefixes
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActionPrefixer do
4
+ end
@@ -0,0 +1 @@
1
+ <p>Hello, World</p>
@@ -0,0 +1 @@
1
+ <h1>Users#index</h1>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Title</title>
5
+ </head>
6
+ <body>
7
+ <%= render 'heading' %>
8
+ <%= render 'hello' %>
9
+ </body>
10
+ </html>
@@ -0,0 +1 @@
1
+ <h1>Users#show</h1>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Title</title>
5
+ </head>
6
+ <body>
7
+ <%= render 'heading' %>
8
+ <%= render 'hello' %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,33 @@
1
+ require 'action_controller/railtie'
2
+ require 'action_view/railtie'
3
+
4
+ module FakeApp
5
+ class Application < Rails::Application
6
+ config.secret_token = [*'A'..'z'].join
7
+ config.session_store :cookie_store, key: '_myapp_session'
8
+ config.active_support.deprecation = :log
9
+ config.eager_load = false
10
+ config.root = File.dirname(__FILE__)
11
+ end
12
+ end
13
+ FakeApp::Application.initialize!
14
+
15
+ # routes
16
+ FakeApp::Application.routes.draw do
17
+ resources :users
18
+ end
19
+
20
+ # controllers
21
+ class ApplicationController < ActionController::Base; end
22
+ class UsersController < ApplicationController
23
+ rescue_from Exception do |exception|
24
+ render xml: exception, status: 500
25
+ end
26
+
27
+ def index; end
28
+
29
+ def show; end
30
+ end
31
+
32
+ # helpers
33
+ module ApplicationHelper; end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Users' do
4
+ scenario 'rendering index page' do
5
+ visit '/users'
6
+
7
+ expect(page).to have_content 'Users#index'
8
+ expect(page).to have_content 'Hello, World'
9
+ end
10
+
11
+ scenario 'rendering show page' do
12
+ visit '/users/1'
13
+
14
+ expect(page).to have_content 'Users#show'
15
+ expect(page).to have_content 'Hello, World'
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rails'
3
+ require 'action_prefixer'
4
+ require 'fake_app/app'
5
+ require 'rspec/rails'
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: action_prefixer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sinsoku
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: It appends a path to searching partial views
98
+ email:
99
+ - sinsoku.listy@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - action_prefixer.gemspec
113
+ - gemfiles/rails_40.gemfile
114
+ - gemfiles/rails_41.gemfile
115
+ - gemfiles/rails_42.gemfile
116
+ - lib/action_prefixer.rb
117
+ - lib/action_prefixer/version.rb
118
+ - spec/action_prefixer_spec.rb
119
+ - spec/fake_app/app.rb
120
+ - spec/fake_app/app/views/users/_hello.html.erb
121
+ - spec/fake_app/app/views/users/index.html.erb
122
+ - spec/fake_app/app/views/users/index/_heading.html.erb
123
+ - spec/fake_app/app/views/users/show.html.erb
124
+ - spec/fake_app/app/views/users/show/_heading.html.erb
125
+ - spec/requests/users_spec.rb
126
+ - spec/spec_helper.rb
127
+ homepage: https://github.com/sinsoku/action_prefixer
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.4.5
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Let's use with partial files
151
+ test_files:
152
+ - spec/action_prefixer_spec.rb
153
+ - spec/fake_app/app.rb
154
+ - spec/fake_app/app/views/users/_hello.html.erb
155
+ - spec/fake_app/app/views/users/index.html.erb
156
+ - spec/fake_app/app/views/users/index/_heading.html.erb
157
+ - spec/fake_app/app/views/users/show.html.erb
158
+ - spec/fake_app/app/views/users/show/_heading.html.erb
159
+ - spec/requests/users_spec.rb
160
+ - spec/spec_helper.rb