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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -1
  3. data/bread.gemspec +1 -1
  4. data/lib/bread.rb +15 -10
  5. data/lib/bread/{crumb.rb → data/crumb.rb} +4 -4
  6. data/lib/bread/helper.rb +3 -25
  7. data/lib/bread/manager/actions.rb +37 -0
  8. data/lib/bread/manager/actions/action_scope.rb +32 -0
  9. data/lib/bread/manager/actions/controller_scope.rb +69 -0
  10. data/lib/bread/manager/actions/top_scope.rb +26 -0
  11. data/lib/bread/manager/crumbs.rb +52 -0
  12. data/lib/bread/manager/crumbs/crumb_scope.rb +39 -0
  13. data/lib/bread/manager/crumbs/top_scope.rb +25 -0
  14. data/lib/bread/manager/manager.rb +14 -0
  15. data/lib/bread/version.rb +1 -1
  16. data/test/dummy/app/assets/javascripts/product_photos.js +2 -0
  17. data/test/dummy/app/assets/stylesheets/product_photos.css +4 -0
  18. data/test/dummy/app/controllers/product_photos_controller.rb +67 -0
  19. data/test/dummy/app/controllers/products_controller.rb +12 -23
  20. data/test/dummy/app/helpers/product_photos_helper.rb +2 -0
  21. data/test/dummy/app/lib/bread/actions.rb +18 -0
  22. data/test/dummy/app/lib/bread/actions_next.rb +43 -0
  23. data/test/dummy/app/lib/bread/crumbs.rb +22 -0
  24. data/test/dummy/app/lib/bread/crumbs_next.rb +77 -0
  25. data/test/dummy/app/models/product.rb +8 -0
  26. data/test/dummy/app/models/product_photo.rb +10 -0
  27. data/test/dummy/app/models/user.rb +6 -0
  28. data/test/dummy/app/views/layouts/application.html.erb +10 -5
  29. data/test/dummy/app/views/product_photos/_form.html.erb +29 -0
  30. data/test/dummy/app/views/product_photos/edit.html.erb +6 -0
  31. data/test/dummy/app/views/product_photos/index.html.erb +31 -0
  32. data/test/dummy/app/views/product_photos/new.html.erb +5 -0
  33. data/test/dummy/app/views/product_photos/show.html.erb +19 -0
  34. data/test/dummy/config/initializers/devise.rb +254 -0
  35. data/test/dummy/config/locales/devise.en.yml +59 -0
  36. data/test/dummy/config/routes.rb +4 -1
  37. data/test/dummy/db/migrate/20140306111733_devise_create_users.rb +42 -0
  38. data/test/dummy/db/migrate/20140306114935_create_product_photos.rb +11 -0
  39. data/test/dummy/db/schema.rb +29 -1
  40. data/test/{bread_test.rb → dummy/test/bread_test.rb} +1 -0
  41. data/test/dummy/test/controllers/product_photos_controller_test.rb +98 -0
  42. data/test/dummy/test/controllers/products_controller_test.rb +94 -30
  43. data/test/dummy/test/fixtures/product_photos.yml +11 -0
  44. data/test/dummy/test/fixtures/products.yml +4 -4
  45. data/test/dummy/test/fixtures/users.yml +11 -0
  46. data/test/dummy/test/helpers/product_photos_helper_test.rb +4 -0
  47. data/test/{integration → dummy/test/integration}/navigation_test.rb +0 -0
  48. data/test/dummy/test/models/product_photo_test.rb +7 -0
  49. data/test/dummy/test/models/user_test.rb +7 -0
  50. data/test/dummy/test/support/asserts.rb +17 -0
  51. data/test/test_helper.rb +1 -1
  52. metadata +68 -14
  53. data/lib/bread/commands/config_command.rb +0 -15
  54. data/lib/bread/commands/controller_layout_command.rb +0 -44
  55. data/lib/bread/commands/crumb_to_command.rb +0 -23
  56. data/lib/bread/commands/ivars_command.rb +0 -16
  57. data/lib/bread/config.rb +0 -24
  58. 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
@@ -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