backstack 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/art/backlinks.gif ADDED
Binary file
Binary file
data/art/complete.gif ADDED
Binary file
data/art/idealized.gif ADDED
Binary file
data/backstack.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{backstack}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kevin Swope"]
12
- s.date = %q{2011-07-09}
12
+ s.date = %q{2011-07-10}
13
13
  s.description = %q{Rails plugin used to dynamically and intelligently generate "back" links or a breadcrumb trail.}
14
14
  s.email = %q{git-kevdev@snkmail.com}
15
15
  s.extra_rdoc_files = [
@@ -24,7 +24,18 @@ Gem::Specification.new do |s|
24
24
  "README.rdoc",
25
25
  "Rakefile",
26
26
  "VERSION",
27
+ "art/animation/1.gif",
28
+ "art/animation/2.gif",
29
+ "art/animation/3.gif",
30
+ "art/animation/4.gif",
31
+ "art/animation/5.gif",
32
+ "art/animation/6.gif",
33
+ "art/animation/anim.gif",
34
+ "art/backlinks.gif",
35
+ "art/bowling_pins (Autosaved).graffle",
27
36
  "art/bowling_pins.graffle",
37
+ "art/complete.gif",
38
+ "art/idealized.gif",
28
39
  "backstack.gemspec",
29
40
  "lib/backstack.rb",
30
41
  "lib/backstacklib.rb",
data/lib/backstack.rb CHANGED
@@ -42,15 +42,15 @@ module BackStack
42
42
  # both keys and values.
43
43
  normalizer = lambda {|x| bs_action_normal(controller_name, x) }
44
44
 
45
- # Add new edges to existing graph, and extract out the names.
46
- # bs_add_edges will also accumulate names for us.
47
- @bs_graph, @bs_names = bs_add_edges(@bs_graph, @bs_names,
45
+ # Add new edges to existing graph, and extract out the labels.
46
+ # bs_add_edges will also accumulate labels for us.
47
+ @bs_graph, @bs_labels = bs_add_edges(@bs_graph, @bs_labels,
48
48
  edges, normalizer)
49
49
 
50
50
  end
51
51
 
52
52
  # So ApplicationController methods can reach @bs_graph and
53
- # @bs_names. I wanted to use @@bs_graph, so both AC::B and the
53
+ # @bs_labels. I wanted to use @@bs_graph, so both AC::B and the
54
54
  # instance of AC could reach it, but this mysteriously breaks
55
55
  # rails routing! So here are getters than we can use and access
56
56
  # from the AC instance as self.class.get_bs_graph. RoR can be a
@@ -59,8 +59,8 @@ module BackStack
59
59
  @bs_graph
60
60
  end
61
61
 
62
- def get_bs_names
63
- @bs_names
62
+ def get_bs_labels
63
+ @bs_labels
64
64
  end
65
65
 
66
66
  send :include, InstanceMethods
@@ -94,7 +94,7 @@ module BackStack
94
94
 
95
95
  hashify = lambda{|x|
96
96
  c, a = x[0].split /#/
97
- {:controller => c, :action => a, :fullpath => x[1], :name => x[2]}
97
+ {:controller => c, :action => a, :fullpath => x[1], :label => x[2]}
98
98
  }
99
99
 
100
100
  if block_given?
@@ -133,7 +133,7 @@ class ActionController::Base
133
133
  puts "=== backstack_dump() " + '=' * 50
134
134
 
135
135
  puts "backstack graph: #{self.class.get_bs_graph}"
136
- puts "backstack names: #{self.class.get_bs_names}"
136
+ puts "backstack labels: #{self.class.get_bs_labels}"
137
137
  puts "backstack stack: #{session[:bs_stack]}"
138
138
 
139
139
  puts '=' * 71
@@ -150,7 +150,7 @@ class ActionController::Base
150
150
  session[:bs_stack],
151
151
  action,
152
152
  request.fullpath,
153
- self.class.get_bs_names[action])
153
+ self.class.get_bs_labels[action])
154
154
 
155
155
  end
156
156
 
data/lib/backstacklib.rb CHANGED
@@ -30,35 +30,35 @@ module BackStackLib
30
30
  # Note: the shorthand form of the edges parameter can be taken as far as
31
31
  # something like this {[:d, :e, :f] => [:b, :c]}
32
32
  #
33
- # New feature: named nodes. Instead of {:c => :a}, the "key" can be
34
- # named like this {{:c => "Charlie"} => :a}. We're going to remove
35
- # those named keys, replace them with just the key, and return them as
33
+ # New feature: labeled nodes. Instead of {:c => :a}, the "key" can be
34
+ # labeled like this {{:c => "Charlie"} => :a}. We're going to remove
35
+ # those labeled keys, replace them with just the key, and return them as
36
36
  # the second value
37
37
  #
38
38
  # Decided to allow user to pass a normalizer proc/lambda in to
39
39
  # modify all the keys and values.
40
- def bs_add_edges(graph, names, edges, normalizer=nil)
40
+ def bs_add_edges(graph, labels, edges, normalizer=nil)
41
41
 
42
42
  graph ||= {}
43
- names ||= {}
43
+ labels ||= {}
44
44
 
45
45
  edges.each do |k,v| # k is a scalar or array, same with v
