js-routes 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +9 -9
- data/VERSION +1 -1
- data/js-routes.gemspec +6 -6
- data/lib/routes.js +8 -1
- data/spec/js_routes_spec.rb +12 -1
- data/spec/spec_helper.rb +4 -1
- metadata +40 -15
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -74,14 +74,14 @@ GEM
|
|
74
74
|
rake (0.9.2)
|
75
75
|
rdoc (3.12)
|
76
76
|
json (~> 1.4)
|
77
|
-
rspec (2.
|
78
|
-
rspec-core (~> 2.
|
79
|
-
rspec-expectations (~> 2.
|
80
|
-
rspec-mocks (~> 2.
|
81
|
-
rspec-core (2.
|
82
|
-
rspec-expectations (2.
|
83
|
-
diff-lcs (~> 1.1.
|
84
|
-
rspec-mocks (2.
|
77
|
+
rspec (2.10.0)
|
78
|
+
rspec-core (~> 2.10.0)
|
79
|
+
rspec-expectations (~> 2.10.0)
|
80
|
+
rspec-mocks (~> 2.10.0)
|
81
|
+
rspec-core (2.10.1)
|
82
|
+
rspec-expectations (2.10.0)
|
83
|
+
diff-lcs (~> 1.1.3)
|
84
|
+
rspec-mocks (2.10.1)
|
85
85
|
sprockets (2.1.2)
|
86
86
|
hike (~> 1.2)
|
87
87
|
rack (~> 1.0)
|
@@ -102,5 +102,5 @@ DEPENDENCIES
|
|
102
102
|
bundler (~> 1.1.0)
|
103
103
|
jeweler (~> 1.6.2)
|
104
104
|
rails (>= 3.2)
|
105
|
-
rspec (~> 2.
|
105
|
+
rspec (~> 2.10.0)
|
106
106
|
therubyracer
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.4
|
data/js-routes.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "js-routes"
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bogdan Gusiev"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-07-10"
|
13
13
|
s.description = "Generates javascript file that defines all Rails named routes as javascript helpers"
|
14
14
|
s.email = "agresso@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
s.homepage = "http://github.com/railsware/js-routes"
|
40
40
|
s.licenses = ["MIT"]
|
41
41
|
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = "1.8.
|
42
|
+
s.rubygems_version = "1.8.24"
|
43
43
|
s.summary = "Brings Rails named routes to javascript"
|
44
44
|
|
45
45
|
if s.respond_to? :specification_version then
|
@@ -48,20 +48,20 @@ Gem::Specification.new do |s|
|
|
48
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
49
|
s.add_runtime_dependency(%q<rails>, [">= 3.2"])
|
50
50
|
s.add_development_dependency(%q<therubyracer>, [">= 0"])
|
51
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.
|
51
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.10.0"])
|
52
52
|
s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
|
53
53
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
54
54
|
else
|
55
55
|
s.add_dependency(%q<rails>, [">= 3.2"])
|
56
56
|
s.add_dependency(%q<therubyracer>, [">= 0"])
|
57
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
58
58
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
59
59
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
60
60
|
end
|
61
61
|
else
|
62
62
|
s.add_dependency(%q<rails>, [">= 3.2"])
|
63
63
|
s.add_dependency(%q<therubyracer>, [">= 0"])
|
64
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
64
|
+
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
65
65
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
66
66
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
67
67
|
end
|
data/lib/routes.js
CHANGED
@@ -96,6 +96,12 @@
|
|
96
96
|
return result;
|
97
97
|
},
|
98
98
|
|
99
|
+
smartIndexOf: function(array, item){
|
100
|
+
if (Array.prototype.indexOf && array.indexOf === Array.prototype.indexOf) return array.indexOf(item);
|
101
|
+
for (var i = 0; i < array.length; i++) if (i in array && array[i] === item) return i;
|
102
|
+
return -1;
|
103
|
+
},
|
104
|
+
|
99
105
|
build_path: function(required_parameters, optional_parts, route, args) {
|
100
106
|
args = Array.prototype.slice.call(args);
|
101
107
|
var opts = this.extract_options(required_parameters.length, args);
|
@@ -104,7 +110,8 @@
|
|
104
110
|
}
|
105
111
|
|
106
112
|
parameters = this.prepare_parameters(required_parameters, args, opts);
|
107
|
-
|
113
|
+
// Array#indexOf is not supported by IE <= 8, so we use custom method
|
114
|
+
if (Utils.smartIndexOf(optional_parts, 'format') !== -1) {
|
108
115
|
this.set_default_format(parameters);
|
109
116
|
}
|
110
117
|
var result = Utils.get_prefix();
|
data/spec/js_routes_spec.rb
CHANGED
@@ -3,8 +3,10 @@ require "fileutils"
|
|
3
3
|
|
4
4
|
|
5
5
|
describe JsRoutes do
|
6
|
+
before(:all) do
|
7
|
+
draw_routes
|
8
|
+
end
|
6
9
|
before(:each) do
|
7
|
-
Rails.application.stub!(:reload_routes!).and_return(true)
|
8
10
|
evaljs(_presetup)
|
9
11
|
evaljs(JsRoutes.generate(_options))
|
10
12
|
end
|
@@ -232,6 +234,15 @@ describe JsRoutes do
|
|
232
234
|
|
233
235
|
end
|
234
236
|
|
237
|
+
context "when javascript engine without Array#indexOf is used" do
|
238
|
+
before(:each) do
|
239
|
+
evaljs("Array.prototype.indexOf = null")
|
240
|
+
end
|
241
|
+
it "should still work correctly" do
|
242
|
+
evaljs("Routes.inboxes_path()").should == routes.inboxes_path()
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
235
246
|
context "when default_format is specified" do
|
236
247
|
let(:_options) { {:default_format => "json"} }
|
237
248
|
|
data/spec/spec_helper.rb
CHANGED
@@ -30,8 +30,11 @@ end
|
|
30
30
|
class App < Rails::Application
|
31
31
|
# Enable the asset pipeline
|
32
32
|
config.assets.enabled = true
|
33
|
+
end
|
34
|
+
|
35
|
+
def draw_routes
|
33
36
|
|
34
|
-
|
37
|
+
App.routes.draw do
|
35
38
|
resources :inboxes do
|
36
39
|
resources :messages do
|
37
40
|
resources :attachments
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: therubyracer
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,21 +37,31 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
53
|
+
version: 2.10.0
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.10.0
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: bundler
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 1.1.0
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.1.0
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: jeweler
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ~>
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: 1.6.2
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.6.2
|
69
94
|
description: Generates javascript file that defines all Rails named routes as javascript
|
70
95
|
helpers
|
71
96
|
email: agresso@gmail.com
|
@@ -108,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
133
|
version: '0'
|
109
134
|
segments:
|
110
135
|
- 0
|
111
|
-
hash:
|
136
|
+
hash: 4117024943780104763
|
112
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
138
|
none: false
|
114
139
|
requirements:
|
@@ -117,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
142
|
version: '0'
|
118
143
|
requirements: []
|
119
144
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.8.
|
145
|
+
rubygems_version: 1.8.24
|
121
146
|
signing_key:
|
122
147
|
specification_version: 3
|
123
148
|
summary: Brings Rails named routes to javascript
|