tourguide 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tourguide.rb +2 -0
- data/lib/tourguide/renderers/group.rb +39 -0
- data/lib/tourguide/renderers/progress.rb +26 -0
- data/lib/tourguide/renderers/stop.rb +15 -2
- data/lib/tourguide/renderers/tourbus.rb +9 -1
- data/lib/tourguide/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91c503b4e51c1f3cac25f5bd96a00616826704b9
|
4
|
+
data.tar.gz: b5d60879758f4faf6d16059fb9ad2db06f341986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31a455c0958e83e8e5957c1ef7957349c8f3ef651f9f23b913fd6f6dfe31312df2ae80a5bfb5df6604e768c79131097d5dd2933fd31831d7f53a596157d0d712
|
7
|
+
data.tar.gz: 92e2f5607313e537517644f5f2f8e14311198b1aa1c36ba7dae59c34904f79ae2d4a5b186a16aa2a150fd7c6633a97f2a328d9f16d48617b64a8a7df5c04e9d0
|
data/lib/tourguide.rb
CHANGED
@@ -8,6 +8,8 @@ require "tourguide/engine" if defined? Rails
|
|
8
8
|
require "tourguide/renderers/tourbus"
|
9
9
|
require "tourguide/renderers/link"
|
10
10
|
require "tourguide/renderers/connections"
|
11
|
+
require "tourguide/renderers/group"
|
12
|
+
require "tourguide/renderers/progress"
|
11
13
|
require "tourguide/renderers/stop"
|
12
14
|
|
13
15
|
module Tourguide
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Tourguide
|
2
|
+
module Renderers
|
3
|
+
class Group
|
4
|
+
|
5
|
+
attr_reader :stops, :options
|
6
|
+
|
7
|
+
def initialize(context, options={})
|
8
|
+
@context = context
|
9
|
+
@options = options.reverse_merge default_options
|
10
|
+
@stops = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
stops.each_with_index.map do |renderer, i|
|
15
|
+
renderer.count = i
|
16
|
+
renderer.total = total_stops
|
17
|
+
renderer.render
|
18
|
+
end.join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def stop(options={}, &block)
|
22
|
+
renderer = Tourguide::Renderers::Stop.new(@context, options)
|
23
|
+
yield(renderer) if block_given?
|
24
|
+
stops << renderer
|
25
|
+
end
|
26
|
+
|
27
|
+
def total_stops
|
28
|
+
@stops.count
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def default_options
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Tourguide
|
2
|
+
module Renderers
|
3
|
+
class Progress
|
4
|
+
|
5
|
+
def initialize(context, count, total)
|
6
|
+
@context = context
|
7
|
+
@count = count
|
8
|
+
@total = total
|
9
|
+
end
|
10
|
+
|
11
|
+
def render
|
12
|
+
return "" if uncountable?
|
13
|
+
(0...@total).map do |i|
|
14
|
+
css = ['bullet']
|
15
|
+
css << 'active' if i == @count
|
16
|
+
@context.content_tag(:li, "•".html_safe, class: css.join(' '))
|
17
|
+
end.join("\n").html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
def uncountable?
|
21
|
+
@count.blank? && @total.blank?
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -3,6 +3,7 @@ module Tourguide
|
|
3
3
|
class Stop
|
4
4
|
|
5
5
|
attr_reader :options
|
6
|
+
attr_writer :count, :total
|
6
7
|
|
7
8
|
def initialize(context, options={})
|
8
9
|
@context = context
|
@@ -27,11 +28,23 @@ module Tourguide
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def render
|
30
|
-
@context.content_tag(:li,
|
31
|
+
@context.content_tag(:li, rendered_content, li_options).html_safe
|
32
|
+
end
|
33
|
+
|
34
|
+
def progress
|
35
|
+
@progress ||= Tourguide::Renderers::Progress.new(@context, @count, @total)
|
31
36
|
end
|
32
37
|
|
33
38
|
private
|
34
39
|
|
40
|
+
def rendered_content
|
41
|
+
[close.render, @content, progress_content, connections.render].compact.join("\n").html_safe
|
42
|
+
end
|
43
|
+
|
44
|
+
def progress_content
|
45
|
+
@context.content_tag(:ol, progress.render, class: 'progress-list') unless progress.uncountable?
|
46
|
+
end
|
47
|
+
|
35
48
|
def li_options
|
36
49
|
{
|
37
50
|
data: data_options
|
@@ -39,7 +52,7 @@ module Tourguide
|
|
39
52
|
end
|
40
53
|
|
41
54
|
def data_options
|
42
|
-
options.except(:wrapper, :close).reject { |k, v| v.blank? }
|
55
|
+
options.except(:wrapper, :close, :counter).reject { |k, v| v.blank? }
|
43
56
|
end
|
44
57
|
|
45
58
|
def default_options
|
@@ -17,11 +17,19 @@ module Tourguide
|
|
17
17
|
stops << renderer
|
18
18
|
end
|
19
19
|
|
20
|
+
def group(options={}, &block)
|
21
|
+
renderer = Tourguide::Renderers::Group.new(@context, options)
|
22
|
+
yield(renderer) if block_given?
|
23
|
+
stops << renderer
|
24
|
+
end
|
25
|
+
|
26
|
+
|
20
27
|
def render
|
21
28
|
xhtml = Builder::XmlMarkup.new target: out=(''), indent: 2
|
22
29
|
xhtml.ul(ul_options) do |ul|
|
23
30
|
ul << stops.map { |x| x.render }.join("\n")
|
24
31
|
end
|
32
|
+
xhtml.div class: 'tour-overlay'
|
25
33
|
out.html_safe
|
26
34
|
end
|
27
35
|
|
@@ -44,7 +52,7 @@ module Tourguide
|
|
44
52
|
def default_options
|
45
53
|
{}
|
46
54
|
end
|
47
|
-
|
55
|
+
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/tourguide/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tourguide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Carlile
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass-rails
|
@@ -101,7 +101,9 @@ files:
|
|
101
101
|
- lib/tourguide.rb
|
102
102
|
- lib/tourguide/engine.rb
|
103
103
|
- lib/tourguide/renderers/connections.rb
|
104
|
+
- lib/tourguide/renderers/group.rb
|
104
105
|
- lib/tourguide/renderers/link.rb
|
106
|
+
- lib/tourguide/renderers/progress.rb
|
105
107
|
- lib/tourguide/renderers/stop.rb
|
106
108
|
- lib/tourguide/renderers/tourbus.rb
|
107
109
|
- lib/tourguide/version.rb
|