kaseifu 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e80dcf95f3c552e1b7aed91a7ce0e04a58ba5103
4
+ data.tar.gz: 526809cd70adfcfba0d77f90f10d19411ddb3142
5
+ SHA512:
6
+ metadata.gz: f84a80c5a07f5a1df99f800139c4c5aa0f9fd40c18d0be1a71b35e6e4aaecbe89b8b05332d9fac91283c215af815041728f7007629b45292f6f9774b504c47c4
7
+ data.tar.gz: c6496656ae90e67012f7adff356eb7f3568223795d66011149e68e69db35e8e21990fc82b67391d598d825e16ce7890532a535281c16b55fc3fac8d777bfc6ac
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/AbcSize:
4
+ Max: 16
5
+
6
+ Metrics/LineLength:
7
+ Max: 140
8
+
9
+ Style/ClassAndModuleChildren:
10
+ Enabled: false
11
+
12
+ Style/Documentation:
13
+ Enabled: false
@@ -0,0 +1,6 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-05-07 16:26:24 +0900 using RuboCop version 0.31.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.
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kaseifu.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Takeshi Takizawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Kaseifu [<img src="https://travis-ci.org/TakiTake/kaseifu.svg"/>](http://travis-ci.org/TakiTake/kaseifu) [<img src="https://img.shields.io/codeclimate/github/TakiTake/kaseifu.svg" />](https://codeclimate.com/github/TakiTake/kaseifu)
2
+
3
+ Add useful helper methods to your Rails APP.
4
+
5
+ kaseifu works on ruby 2.1 or higher.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kaseifu'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kaseifu
22
+
23
+ ## Usage
24
+
25
+ ### render\_if\_present
26
+
27
+ Render partial if the given method is present as the receiver's method.
28
+
29
+ For example, something like
30
+
31
+ ```erb
32
+ <%= render_if_present :shop_image_path, in: @shop %>
33
+ ```
34
+
35
+ same as
36
+
37
+ ```erb
38
+ <% if @shop.shop_image_path.present? %>
39
+ <%= render 'shop_image_path', locals: { shop_image_path: @shop.shop_image_path } %>
40
+ <% end %>
41
+ ```
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/[my-github-username]/kaseifu/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
@@ -0,0 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'kaseifu'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kaseifu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kaseifu'
8
+ spec.version = Kaseifu::VERSION
9
+ spec.authors = ['Takeshi Takizawa']
10
+ spec.email = ['takitake.create@gmail.com']
11
+
12
+ spec.summary = 'Additional helper methods of ActionView.'
13
+ spec.description = 'This gem provide some useful helper methods for Application which use ActionView.'
14
+ spec.homepage = 'https://github.com/TakiTake/kaseifu'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'activesupport', '~> 3.0'
23
+ spec.add_dependency 'actionpack', '~> 3.0'
24
+ spec.add_dependency 'railties', '~> 3.0'
25
+
26
+ spec.add_development_dependency 'bundler', '>= 1.6.9'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'rails', '~> 3.0'
30
+ spec.add_development_dependency 'rspec-rails'
31
+ end
@@ -0,0 +1,4 @@
1
+ require 'active_support'
2
+ require 'kaseifu/version'
3
+ require 'kaseifu/railtie'
4
+ require 'kaseifu/action_view/helpers'
@@ -0,0 +1,11 @@
1
+ module Kaseifu
2
+ module ActionView
3
+ module Helpers
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :RenderingHelper
7
+
8
+ include RenderingHelper
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ module Kaseifu::ActionView::Helpers
2
+ module RenderingHelper
3
+ # Render partial if the given method is present as the receiver's method.
4
+ #
5
+ # For example, something like
6
+ # <%= render_if_present :shop_image_path, in: @shop %>
7
+ # same as
8
+ # <% if @shop.shop_image_path.present? %>
9
+ # <%= render 'shop_image_path', locals: { shop_image_path: @shop.shop_image_path } %>
10
+ # <% end %>
11
+ #
12
+ # You can pass different path of partial
13
+ # <%= render_if_present :shop_image_path, in: @shop, partial: 'image' %>
14
+ # same as
15
+ # <% if @shop.shop_image_path.present? %>
16
+ # <%= render 'image', locals: { shop_image_path: @shop.shop_image_path } %>
17
+ # <% end %>
18
+ #
19
+ # You can use different name as a local variable name in the partial
20
+ # <%= render_if_present :shop_image_path, in: @shop, as: :shop_image %>
21
+ # same as
22
+ # <% if @shop.shop_image_path.present? %>
23
+ # <%= render 'shop_image', locals: { shop_image: @shop.shop_image_path } %>
24
+ # <% end %>
25
+ #
26
+ # You can pass more locals
27
+ # <%= render_if_present :shop_image_path, in: @shop, locals: { shop_name: @shop.name } %>
28
+ # same as
29
+ # <% if @shop.shop_image_path.present? %>
30
+ # <%= render 'shop_image_path', locals: { shop_image_path: @shop.shop_image_path, shop_name: @shop.name } %>
31
+ # <% end %>
32
+ def render_if_present(method, in: nil, as: nil, **options)
33
+ # "in" is special keyword so need to use local_variable_get to get value
34
+ receiver = binding.local_variable_get(:in)
35
+
36
+ fail ArgumentError, 'missing keyword: in' if receiver.nil?
37
+
38
+ # If receiver doesn't respond to the given method, render nothing
39
+ return '' unless receiver.respond_to?(method)
40
+
41
+ key = (as || method).to_sym
42
+ value = receiver.send(method)
43
+
44
+ # If given method return blank, render nothing
45
+ return '' if value.blank?
46
+
47
+ # If partial file name is already exist use it else use key.
48
+ options[:partial] ||= key.to_s
49
+
50
+ options[:locals] ||= {}
51
+ options[:locals].merge!(key => value)
52
+
53
+ render options
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,11 @@
1
+ require 'rails/railtie'
2
+
3
+ module Kaseifu
4
+ class Railtie < ::Rails::Railtie
5
+ initializer 'kaseifu.include_helpers' do
6
+ ActiveSupport.on_load :action_view do
7
+ include Kaseifu::ActionView::Helpers
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Kaseifu
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kaseifu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takeshi Takizawa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionpack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.9
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.6.9
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: This gem provide some useful helper methods for Application which use
126
+ ActionView.
127
+ email:
128
+ - takitake.create@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".rubocop.yml"
136
+ - ".rubocop_todo.yml"
137
+ - ".travis.yml"
138
+ - CODE_OF_CONDUCT.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - kaseifu.gemspec
146
+ - lib/kaseifu.rb
147
+ - lib/kaseifu/action_view/helpers.rb
148
+ - lib/kaseifu/action_view/helpers/rendering_helper.rb
149
+ - lib/kaseifu/railtie.rb
150
+ - lib/kaseifu/version.rb
151
+ homepage: https://github.com/TakiTake/kaseifu
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.4.6
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Additional helper methods of ActionView.
175
+ test_files: []
176
+ has_rdoc: