cone 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dfc31078d447ab6188e4f842b480b870b5c564b
4
- data.tar.gz: 4bf4c87d492866bc694862cf23cc377647e2411f
3
+ metadata.gz: 8a942374015a7a7e7284ffd570b56b211e20d121
4
+ data.tar.gz: 3b6471fc8bd8d7e59d94c6e251e4619ad0ec2d5f
5
5
  SHA512:
6
- metadata.gz: 822362cf5b235595126b91d59284425d5ce32e045250beec28c3a754684afaff97d4a767f026cf9149175216b980df88f470afc1155b62d45d05734dc90d094c
7
- data.tar.gz: cb36210caf836249dbae53d9c769f035f464df89d6d35893e88ad91262074f43f8d6f0aca4524845060a5e3384df7c85c3843741fe07f507ce1762ac672ce938
6
+ metadata.gz: e5b7ea5912dc13217a8365e111b6c8cc392dcb665541fd68d4f1b25ff39366b159d2a567c8d0f1737a67d4c9ef994528f29c87006ebf3cd4b6adac912cc60ffc
7
+ data.tar.gz: f5f7dfddbb1b69567f1cd54901ff70be0bb483dbc950cd7bac636406c0d3e7d4a1be4c8277d554d6ddeb6cbe458b66bea6938d83024bf1159130ffe792e2c1f5
data/README.md CHANGED
@@ -10,14 +10,17 @@ user GET /users/:id(.:format) users#show
10
10
  Let's say you have this Rails route. Here's how you would access it in Javascript with cone:
11
11
 
12
12
  ```javascript
13
- cone.userPath({id: 12});
13
+ cone.userPath({ id: 12 });
14
14
  "/users/12"
15
15
 
16
- cone.userPath({id: 12, format: 'json'});
16
+ cone.userPath({ id: 12, format: 'json' });
17
17
  "/users/12.json"
18
18
 
19
- cone.userPath({id: 12, format: 'json', foo: 'bar baz'});
19
+ cone.userPath({ id: 12, format: 'json', foo: 'bar baz' });
20
20
  "/users/12.json?foo=bar%20baz"
21
+
22
+ cone.userPath({ id: 12, foo: 'bar baz', anchor: 'foo' });
23
+ "/users/12?foo=bar%20baz#foo"
21
24
  ```
22
25
 
23
26
  Reload the server whenever your routes change to have the Javascript regenerated.
@@ -27,4 +30,4 @@ Reload the server whenever your routes change to have the Javascript regenerated
27
30
  1. Add gem 'cone' to your Gemfile.
28
31
  2. Run bundle install.
29
32
  3. Add //= require cone to your Javascript manifest file (usually found at app/assets/javascripts/application.js).
30
- 4. Restart your server.
33
+ 4. Restart your server.
data/cone.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'cone'
3
- gem.version = '0.2.0'
3
+ gem.version = '0.3.0'
4
4
  gem.summary = 'Rails client side URL helpers'
5
5
  gem.author = 'Lihan Li'
6
6
  gem.email = 'frankieteardrop@gmail.com'
@@ -7,13 +7,19 @@ processPath = (path, params = {}) ->
7
7
 
8
8
  for k, v of params
9
9
  keySymbol = ":#{k}"
10
+ v = encodeURIComponent(v)
11
+ anchor = null
10
12
 
11
13
  if path.indexOf(keySymbol) == -1
12
- paramsArray.push("#{encodeURIComponent(k)}=#{encodeURIComponent(v)}")
14
+ if k == 'anchor'
15
+ anchor = v
16
+ else
17
+ paramsArray.push("#{encodeURIComponent(k)}=#{v}")
13
18
  else
14
- path = path.replace(keySymbol, encodeURIComponent(v))
19
+ path = path.replace(keySymbol, v)
15
20
 
16
21
  path += "?#{paramsArray.join('&')}" unless paramsArray.length == 0
22
+ path += "##{anchor}" if anchor?
17
23
  path
18
24
 
19
25
  @cone =
data/test/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '5.0.0'
3
+ gem 'rails', '5.0.1'
4
4
  gem 'cone', path: '..'
5
5
 
6
6
  group :development, :test do
data/test/Gemfile.lock CHANGED
@@ -8,46 +8,46 @@ PATH
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.0.0)
12
- actionpack (= 5.0.0)
11
+ actioncable (5.0.1)
12
+ actionpack (= 5.0.1)
13
13
  nio4r (~> 1.2)
14
14
  websocket-driver (~> 0.6.1)
