pankuzu 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: fd63fbf1e51078b1fb136c4c795175f3c00fc669
4
+ data.tar.gz: daa95dc8c78eea8e1ab24155955c1e88b2575b0c
5
+ SHA512:
6
+ metadata.gz: 9ae5d4254845fd9420df0cd58e412b6556e0294ec9309104074e3454386a137a4a292e96d470bfdd8f712f7760fc375df5a73948aa030b999815a38be22f978a
7
+ data.tar.gz: d7c0e1c073ce003137f4349ae13b75670c70f014a9f55aa17a6ea6f395850db8be6cce10ffd2d217fb82aa955014871e5979c2e1e4ee162ae5a09f6960693b14
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Masaki Komagata
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Pankuzu
2
+
3
+ Pankuzu generates breadcrumbs html. (*Pankuzu means bread crumbs in Japanese.*)
4
+
5
+ ## Usage
6
+
7
+ Put on `breadcrumbs` helper in your view file.
8
+
9
+ app/views/layouts/application.html.erb:
10
+ ```
11
+ <%= render "breadcrumbs" %>
12
+ ```
13
+
14
+ Add breadcrumb each views.
15
+
16
+ app/views/posts/show.html.erb:
17
+ ```
18
+ <%
19
+ add_breadcrumb "Home", root_path
20
+ add_breadcrumb "Listing Posts", posts_path
21
+ add_breadcrumb "A Post", post_path(@post)
22
+ %>
23
+ ```
24
+
25
+ `breadcrumbs` helper puts html below.
26
+
27
+ ```html
28
+ <ol class="breadcrumbs">
29
+ <li class="breadcrumb"><a href="/">Home</a></li>
30
+ <li class="breadcrumb"><a href="/posts">Listing Posts</a></li>
31
+ <li class="breadcrumb">A Post</li>
32
+ </ol>
33
+ ```
34
+
35
+ ## Installation
36
+
37
+ Add this line to your application's Gemfile:
38
+
39
+ ```ruby
40
+ gem "pankuzu"
41
+ ```
42
+
43
+ And then execute:
44
+ ```bash
45
+ $ rails genarate pankuzu:install
46
+ ```
47
+
48
+ This generator creates `_breadcrumbs.html.erb` in `app/views/application` directory.
49
+
50
+ ## Contributing
51
+ Contribution directions go here.
52
+
53
+ ## License
54
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Pankuzu'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
@@ -0,0 +1,14 @@
1
+ require "rails/generators/base"
2
+
3
+ module Pankuzu
4
+ module Generators
5
+
6
+ class InstallGenerator < Rails::Generators::Base
7
+ source_root File.expand_path("../../templates", __FILE__)
8
+
9
+ def copy_initializer_file
10
+ copy_file "_breadcrumbs.html.erb", "app/views/application/#{file_name}.rb"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ <% if breadcrumbs.present? %>
2
+ <ol class="breadcrumbs">
3
+ <% breadcrumbs.each do |breadcrumb| %>
4
+ <li class="breadcrumb">
5
+ <%= link_to_if breadcrumbs.last != breadcrumb, breadcrumb.name, breadcrumb.url %>
6
+ </li>
7
+ <% end %>
8
+ </ol>
9
+ <% end %>
@@ -0,0 +1,12 @@
1
+ module Pankuzu
2
+ module Helper
3
+ def add_breadcrumb(name, url = nil)
4
+ @_breadcrumbs ||= []
5
+ @_breadcrumbs << OpenStruct.new(name: name, url: url)
6
+ end
7
+
8
+ def breadcrumbs
9
+ @_breadcrumbs
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ require "pankuzu/helper"
2
+
3
+ module Pankuzu
4
+ class Railtie < Rails::Railtie
5
+ initializer "pankuzu.action_controller_helper" do |_|
6
+ ActionView::Base.send :include, Pankuzu::Helper
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Pankuzu
2
+ VERSION = "0.1.0"
3
+ end
data/lib/pankuzu.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "pankuzu/version"
2
+ require "pankuzu/helper"
3
+
4
+ module Pankuzu
5
+ require "pankuzu/railtie" if defined?(Rails)
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :pankuzu do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pankuzu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masaki Komagata
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-12 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
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Generate breadcrumbs simply.
42
+ email:
43
+ - komagata@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/generators/pankuzu/install_generator.rb
52
+ - lib/generators/templates/_breadcrumbs.html.erb
53
+ - lib/pankuzu.rb
54
+ - lib/pankuzu/helper.rb
55
+ - lib/pankuzu/railtie.rb
56
+ - lib/pankuzu/version.rb
57
+ - lib/tasks/pankuzu_tasks.rake
58
+ homepage: https://github.com/komagata/pankuzu
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.13
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Generate breadcrumbs simply.
82
+ test_files: []