bread 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/Gemfile +4 -1
- data/bread.gemspec +1 -1
- data/lib/bread.rb +15 -10
- data/lib/bread/{crumb.rb → data/crumb.rb} +4 -4
- data/lib/bread/helper.rb +3 -25
- data/lib/bread/manager/actions.rb +37 -0
- data/lib/bread/manager/actions/action_scope.rb +32 -0
- data/lib/bread/manager/actions/controller_scope.rb +69 -0
- data/lib/bread/manager/actions/top_scope.rb +26 -0
- data/lib/bread/manager/crumbs.rb +52 -0
- data/lib/bread/manager/crumbs/crumb_scope.rb +39 -0
- data/lib/bread/manager/crumbs/top_scope.rb +25 -0
- data/lib/bread/manager/manager.rb +14 -0
- data/lib/bread/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/product_photos.js +2 -0
- data/test/dummy/app/assets/stylesheets/product_photos.css +4 -0
- data/test/dummy/app/controllers/product_photos_controller.rb +67 -0
- data/test/dummy/app/controllers/products_controller.rb +12 -23
- data/test/dummy/app/helpers/product_photos_helper.rb +2 -0
- data/test/dummy/app/lib/bread/actions.rb +18 -0
- data/test/dummy/app/lib/bread/actions_next.rb +43 -0
- data/test/dummy/app/lib/bread/crumbs.rb +22 -0
- data/test/dummy/app/lib/bread/crumbs_next.rb +77 -0
- data/test/dummy/app/models/product.rb +8 -0
- data/test/dummy/app/models/product_photo.rb +10 -0
- data/test/dummy/app/models/user.rb +6 -0
- data/test/dummy/app/views/layouts/application.html.erb +10 -5
- data/test/dummy/app/views/product_photos/_form.html.erb +29 -0
- data/test/dummy/app/views/product_photos/edit.html.erb +6 -0
- data/test/dummy/app/views/product_photos/index.html.erb +31 -0
- data/test/dummy/app/views/product_photos/new.html.erb +5 -0
- data/test/dummy/app/views/product_photos/show.html.erb +19 -0
- data/test/dummy/config/initializers/devise.rb +254 -0
- data/test/dummy/config/locales/devise.en.yml +59 -0
- data/test/dummy/config/routes.rb +4 -1
- data/test/dummy/db/migrate/20140306111733_devise_create_users.rb +42 -0
- data/test/dummy/db/migrate/20140306114935_create_product_photos.rb +11 -0
- data/test/dummy/db/schema.rb +29 -1
- data/test/{bread_test.rb → dummy/test/bread_test.rb} +1 -0
- data/test/dummy/test/controllers/product_photos_controller_test.rb +98 -0
- data/test/dummy/test/controllers/products_controller_test.rb +94 -30
- data/test/dummy/test/fixtures/product_photos.yml +11 -0
- data/test/dummy/test/fixtures/products.yml +4 -4
- data/test/dummy/test/fixtures/users.yml +11 -0
- data/test/dummy/test/helpers/product_photos_helper_test.rb +4 -0
- data/test/{integration → dummy/test/integration}/navigation_test.rb +0 -0
- data/test/dummy/test/models/product_photo_test.rb +7 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/dummy/test/support/asserts.rb +17 -0
- data/test/test_helper.rb +1 -1
- metadata +68 -14
- data/lib/bread/commands/config_command.rb +0 -15
- data/lib/bread/commands/controller_layout_command.rb +0 -44
- data/lib/bread/commands/crumb_to_command.rb +0 -23
- data/lib/bread/commands/ivars_command.rb +0 -16
- data/lib/bread/config.rb +0 -24
- data/lib/bread/controller.rb +0 -30
@@ -1,44 +0,0 @@
|
|
1
|
-
module Bread
|
2
|
-
class ControllerLayoutCommand
|
3
|
-
|
4
|
-
attr_reader :keys
|
5
|
-
|
6
|
-
def initialize(controller)
|
7
|
-
IvarsCommand.new(controller).ivars.each do |key, ivar|
|
8
|
-
self.instance_variable_set(key, ivar)
|
9
|
-
end
|
10
|
-
|
11
|
-
@controller = controller
|
12
|
-
@actions = {}
|
13
|
-
@keys = []
|
14
|
-
end
|
15
|
-
|
16
|
-
def actions(*action_names, &block)
|
17
|
-
action_names.each do |action_name|
|
18
|
-
@actions[action_name] = block
|
19
|
-
is_current_action = action_name.to_s == @controller.action_name
|
20
|
-
|
21
|
-
if is_current_action
|
22
|
-
self.instance_eval(&block)
|
23
|
-
# teria que ter um break aqui, que tambem pare todos os registros de proximas actions =D
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def crumbs(*keys)
|
29
|
-
parent = nil
|
30
|
-
if keys.last.is_a? Hash
|
31
|
-
options = keys.last
|
32
|
-
keys.delete(options)
|
33
|
-
#raise "Unexpected options: #{}"
|
34
|
-
parent = options[:parent]
|
35
|
-
end
|
36
|
-
@keys = keys + @keys
|
37
|
-
if parent
|
38
|
-
blk = @actions[parent]
|
39
|
-
instance_eval(&blk)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Bread
|
2
|
-
class CrumbToCommand
|
3
|
-
|
4
|
-
include ActionDispatch::Routing::UrlFor
|
5
|
-
|
6
|
-
attr_reader :crumb
|
7
|
-
|
8
|
-
def initialize(controller, key, &block)
|
9
|
-
@key = key
|
10
|
-
|
11
|
-
IvarsCommand.new(controller).ivars.each do |key, ivar|
|
12
|
-
instance_variable_set(key, ivar)
|
13
|
-
end
|
14
|
-
|
15
|
-
instance_eval(&block)
|
16
|
-
end
|
17
|
-
|
18
|
-
def crumb_to(title, path, options={})
|
19
|
-
@crumb = Crumb.new(options)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Bread
|
2
|
-
class IvarsCommand
|
3
|
-
|
4
|
-
attr_reader :ivars
|
5
|
-
|
6
|
-
def initialize(target)
|
7
|
-
@ivars = {}
|
8
|
-
|
9
|
-
ivars_keys = target.instance_variables.select { |key| not key.to_s.starts_with?('@_') }
|
10
|
-
ivars_keys.each do |key|
|
11
|
-
@ivars[key] = target.instance_variable_get(key)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
data/lib/bread/config.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Bread
|
2
|
-
class Config
|
3
|
-
include Singleton
|
4
|
-
|
5
|
-
attr_reader :crumb_definitions
|
6
|
-
|
7
|
-
def reload!
|
8
|
-
config_file = Rails.root.join "config/breadcrumbs.rb"
|
9
|
-
if File.exists? config_file
|
10
|
-
load config_file
|
11
|
-
else
|
12
|
-
`rails g bread:install`
|
13
|
-
self.reload!
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def config(&block)
|
18
|
-
cmd = ConfigCommand.new
|
19
|
-
cmd.instance_eval(&block)
|
20
|
-
@crumb_definitions = cmd.crumb_definitions
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
data/lib/bread/controller.rb
DELETED
@@ -1,30 +0,0 @@
|
|
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
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def bread_keys
|
13
|
-
block = self.class.bread_block
|
14
|
-
if block.nil?
|
15
|
-
puts "breadcrumbs: HEY! write some breadcrumbs for #{controller_name}##{action_name}".black.on_light_yellow
|
16
|
-
return []
|
17
|
-
end
|
18
|
-
cmd = ControllerLayoutCommand.new(self)
|
19
|
-
cmd.instance_eval(&block)
|
20
|
-
cmd.keys
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
if defined? ActionController::Base
|
27
|
-
ActionController::Base.class_eval do
|
28
|
-
include Bread::Controller
|
29
|
-
end
|
30
|
-
end
|