cone 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ build
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # cone
2
2
 
3
- Use your Rails url helpers in javascript.
3
+ Automatically generated javascript url helpers based on your Rails routes.
4
4
 
5
5
  ## usage
6
6
 
@@ -20,6 +20,8 @@ cone.userUrl({id: 12, format: 'json', foo: 'bar baz'});
20
20
  "/users/12.json?foo=bar%20baz"
21
21
  ```
22
22
 
23
+ Reload the server whenever your routes change to have the javascript regenerated.
24
+
23
25
  ## installation
24
26
 
25
27
  1. Add gem 'cone' to your Gemfile.
data/Rakefile CHANGED
@@ -2,4 +2,10 @@ task :test do
2
2
  Dir.chdir 'test'
3
3
  `bundle`
4
4
  system 'rake test'
5
+ end
6
+
7
+ task :build do
8
+ system 'gem build cone.gemspec'
9
+ `mkdir -p build`
10
+ `mv *.gem build`
5
11
  end
data/cone.gemspec ADDED
@@ -0,0 +1,11 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'cone'
3
+ gem.version = '0.0.2'
4
+ gem.summary = "Rails client side url helpers"
5
+ gem.author = 'Lihan Li'
6
+ gem.email = 'frankieteardrop@gmail.com'
7
+ gem.homepage = 'http://github.com/lihanli/cone'
8
+ gem.files = `git ls-files`.split("\n")
9
+
10
+ gem.add_dependency('coffee-rails')
11
+ end
@@ -16,8 +16,12 @@ processUrl = (url, params) ->
16
16
  url += "?#{paramsArray.join('&')}" unless paramsArray.length == 0
17
17
  url
18
18
 
19
- @cone =
19
+ @cone = {}
20
+
20
21
  <% Rails.application.routes.routes.named_routes.each do |route_name, route_val| %>
21
- <%= route_name.camelize(:lower) %>Url: (params = {}) ->
22
- processUrl(<%= route_val.path.spec.to_s.to_json %>, params)
22
+
23
+ <% route_name = route_name.camelize(:lower) %>
24
+ cone.<%= route_name %>Path = cone.<%= route_name %>Url = (params = {}) ->
25
+ processUrl(<%= route_val.path.spec.to_s.to_json %>, params)
26
+
23
27
  <% end %>
data/test/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+
13
+ # Ignore all logfiles and tempfiles.
14
+ /log/*.log
15
+ /tmp
data/test/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- cone (0.0.1)
4
+ cone (0.0.2)
5
5
  coffee-rails
6
6
 
7
7
  GEM
File without changes
File without changes
File without changes
File without changes
data/test/log/.gitkeep ADDED
File without changes
File without changes
File without changes
File without changes
@@ -1,8 +1,10 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ConeGemTest < ActionDispatch::IntegrationTest
4
- def get_cone_url(name, params = false)
5
- get_js("cone.#{name}Url(#{params ? params.to_json : ''})")
4
+
5
+ def get_cone_url(name, opt = {})
6
+ # alias, params
7
+ get_js("cone.#{name}#{ opt[:alias] ? 'Url' : 'Path' }(#{ opt[:params] ? opt[:params].to_json : '' })")
6
8
  end
7
9
 
8
10
  test 'url without params' do
@@ -11,13 +13,17 @@ class ConeGemTest < ActionDispatch::IntegrationTest
11
13
  end
12
14
 
13
15
  test 'url with path params' do
14
- assert_equal '/users/12/posts', get_cone_url('userPosts', user_id: '12')
15
- assert_equal '/users/12/posts/34.json', get_cone_url('userPost', user_id: '12', id: '34', format: 'json')
16
+ assert_equal '/users/12/posts', get_cone_url('userPosts', params: {user_id: '12'})
17
+ assert_equal '/users/12/posts/34.json', get_cone_url('userPost', params: {user_id: '12', id: '34', format: 'json'})
16
18
  end
17
19
 
18
20
  test 'url with get params' do
19
- assert_equal '/?foo=bar%20baz', get_cone_url('root', foo: 'bar baz')
20
- assert_equal '/users/12/posts?foo=bar%20baz', get_cone_url('userPosts', user_id: '12', foo: 'bar baz')
21
+ assert_equal '/?foo=bar%20baz', get_cone_url('root', params: {foo: 'bar baz'})
22
+ assert_equal '/users/12/posts?foo=bar%20baz', get_cone_url('userPosts', params: {user_id: '12', foo: 'bar baz'})
23
+ end
24
+
25
+ test 'url helper alias' do
26
+ assert_equal '/users/12/posts', get_cone_url('userPosts', params: {user_id: '12'}, alias: true)
21
27
  end
22
28
 
23
29
  end
File without changes
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ConeInitTest < ActiveSupport::TestCase
4
+ test 'assets cache clear on init' do
5
+ assert Dir["#{Rails.application.config.assets[:cache_store][1]}*"].empty?
6
+ end
7
+ end
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -33,17 +33,29 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - .gitignore
37
+ - MIT-LICENSE
38
+ - README.md
36
39
  - Rakefile
40
+ - cone.gemspec
37
41
  - lib/assets/javascripts/cone.coffee.erb
38
42
  - lib/cone.rb
43
+ - test/.gitignore
44
+ - test/Gemfile
45
+ - test/Gemfile.lock
46
+ - test/README.rdoc
47
+ - test/Rakefile
39
48
  - test/app/assets/images/rails.png
40
49
  - test/app/assets/javascripts/application.js
41
50
  - test/app/assets/stylesheets/application.css
42
51
  - test/app/controllers/application_controller.rb
43
52
  - test/app/controllers/users_controller.rb
44
53
  - test/app/helpers/application_helper.rb
54
+ - test/app/mailers/.gitkeep
55
+ - test/app/models/.gitkeep
45
56
  - test/app/views/layouts/application.html.erb
46
57
  - test/app/views/users/index.html.erb
58
+ - test/config.ru
47
59
  - test/config/application.rb
48
60
  - test/config/boot.rb
49
61
  - test/config/environment.rb
@@ -58,24 +70,28 @@ files:
58
70
  - test/config/initializers/wrap_parameters.rb
59
71
  - test/config/locales/en.yml
60
72
  - test/config/routes.rb
61
- - test/config.ru
62
73
  - test/db/seeds.rb
63
74
  - test/doc/README_FOR_APP
64
- - test/Gemfile
65
- - test/Gemfile.lock
75
+ - test/lib/assets/.gitkeep
76
+ - test/lib/tasks/.gitkeep
77
+ - test/log/.gitkeep
66
78
  - test/public/404.html
67
79
  - test/public/422.html
68
80
  - test/public/500.html
69
81
  - test/public/favicon.ico
70
82
  - test/public/robots.txt
71
- - test/Rakefile
72
- - test/README.rdoc
73
83
  - test/script/rails
84
+ - test/test/fixtures/.gitkeep
85
+ - test/test/functional/.gitkeep
86
+ - test/test/integration/.gitkeep
74
87
  - test/test/integration/cone_gem_test.rb
75
88
  - test/test/performance/browsing_test.rb
76
89
  - test/test/test_helper.rb
77
- - README.md
78
- - MIT-LICENSE
90
+ - test/test/unit/.gitkeep
91
+ - test/test/unit/cone_init_test.rb
92
+ - test/vendor/assets/javascripts/.gitkeep
93
+ - test/vendor/assets/stylesheets/.gitkeep
94
+ - test/vendor/plugins/.gitkeep
79
95
  homepage: http://github.com/lihanli/cone
80
96
  licenses: []
81
97
  post_install_message: