bread 0.0.1

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: 3e2ab2d4f0ca43e9f40ecc6f58cd1fb48af9fa0d
4
+ data.tar.gz: 4d1df4935dd79a5f8697ecd671f8c32da515f704
5
+ SHA512:
6
+ metadata.gz: cb77b92f6e7aebccd09455921cb53b85d3eaf7522bd688f1959c80771f76d1cc97b156ed82427a097c1a165c1642d1fff9dacf4b0e4f0dd7dd66cdc427679845
7
+ data.tar.gz: 31531bc8fad7c72983313a950d06889c17501b75c75918530c22a02e1a5f6c1f19f1c041fde6762284df86daddc9ff6c0325bfbf46b8d04e5c910a36a6f06156
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bread.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Thiago Pinto
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,29 @@
1
+ # Bread
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bread'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bread
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
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
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bread.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bread/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bread"
8
+ spec.version = Bread::VERSION
9
+ spec.authors = ["Thiago Pinto"]
10
+ spec.email = ["tapgyn@gmail.com"]
11
+ spec.description = %q{Simple and organized Breadcrumbs for Rails 3 and 4}
12
+ spec.summary = %q{Set up all your breadcrumbs with on a dependency-based simple block of code}
13
+ spec.homepage = "https://github.com/yakko/bread"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ # spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "colorize"
24
+ end
data/lib/bread.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "bread/version"
2
+ require "bread/command"
3
+ require "bread/controller"
4
+ require "bread/helper"
5
+
6
+
7
+ module Bread
8
+ end
@@ -0,0 +1,16 @@
1
+ module Bread
2
+ class Command
3
+
4
+ def initialize(controller)
5
+ @controller = controller
6
+ @controller._bread_trees = {}
7
+ end
8
+
9
+ def action(action_name, &block)
10
+ parent_name = nil
11
+ action_name, parent_name = action_name.first if action_name.is_a? Hash
12
+ @controller._bread_trees[action_name] = {block: block, parent: @controller._bread_trees[parent_name]}
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ module Bread
2
+ module Controller
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ attr_reader :bread_block
7
+ def bread(&block)
8
+ @bread_block = block
9
+ before_filter :execute_bread_command
10
+ end
11
+ end
12
+
13
+ def _bread_trees
14
+ @_bread_trees ||= {}
15
+ end
16
+
17
+ def execute_bread_command
18
+ Command.new(self).instance_eval(&self.class.bread_block)
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ if defined? ActionController::Base
25
+ ActionController::Base.class_eval do
26
+ include Bread::Controller
27
+ end
28
+ end
@@ -0,0 +1,36 @@
1
+ module Bread
2
+ module Helper
3
+
4
+ def bread
5
+ return @bread if @bread
6
+
7
+ tmp = nil
8
+ controller._bread_trees.each do |i_action, hash|
9
+ if i_action.to_s == action_name
10
+ tmp = hash
11
+ break
12
+ end
13
+ end
14
+
15
+ @bread = if tmp.nil?
16
+ puts "No Bread for this Action. Please check https://github.com/yakko/bread for more info".light_yellow
17
+ []
18
+ else
19
+ list = []
20
+ while tmp
21
+ arr = controller.instance_eval(&tmp[:block])
22
+ list << {title: arr.first, path: arr.second}
23
+ tmp = tmp[:parent]
24
+ end
25
+ list.reverse
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+ if defined? ActionView::Base
33
+ ActionView::Base.class_eval do
34
+ include Bread::Helper
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Bread
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bread
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thiago Pinto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-08 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
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: Simple and organized Breadcrumbs for Rails 3 and 4
42
+ email:
43
+ - tapgyn@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bread.gemspec
54
+ - lib/bread.rb
55
+ - lib/bread/command.rb
56
+ - lib/bread/controller.rb
57
+ - lib/bread/helper.rb
58
+ - lib/bread/version.rb
59
+ homepage: https://github.com/yakko/bread
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Set up all your breadcrumbs with on a dependency-based simple block of code
83
+ test_files: []