ruta 1.0.0 → 1.0.1
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/README.md +16 -1
- data/lib/ruta.rb +4 -5
- data/lib/ruta/context.rb +2 -2
- data/lib/ruta/handler.rb +9 -10
- data/lib/ruta/history.rb +10 -10
- data/lib/ruta/router.rb +1 -1
- data/lib/ruta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ce32584f9e3d2b39f68447190c03b70940c3a12
|
4
|
+
data.tar.gz: 825005efef9a9c759f9ce6fc6e3a4a55bc1cfa4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdba23f5df9a660249604385b34b896cbeb121eeb4ec5843b22a50039d9cce3c97172c91aa71f71953e85cb9973770137694928f4d09f500c7a7d19ff6adc82b
|
7
|
+
data.tar.gz: 5ac91648139d2077b398eb2be4dc92dc61e3478fe8a1282e2547f75df7c637b59e48e918812e5fc822250edfafa536c28961baa841958877692e2dd5ecfb0f9b
|
data/README.md
CHANGED
@@ -155,7 +155,22 @@ Ruta::Context.handle_render do |component,element_id|
|
|
155
155
|
end
|
156
156
|
```
|
157
157
|
|
158
|
-
###
|
158
|
+
###Navigating your app
|
159
|
+
|
160
|
+
Navigating your app is super duper easy.
|
161
|
+
All you have to do is this
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
Ruta.navigate_to_ref(:info_view,:i_switch,value)
|
165
|
+
```
|
166
|
+
The first arg is the context the route you wish to navigate to is located in, the second is the
|
167
|
+
reference of the route, lastly any params you wish to place into the route go next, they are placed into the route as they come.
|
168
|
+
|
169
|
+
You would most probably use it in a 'click' callback in response to the user clicking on somthing
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
###Starting the app
|
159
174
|
|
160
175
|
The last step is to start the router and thus your app this can be accomplished by using `Ruta.start_app`;
|
161
176
|
it's best to wrap this inside of a `$document.ready` block so that the app will only start when the dom is
|
data/lib/ruta.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# @todo:
|
2
|
-
# @todo: Allow empty components to
|
1
|
+
# @todo: allow contexts to be mounted to roots
|
2
|
+
# @todo: Allow empty components to exists and ensure they are only rendered when they are not blank
|
3
3
|
|
4
4
|
if RUBY_ENGINE == 'opal'
|
5
5
|
require 'browser'
|
@@ -18,7 +18,7 @@ if RUBY_ENGINE == 'opal'
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
# used to
|
21
|
+
# used to retrieve a stored url
|
22
22
|
#
|
23
23
|
# @param [Symbol] context of the stored url, if this is nil it defaults to the current context
|
24
24
|
# @param [Symbol] reference to the route
|
@@ -32,7 +32,6 @@ if RUBY_ENGINE == 'opal'
|
|
32
32
|
# @param [Symbol] context that route is mounted to
|
33
33
|
# @param [Symbol] ref to a route that you wish to navigate to
|
34
34
|
# @param [Array<String,Number,Boolean>] *params 0 or more params to replace params in the paramterized route
|
35
|
-
# @note you have to use this function as a proc direcly as in the example, if you place this into a callback block and call it there, you will find that the incorrect context is used for the route
|
36
35
|
# @return [Proc] A proc that can be used as a callback block for an event
|
37
36
|
def navigate_to_ref context, ref,*params
|
38
37
|
route = Router.route_for(context,ref,params)
|
@@ -41,7 +40,7 @@ if RUBY_ENGINE == 'opal'
|
|
41
40
|
end
|
42
41
|
|
43
42
|
# used to start the app
|
44
|
-
# @example
|
43
|
+
# @example start command placed inside of $document.ready block
|
45
44
|
# $document.ready do
|
46
45
|
# Ruta.start_app
|
47
46
|
# end
|
data/lib/ruta/context.rb
CHANGED
@@ -28,7 +28,7 @@ module Ruta
|
|
28
28
|
instance_exec &block if block
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
31
|
+
# define a component of the composition
|
32
32
|
#
|
33
33
|
# @param [Symbol] id of element to mount element contents to
|
34
34
|
# @param [{Symbol => String,Number,Boolean}] list of attributes to attach to tag
|
@@ -104,7 +104,7 @@ module Ruta
|
|
104
104
|
@collection[ref] = new(ref,block)
|
105
105
|
end
|
106
106
|
|
107
|
-
# used to wipe clear an
|
107
|
+
# used to wipe clear an element's content
|
108
108
|
#
|
109
109
|
# @param [String] id of element to be cleared, if no id is provided will clear body tag of content
|
110
110
|
def wipe id=nil
|
data/lib/ruta/handler.rb
CHANGED
@@ -22,13 +22,12 @@ module Ruta
|
|
22
22
|
# wipe the matching element and render a context
|
23
23
|
#
|
24
24
|
# @param [Symbol] context context to be mounted to matching element of handler
|
25
|
-
# @todo Move these functions to execution context?
|
26
25
|
# @return [Proc] returns a proc to be executed later
|
27
26
|
def mount context
|
28
27
|
handler_name = @handler_name
|
29
28
|
proc {
|
30
29
|
Context.wipe handler_name
|
31
|
-
Context.render context
|
30
|
+
Context.render context, handler_name
|
32
31
|
}
|
33
32
|
end
|
34
33
|
|
@@ -36,14 +35,14 @@ module Ruta
|
|
36
35
|
# define handlers for a context
|
37
36
|
#
|
38
37
|
# @example
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
38
|
+
# Ruta::Handlers.define_for :main do
|
39
|
+
# handler :header do |params,url|
|
40
|
+
# some code that process the params and returns a component
|
41
|
+
# end
|
42
|
+
# handler :footer do |params,url|
|
43
|
+
# some code that process the params and returns a component
|
44
|
+
# end
|
45
|
+
# end
|
47
46
|
# @param [Symbol] context to define handlers for
|
48
47
|
# @yield block containing handlers for a context
|
49
48
|
def define_for context, &block
|
data/lib/ruta/history.rb
CHANGED
@@ -43,17 +43,17 @@ module Ruta
|
|
43
43
|
`location.href = #{path}`
|
44
44
|
end
|
45
45
|
|
46
|
-
# get current `
|
46
|
+
# get current `item` from locaction
|
47
47
|
#
|
48
|
-
# current
|
48
|
+
# current items supported are:
|
49
49
|
# * query
|
50
50
|
# * fragment
|
51
51
|
# * path
|
52
52
|
# * url
|
53
53
|
# * uri
|
54
|
-
# @param [Symbol]
|
55
|
-
def current
|
56
|
-
case
|
54
|
+
# @param [Symbol] item to get the current value of from the current location
|
55
|
+
def current item
|
56
|
+
case item
|
57
57
|
when :query
|
58
58
|
`location.query`
|
59
59
|
when :fragment
|
@@ -92,13 +92,13 @@ module Ruta
|
|
92
92
|
def listen_for_on_before_load
|
93
93
|
`window.onbeforeunload = function (evt) {
|
94
94
|
var message = 'Are you sure you want to leave?';
|
95
|
-
|
95
|
+
if (typeof evt == 'undefined') {
|
96
96
|
evt = window.event;
|
97
|
-
|
98
|
-
|
97
|
+
}
|
98
|
+
if (evt) {
|
99
99
|
evt.returnValue = message;
|
100
|
-
|
101
|
-
|
100
|
+
}
|
101
|
+
return message;
|
102
102
|
}`
|
103
103
|
end
|
104
104
|
end
|
data/lib/ruta/router.rb
CHANGED
data/lib/ruta/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Becker
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opal
|