15
- actionmailer (5.0.0)
16
- actionpack (= 5.0.0)
17
- actionview (= 5.0.0)
18
- activejob (= 5.0.0)
15
+ actionmailer (5.0.1)
16
+ actionpack (= 5.0.1)
17
+ actionview (= 5.0.1)
18
+ activejob (= 5.0.1)
19
19
  mail (~> 2.5, >= 2.5.4)
20
20
  rails-dom-testing (~> 2.0)
21
- actionpack (5.0.0)
22
- actionview (= 5.0.0)
23
- activesupport (= 5.0.0)
21
+ actionpack (5.0.1)
22
+ actionview (= 5.0.1)
23
+ activesupport (= 5.0.1)
24
24
  rack (~> 2.0)
25
25
  rack-test (~> 0.6.3)
26
26
  rails-dom-testing (~> 2.0)
27
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.0.0)
29
- activesupport (= 5.0.0)
28
+ actionview (5.0.1)
29
+ activesupport (= 5.0.1)
30
30
  builder (~> 3.1)
31
31
  erubis (~> 2.7.0)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
34
- activejob (5.0.0)
35
- activesupport (= 5.0.0)
34
+ activejob (5.0.1)
35
+ activesupport (= 5.0.1)
36
36
  globalid (>= 0.3.6)
37
- activemodel (5.0.0)
38
- activesupport (= 5.0.0)
39
- activerecord (5.0.0)
40
- activemodel (= 5.0.0)
41
- activesupport (= 5.0.0)
37
+ activemodel (5.0.1)
38
+ activesupport (= 5.0.1)
39
+ activerecord (5.0.1)
40
+ activemodel (= 5.0.1)
41
+ activesupport (= 5.0.1)
42
42
  arel (~> 7.0)
43
- activesupport (5.0.0)
43
+ activesupport (5.0.1)
44
44
  concurrent-ruby (~> 1.0, >= 1.0.2)
45
45
  i18n (~> 0.7)
46
46
  minitest (~> 5.1)
47
47
  tzinfo (~> 1.1)
48
48
  addressable (2.4.0)
49
49
  ansi (1.5.0)
50
- arel (7.0.0)
50
+ arel (7.1.4)
51
51
  builder (3.2.2)
52
52
  capybara (2.7.1)
53
53
  addressable
@@ -66,13 +66,13 @@ GEM
66
66
  coffee-script-source
67
67
  execjs
68
68
  coffee-script-source (1.10.0)
69
- concurrent-ruby (1.0.2)
69
+ concurrent-ruby (1.0.4)
70
70
  daemons (1.2.3)
71
71
  erubis (2.7.0)
72
72
  eventmachine (1.2.0.1)
73
73
  execjs (2.7.0)
74
74
  ffi (1.9.14)
75
- globalid (0.3.6)
75
+ globalid (0.3.7)
76
76
  activesupport (>= 4.1.0)
77
77
  i18n (0.7.0)
78
78
  loofah (2.0.3)
@@ -84,17 +84,15 @@ GEM
84
84
  mime-types-data (~> 3.2015)
85
85
  mime-types-data (3.2016.0521)
86
86
  mini_portile2 (2.1.0)
87
- minitest (5.9.0)
87
+ minitest (5.10.1)
88
88
  minitest-reporters (1.0.8)
89
89
  ansi
90
90
  builder
91
91
  minitest (>= 5.0)
92
92
  ruby-progressbar
93
93
  nio4r (1.2.1)
94
- nokogiri (1.6.8)
94
+ nokogiri (1.7.0)
95
95
  mini_portile2 (~> 2.1.0)
96
- pkg-config (~> 1.1.7)
97
- pkg-config (1.1.7)
98
96
  pry (0.10.4)
99
97
  coderay (~> 1.1.0)
100
98
  method_source (~> 0.8.1)
@@ -104,30 +102,30 @@ GEM
104
102
  rack (2.0.1)
105
103
  rack-test (0.6.3)
106
104
  rack (>= 1.0)
107
- rails (5.0.0)
108
- actioncable (= 5.0.0)
109
- actionmailer (= 5.0.0)
110
- actionpack (= 5.0.0)
111
- actionview (= 5.0.0)
112
- activejob (= 5.0.0)
113
- activemodel (= 5.0.0)
114
- activerecord (= 5.0.0)
115
- activesupport (= 5.0.0)
105
+ rails (5.0.1)
106
+ actioncable (= 5.0.1)
107
+ actionmailer (= 5.0.1)
108
+ actionpack (= 5.0.1)
109
+ actionview (= 5.0.1)
110
+ activejob (= 5.0.1)
111
+ activemodel (= 5.0.1)
112
+ activerecord (= 5.0.1)
113
+ activesupport (= 5.0.1)
116
114
  bundler (>= 1.3.0, < 2.0)
117
- railties (= 5.0.0)
115
+ railties (= 5.0.1)
118
116
  sprockets-rails (>= 2.0.0)
119
- rails-dom-testing (2.0.1)
117
+ rails-dom-testing (2.0.2)
120
118
  activesupport (>= 4.2.0, < 6.0)
121
- nokogiri (~> 1.6.0)
119
+ nokogiri (~> 1.6)
122
120
  rails-html-sanitizer (1.0.3)
123
121
  loofah (~> 2.0)
124
- railties (5.0.0)
125
- actionpack (= 5.0.0)
126
- activesupport (= 5.0.0)
122
+ railties (5.0.1)
123
+ actionpack (= 5.0.1)
124
+ activesupport (= 5.0.1)
127
125
  method_source
128
126
  rake (>= 0.8.7)
129
127
  thor (>= 0.18.1, < 2.0)
130
- rake (11.2.2)
128
+ rake (12.0.0)
131
129
  ruby-progressbar (1.8.1)
132
130
  rubyzip (1.2.0)
133
131
  selenium-webdriver (2.53.4)
@@ -135,10 +133,10 @@ GEM
135
133
  rubyzip (~> 1.0)
136
134
  websocket (~> 1.0)
137
135
  slop (3.6.0)
138
- sprockets (3.6.3)
136
+ sprockets (3.7.1)
139
137
  concurrent-ruby (~> 1.0)
140
138
  rack (> 1, < 3)
141
- sprockets-rails (3.1.1)
139
+ sprockets-rails (3.2.0)
142
140
  actionpack (>= 4.0)
143
141
  activesupport (>= 4.0)
144
142
  sprockets (>= 3.0.0)
@@ -146,7 +144,7 @@ GEM
146
144
  daemons (~> 1.0, >= 1.0.9)
147
145
  eventmachine (~> 1.0, >= 1.0.4)
148
146
  rack (>= 1, < 3)
149
- thor (0.19.1)
147
+ thor (0.19.4)
150
148
  thread_safe (0.3.5)
151
149
  tzinfo (1.2.2)
152
150
  thread_safe (~> 0.1)
@@ -165,9 +163,9 @@ DEPENDENCIES
165
163
  cone!
166
164
  minitest-reporters (= 1.0.8)
167
165
  pry-rails
168
- rails (= 5.0.0)
166
+ rails (= 5.0.1)
169
167
  selenium-webdriver (= 2.53.4)
170
168
  thin
171
169
 
172
170
  BUNDLED WITH
173
- 1.12.4
171
+ 1.12.5
@@ -1,24 +1,27 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ConeGemTest < ActionDispatch::IntegrationTest
4
- def get_cone_url(name, opt = {})
4
+ def get_cone_path(name, opt = {})
5
5
  # alias, params
6
6
  get_js("cone.#{name}Path(#{ opt[:params] ? opt[:params].to_json : '' })")
7
7
  end
8
8
 
9
- test 'url without params' do
10
- assert_equal '/', get_cone_url('root')
11
- assert_equal '/users', get_cone_url('users')
9
+ test 'path without params' do
10
+ assert_equal '/', get_cone_path('root')
11
+ assert_equal '/users', get_cone_path('users')
12
12
  end
13
13
 
14
- test 'url with path params' do
15
- assert_equal '/users/12/posts', get_cone_url('userPosts', params: {user_id: '12'})
16
- assert_equal '/users/12/posts/34.json', get_cone_url('userPost', params: {user_id: '12', id: '34', format: 'json'})
14
+ test 'path with path params' do
15
+ assert_equal '/users/12/posts', get_cone_path('userPosts', params: {user_id: '12'})
16
+ assert_equal '/users/12/posts/34.json', get_cone_path('userPost', params: {user_id: '12', id: '34', format: 'json'})
17
17
  end
18
18
 
19
- test 'url with get params' do
20
- assert_equal '/?foo=bar%20baz', get_cone_url('root', params: {foo: 'bar baz'})
21
- assert_equal '/users/12/posts?foo=bar%20baz', get_cone_url('userPosts', params: {user_id: '12', foo: 'bar baz'})
19
+ test 'path with get params' do
20
+ assert_equal '/?foo=bar%20baz', get_cone_path('root', params: {foo: 'bar baz'})
21
+ assert_equal '/users/12/posts?foo=bar%20baz', get_cone_path('userPosts', params: {user_id: '12', foo: 'bar baz'})
22
22
  end
23
23
 
24
+ test 'path with anchor' do
25
+ assert_equal '/?foo=bar#bar%20bar', get_cone_path('root', params: { foo: 'bar', anchor: 'bar bar' })
26
+ end
24
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lihan Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-17 00:00:00.000000000 Z
11
+ date: 2016-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails