js-routes 0.2.0
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.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +97 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +49 -0
- data/Readme.md +38 -0
- data/VERSION +1 -0
- data/jsroutes.gemspec +69 -0
- data/lib/js_routes.rb +88 -0
- data/lib/jsroutes.rb +1 -0
- data/lib/routes.js +29 -0
- data/lib/tasks/js_routes.rake +14 -0
- data/spec/js_routes_spec.rb +59 -0
- data/spec/spec_helper.rb +30 -0
- metadata +171 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.9)
|
6
|
+
actionpack (= 3.0.9)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.9)
|
9
|
+
activemodel (= 3.0.9)
|
10
|
+
activesupport (= 3.0.9)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.9)
|
19
|
+
activesupport (= 3.0.9)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.9)
|
23
|
+
activemodel (= 3.0.9)
|
24
|
+
activesupport (= 3.0.9)
|
25
|
+
arel (~> 2.0.10)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.9)
|
28
|
+
activemodel (= 3.0.9)
|
29
|
+
activesupport (= 3.0.9)
|
30
|
+
activesupport (3.0.9)
|
31
|
+
arel (2.0.10)
|
32
|
+
builder (2.1.2)
|
33
|
+
diff-lcs (1.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
36
|
+
git (1.2.5)
|
37
|
+
i18n (0.5.0)
|
38
|
+
jeweler (1.6.4)
|
39
|
+
bundler (~> 1.0)
|
40
|
+
git (>= 1.2.5)
|
41
|
+
rake
|
42
|
+
libv8 (3.3.10.2)
|
43
|
+
mail (2.2.19)
|
44
|
+
activesupport (>= 2.3.6)
|
45
|
+
i18n (>= 0.4.0)
|
46
|
+
mime-types (~> 1.16)
|
47
|
+
treetop (~> 1.4.8)
|
48
|
+
mime-types (1.16)
|
49
|
+
polyglot (0.3.2)
|
50
|
+
rack (1.2.3)
|
51
|
+
rack-mount (0.6.14)
|
52
|
+
rack (>= 1.0.0)
|
53
|
+
rack-test (0.5.7)
|
54
|
+
rack (>= 1.0)
|
55
|
+
rails (3.0.9)
|
56
|
+
actionmailer (= 3.0.9)
|
57
|
+
actionpack (= 3.0.9)
|
58
|
+
activerecord (= 3.0.9)
|
59
|
+
activeresource (= 3.0.9)
|
60
|
+
activesupport (= 3.0.9)
|
61
|
+
bundler (~> 1.0)
|
62
|
+
railties (= 3.0.9)
|
63
|
+
railties (3.0.9)
|
64
|
+
actionpack (= 3.0.9)
|
65
|
+
activesupport (= 3.0.9)
|
66
|
+
rake (>= 0.8.7)
|
67
|
+
rdoc (~> 3.4)
|
68
|
+
thor (~> 0.14.4)
|
69
|
+
rake (0.9.2)
|
70
|
+
rcov (0.9.9)
|
71
|
+
rdoc (3.9.1)
|
72
|
+
rspec (2.3.0)
|
73
|
+
rspec-core (~> 2.3.0)
|
74
|
+
rspec-expectations (~> 2.3.0)
|
75
|
+
rspec-mocks (~> 2.3.0)
|
76
|
+
rspec-core (2.3.1)
|
77
|
+
rspec-expectations (2.3.0)
|
78
|
+
diff-lcs (~> 1.1.2)
|
79
|
+
rspec-mocks (2.3.0)
|
80
|
+
therubyracer (0.9.2)
|
81
|
+
libv8 (~> 3.3.10)
|
82
|
+
thor (0.14.6)
|
83
|
+
treetop (1.4.10)
|
84
|
+
polyglot
|
85
|
+
polyglot (>= 0.3.1)
|
86
|
+
tzinfo (0.3.29)
|
87
|
+
|
88
|
+
PLATFORMS
|
89
|
+
ruby
|
90
|
+
|
91
|
+
DEPENDENCIES
|
92
|
+
bundler (~> 1.0.0)
|
93
|
+
jeweler (~> 1.6.2)
|
94
|
+
rails (>= 3.0)
|
95
|
+
rcov
|
96
|
+
rspec (~> 2.3.0)
|
97
|
+
therubyracer
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Bogdan Gusiev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "js-routes"
|
18
|
+
gem.homepage = "http://github.com/railsware/js-routes"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Brings Rails named routes to javascript}
|
21
|
+
gem.description = %Q{Generates javascript file that defines all Rails named routes as javascript helpers}
|
22
|
+
gem.email = "agresso@gmail.com"
|
23
|
+
gem.authors = ["Bogdan Gusiev"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "js-routes #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
## JsRoutes
|
2
|
+
|
3
|
+
Generates javascript file that defines all Rails named routes as javascript helpers
|
4
|
+
|
5
|
+
### Intallation
|
6
|
+
|
7
|
+
Your Rails Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "js-routes"
|
11
|
+
```
|
12
|
+
|
13
|
+
Your application initializer, like `config/initializers/jsroutes.rb`:
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
JsRoutes.generate!(
|
17
|
+
:file => "#{Rails.root}app/assets/javascripts/routes.js", # This is default
|
18
|
+
:default_format => "json" # Default is blank
|
19
|
+
)
|
20
|
+
```
|
21
|
+
|
22
|
+
### Usage
|
23
|
+
|
24
|
+
This will create a nice javascript file with `Routes` object that has all the rails routes available:
|
25
|
+
|
26
|
+
``` js
|
27
|
+
Routes.users_path() // => "/users"
|
28
|
+
Routes.user_path(1, {format: 'json'}) // => "/users/1.json"
|
29
|
+
Routes.urer_project_path(1,2, {q: 'hello', custom: true}) // => "/users/1/projects/2?q=hello&custom=true"
|
30
|
+
```
|
31
|
+
|
32
|
+
In order to make routes helpers available globally:
|
33
|
+
|
34
|
+
``` js
|
35
|
+
$.extend(window, Routes)
|
36
|
+
```
|
37
|
+
|
38
|
+
#### Have fun
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/jsroutes.gemspec
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jsroutes}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Bogdan Gusiev"]
|
12
|
+
s.date = %q{2011-08-04}
|
13
|
+
s.description = %q{Generates javascript file that defines all Rails named routes as javascript helpers}
|
14
|
+
s.email = %q{agresso@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".rspec",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"Rakefile",
|
25
|
+
"Readme.md",
|
26
|
+
"VERSION",
|
27
|
+
"jsroutes.gemspec",
|
28
|
+
"lib/js_routes.rb",
|
29
|
+
"lib/jsroutes.rb",
|
30
|
+
"lib/routes.js",
|
31
|
+
"lib/tasks/js_routes.rake",
|
32
|
+
"spec/js_routes_spec.rb",
|
33
|
+
"spec/spec_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/bogdan/jsroutes}
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.7}
|
39
|
+
s.summary = %q{Brings Rails named routes to javascript}
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<therubyracer>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
54
|
+
s.add_dependency(%q<therubyracer>, [">= 0"])
|
55
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
62
|
+
s.add_dependency(%q<therubyracer>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
64
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
66
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/lib/js_routes.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
module JsRoutes
|
2
|
+
class << self
|
3
|
+
|
4
|
+
|
5
|
+
def generate(options = {})
|
6
|
+
js = File.read(File.dirname(__FILE__) + "/routes.js")
|
7
|
+
js.gsub!("IDENTITY", js_routes(options))
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate!(options = {})
|
11
|
+
file = options[:file] || default_file
|
12
|
+
File.open(file, 'w') do |f|
|
13
|
+
f.write generate(options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Implementation
|
19
|
+
#
|
20
|
+
|
21
|
+
protected
|
22
|
+
def js_routes(options = {})
|
23
|
+
|
24
|
+
options[:default_format] ||= ""
|
25
|
+
|
26
|
+
Rails.application.reload_routes!
|
27
|
+
Rails.application.routes.named_routes.routes.map do |name, route|
|
28
|
+
<<-JS
|
29
|
+
// #{route.name} => #{route.path}
|
30
|
+
#{name.to_s}_path: function(#{build_params route}) {
|
31
|
+
var opts = options || {};
|
32
|
+
var format = opts.format || '#{options[:default_format]}';
|
33
|
+
delete opts.format;
|
34
|
+
#{build_default_params route};
|
35
|
+
return Routes.check_path('#{build_path route}' + format) + Routes.serialize(opts);
|
36
|
+
},
|
37
|
+
JS
|
38
|
+
end.join("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def build_params route
|
43
|
+
route.conditions[:path_info].captures.map do |cap|
|
44
|
+
if cap.is_a?(Rack::Mount::GeneratableRegexp::DynamicSegment)
|
45
|
+
if cap.name.to_s == "format"
|
46
|
+
nil
|
47
|
+
else
|
48
|
+
cap.name.to_s.gsub(':', '')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end.compact.<<("options").join(', ')
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_default_params route
|
55
|
+
route.conditions[:path_info].captures.map do |cap|
|
56
|
+
if cap.is_a?(Rack::Mount::GeneratableRegexp::DynamicSegment)
|
57
|
+
segg = cap.name.to_s.gsub(':', '')
|
58
|
+
"#{segg} = Routes.check_parameter(#{segg});"
|
59
|
+
end
|
60
|
+
end.join("\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
def build_path route
|
64
|
+
s = route.path.gsub(/\(\.:format\)$/, ".")
|
65
|
+
|
66
|
+
route.conditions[:path_info].captures.each do |cap|
|
67
|
+
unless cap.name.to_s == "format"
|
68
|
+
if route.conditions[:path_info].required_params.include?(cap.name)
|
69
|
+
s.gsub!(/:#{cap.name.to_s}/){ "' + #{cap.name.to_s.gsub(':','')} + '" }
|
70
|
+
else
|
71
|
+
s.gsub!(/\((\.)?:#{cap.name.to_s}\)/){ "#{$1}' + #{cap.name.to_s.gsub(':','')} + '" }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
s
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def default_file
|
80
|
+
if Rails.version >= "3.1"
|
81
|
+
"#{Rails.root}/app/assets/javascripts/routes.js"
|
82
|
+
else
|
83
|
+
"#{Rails.root}/public/javascripts/routes.js"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/lib/jsroutes.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "js_routes"
|
data/lib/routes.js
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
var Routes = {
|
2
|
+
|
3
|
+
IDENTITY
|
4
|
+
|
5
|
+
serialize: function(obj){
|
6
|
+
if (obj == null) {return '';}
|
7
|
+
var s = [];
|
8
|
+
for (prop in obj){
|
9
|
+
s.push(prop + "=" + obj[prop]);
|
10
|
+
}
|
11
|
+
if (s.length == 0) {
|
12
|
+
return '';
|
13
|
+
}
|
14
|
+
return "?" + s.join('&');
|
15
|
+
},
|
16
|
+
|
17
|
+
|
18
|
+
check_parameter: function(param) {
|
19
|
+
if (param === undefined) {
|
20
|
+
param = '';
|
21
|
+
}
|
22
|
+
return param;
|
23
|
+
},
|
24
|
+
|
25
|
+
check_path: function(path) {
|
26
|
+
return path.replace(/\.$/m, '');
|
27
|
+
}
|
28
|
+
|
29
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
namespace :less do
|
3
|
+
namespace :js do
|
4
|
+
desc "Make a js file that will have functions that will return restful routes/urls."
|
5
|
+
task :routes => :environment do
|
6
|
+
require "jsroutes"
|
7
|
+
|
8
|
+
# Hack for actually load the routes (taken from railties console/app.rb)
|
9
|
+
ActionDispatch::Callbacks.new(lambda {}, false)
|
10
|
+
|
11
|
+
JsRoutes.generate!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
describe JsRoutes do
|
7
|
+
before(:each) do
|
8
|
+
evaljs(JsRoutes.generate(_options))
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:_options) { {} }
|
12
|
+
|
13
|
+
it "should generate collection routing" do
|
14
|
+
evaljs("Routes.inboxes_path()").should == "/inboxes"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should generate member routing" do
|
18
|
+
evaljs("Routes.inbox_path(1)").should == "/inboxes/1"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should generate nested routing" do
|
22
|
+
evaljs("Routes.inbox_message_path(1,2)").should == "/inboxes/1/messages/2"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should generate routing with format" do
|
26
|
+
evaljs("Routes.inbox_path(1, {format: 'json'})").should == "/inboxes/1.json"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should support get parameters" do
|
30
|
+
evaljs("Routes.inbox_path(1, {format: 'json', q: 'hello', lang: 'ua'})").should == "/inboxes/1.json?q=hello&lang=ua"
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
context "when default_format is specified" do
|
35
|
+
let(:_options) { {:default_format => "json"} }
|
36
|
+
|
37
|
+
it "should render routing with default_format" do
|
38
|
+
evaljs("Routes.inbox_path(1)").should == "/inboxes/1.json"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should override default_format implicitly" do
|
42
|
+
evaljs("Routes.inbox_path(1, {format: 'xml'})").should == "/inboxes/1.xml"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".generate!" do
|
48
|
+
let(:name) { "#{File.dirname(__FILE__)}/../routes.js" }
|
49
|
+
it "should generate routes file" do
|
50
|
+
FileUtils.rm_f(name)
|
51
|
+
JsRoutes.generate!({:file => name})
|
52
|
+
File.exists?(name).should be_true
|
53
|
+
end
|
54
|
+
after(:all) do
|
55
|
+
FileUtils.rm_f(name)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'jsroutes'
|
5
|
+
require 'rails'
|
6
|
+
require "v8"
|
7
|
+
require "active_support/core_ext/hash/slice"
|
8
|
+
|
9
|
+
def evaljs(string)
|
10
|
+
@context ||= V8::Context.new
|
11
|
+
@context.eval(string)
|
12
|
+
end
|
13
|
+
|
14
|
+
class App < Rails::Application
|
15
|
+
self.routes.draw do
|
16
|
+
resources :inboxes do
|
17
|
+
resources :messages
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
# Requires supporting files with custom matchers and macros, etc,
|
25
|
+
# in ./support/ and its subdirectories.
|
26
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: js-routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Bogdan Gusiev
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-04 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 7
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
version: "3.0"
|
32
|
+
requirement: *id001
|
33
|
+
type: :runtime
|
34
|
+
name: rails
|
35
|
+
prerelease: false
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
requirement: *id002
|
47
|
+
type: :development
|
48
|
+
name: therubyracer
|
49
|
+
prerelease: false
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 2
|
59
|
+
- 3
|
60
|
+
- 0
|
61
|
+
version: 2.3.0
|
62
|
+
requirement: *id003
|
63
|
+
type: :development
|
64
|
+
name: rspec
|
65
|
+
prerelease: false
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 23
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 0
|
76
|
+
- 0
|
77
|
+
version: 1.0.0
|
78
|
+
requirement: *id004
|
79
|
+
type: :development
|
80
|
+
name: bundler
|
81
|
+
prerelease: false
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 11
|
89
|
+
segments:
|
90
|
+
- 1
|
91
|
+
- 6
|
92
|
+
- 2
|
93
|
+
version: 1.6.2
|
94
|
+
requirement: *id005
|
95
|
+
type: :development
|
96
|
+
name: jeweler
|
97
|
+
prerelease: false
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirement: *id006
|
109
|
+
type: :development
|
110
|
+
name: rcov
|
111
|
+
prerelease: false
|
112
|
+
description: Generates javascript file that defines all Rails named routes as javascript helpers
|
113
|
+
email: agresso@gmail.com
|
114
|
+
executables: []
|
115
|
+
|
116
|
+
extensions: []
|
117
|
+
|
118
|
+
extra_rdoc_files:
|
119
|
+
- LICENSE.txt
|
120
|
+
files:
|
121
|
+
- .document
|
122
|
+
- .rspec
|
123
|
+
- Gemfile
|
124
|
+
- Gemfile.lock
|
125
|
+
- LICENSE.txt
|
126
|
+
- Rakefile
|
127
|
+
- Readme.md
|
128
|
+
- VERSION
|
129
|
+
- jsroutes.gemspec
|
130
|
+
- lib/js_routes.rb
|
131
|
+
- lib/jsroutes.rb
|
132
|
+
- lib/routes.js
|
133
|
+
- lib/tasks/js_routes.rake
|
134
|
+
- spec/js_routes_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
has_rdoc: true
|
137
|
+
homepage: http://github.com/railsware/js-routes
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 3
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
version: "0"
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
hash: 3
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
version: "0"
|
163
|
+
requirements: []
|
164
|
+
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 1.3.7
|
167
|
+
signing_key:
|
168
|
+
specification_version: 3
|
169
|
+
summary: Brings Rails named routes to javascript
|
170
|
+
test_files: []
|
171
|
+
|