46
46
 
47
47
  # Does this [x].flatten idiom make it less readable?
48
48
  [k].flatten.each do |x|
49
49
 
50
- # Extract names out into their own hash, and normalize key
51
- if x.class == Hash # if its a hash it contains a name
52
- names[x.first[0]] = x.first[1]
53
- x = x.first[0] # remove name and replace with normal key
50
+ # Extract labels out into their own hash, and normalize key
51
+ if x.class == Hash # if its a hash it contains a label
52
+ labels[x.first[0]] = x.first[1]
53
+ x = x.first[0] # remove label and replace with normal key
54
54
  end
55
55
 
56
56
  # Run normalizer on all keys and values of new edges
57
57
  if normalizer
58
58
  x = normalizer.call(x)
59
59
  v = [v].flatten.map{|y| normalizer.call(y)}
60
- # also run normalizer on names keys
61
- names = Hash[names.map {|k,v| [normalizer.call(k), v]}]
60
+ # also run normalizer on labels keys
61
+ labels = Hash[labels.map {|k,v| [normalizer.call(k), v]}]
62
62
  end
63
63
 
64
64
  # If merge finds dupe keys it will use block to determine
@@ -71,20 +71,20 @@ module BackStackLib
71
71
 
72
72
  end
73
73
 
74
- [graph, names]
74
+ [graph, labels]
75
75
 
76
76
  end
77
77
 
78
78
  # Judging by graph, push onto stack if appropriate. Pushing doesn't
79
79
  # necessarily build stack up, it might cause a rewind and actually
80
80
  # shrink stack.
81
- def bs_push(graph, stack, action, fullpath, name=nil)
81
+ def bs_push(graph, stack, action, fullpath, label=nil)
82
82
 
83
83
  # bs_push might be called before there is a graph or stack
84
84
  graph ||= {}
85
85
  stack ||= []
86
86
 
87
- element = [action, fullpath, name]
87
+ element = [action, fullpath, label]
88
88
 
89
89
  # if action closes to what's on top of stack, build stack up
90
90
  if graph[action] && stack.last && graph[action].include?(stack.last.first)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- backstack (0.0.0)
4
+ backstack (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -18,9 +18,9 @@
18
18
  <p class="trail" id="link_trail">
19
19
  <% backstack_trail do |c| %>
20
20
  <% if c[:fullpath] == request.fullpath %>
21
- <%= c[:name] %> /
21
+ <%= c[:label] %> /
22
22
  <% else %>
23
- <%= smart_link_to(c[:name], c[:fullpath]) %> /
23
+ <%= smart_link_to(c[:label], c[:fullpath]) %> /
24
24
  <% end %>
25
25
  <% end %>
26
26
  </p>
@@ -29,9 +29,9 @@
29
29
  <%# trail demonstrating calling without block returns array, no links this time %>
30
30
  <p class="trail" id="no_link_trail">
31
31
 
32
- <% links = [] %>
33
- <% backstack_trail.each {|c| links.push c[:name] } %>
34
- <%= links.join(" / ").html_safe %>
32
+ <% crumbs = [] %>
33
+ <% backstack_trail.each {|c| crumbs.push c[:label] } %>
34
+ <%= crumbs.join(" / ").html_safe %>
35
35
 
36
36
  </p>
37
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-09 00:00:00.000000000 -04:00
12
+ date: 2011-07-10 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
17
- requirement: &2153556140 !ruby/object:Gem::Requirement
17
+ requirement: &2152716200 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2153556140
25
+ version_requirements: *2152716200
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &2153555660 !ruby/object:Gem::Requirement
28
+ requirement: &2152715720 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2153555660
36
+ version_requirements: *2152715720
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: jeweler
39
- requirement: &2153555180 !ruby/object:Gem::Requirement
39
+ requirement: &2152715240 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2153555180
47
+ version_requirements: *2152715240
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rcov
50
- requirement: &2153571060 !ruby/object:Gem::Requirement
50
+ requirement: &2152714760 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2153571060
58
+ version_requirements: *2152714760
59
59
  description: Rails plugin used to dynamically and intelligently generate "back" links
60
60
  or a breadcrumb trail.
61
61
  email: git-kevdev@snkmail.com
@@ -72,7 +72,18 @@ files:
72
72
  - README.rdoc
73
73
  - Rakefile
74
74
  - VERSION
75
+ - art/animation/1.gif
76
+ - art/animation/2.gif
77
+ - art/animation/3.gif
78
+ - art/animation/4.gif
79
+ - art/animation/5.gif
80
+ - art/animation/6.gif
81
+ - art/animation/anim.gif
82
+ - art/backlinks.gif
83
+ - art/bowling_pins (Autosaved).graffle
75
84
  - art/bowling_pins.graffle
85
+ - art/complete.gif
86
+ - art/idealized.gif
76
87
  - backstack.gemspec
77
88
  - lib/backstack.rb
78
89
  - lib/backstacklib.rb
@@ -160,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
171
  version: '0'
161
172
  segments:
162
173
  - 0
163
- hash: -3534997333895431026
174
+ hash: -463953268826810848
164
175
  required_rubygems_version: !ruby/object:Gem::Requirement
165
176
  none: false
166
177
  requirements: