eastwood 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -15
- data/README.md +1 -0
- data/app/assets/javascripts/eastwood.js.coffee.erb +4 -0
- data/eastwood.gemspec +3 -7
- data/gemfiles/rails-3.1.0.gemfile.lock +16 -16
- data/gemfiles/rails-3.2.0.gemfile.lock +20 -16
- data/lib/eastwood/config.rb +3 -1
- data/lib/eastwood/context/action_route.rb +2 -1
- data/lib/eastwood/context/hash_route.rb +2 -1
- data/lib/eastwood/context/journey_route.rb +2 -1
- data/lib/eastwood/context/route_helpers.rb +17 -0
- data/lib/eastwood/version.rb +1 -1
- data/lib/eastwood.rb +4 -0
- data/spec/unit/config_spec.rb +8 -0
- data/spec/unit/route_spec.rb +25 -1
- metadata +23 -22
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eastwood (0.3.
|
4
|
+
eastwood (0.3.6)
|
5
5
|
coffee-rails
|
6
|
-
rails
|
6
|
+
rails (>= 3.1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
@@ -87,20 +87,24 @@ GEM
|
|
87
87
|
rake (0.9.2.2)
|
88
88
|
rdoc (3.12)
|
89
89
|
json (~> 1.4)
|
90
|
-
rspec (2.
|
91
|
-
rspec-core (~> 2.
|
92
|
-
rspec-expectations (~> 2.
|
93
|
-
rspec-mocks (~> 2.
|
94
|
-
rspec-core (2.
|
95
|
-
rspec-expectations (2.
|
96
|
-
diff-lcs (~> 1.1.
|
97
|
-
rspec-mocks (2.
|
98
|
-
rspec-rails (2.
|
90
|
+
rspec (2.9.0)
|
91
|
+
rspec-core (~> 2.9.0)
|
92
|
+
rspec-expectations (~> 2.9.0)
|
93
|
+
rspec-mocks (~> 2.9.0)
|
94
|
+
rspec-core (2.9.0)
|
95
|
+
rspec-expectations (2.9.0)
|
96
|
+
diff-lcs (~> 1.1.3)
|
97
|
+
rspec-mocks (2.9.0)
|
98
|
+
rspec-rails (2.9.0)
|
99
99
|
actionpack (>= 3.0)
|
100
100
|
activesupport (>= 3.0)
|
101
101
|
railties (>= 3.0)
|
102
|
-
rspec (~> 2.
|
103
|
-
shoulda (
|
102
|
+
rspec (~> 2.9.0)
|
103
|
+
shoulda (3.0.1)
|
104
|
+
shoulda-context (~> 1.0.0)
|
105
|
+
shoulda-matchers (~> 1.0.0)
|
106
|
+
shoulda-context (1.0.0)
|
107
|
+
shoulda-matchers (1.0.0)
|
104
108
|
simplecov (0.6.1)
|
105
109
|
multi_json (~> 1.0)
|
106
110
|
simplecov-html (~> 0.5.3)
|
@@ -124,7 +128,7 @@ DEPENDENCIES
|
|
124
128
|
appraisal (= 0.4.1)
|
125
129
|
eastwood!
|
126
130
|
execjs (= 1.3.0)
|
127
|
-
rspec-rails (= 2.
|
128
|
-
shoulda
|
131
|
+
rspec-rails (= 2.9.0)
|
132
|
+
shoulda (= 3.0.1)
|
129
133
|
simplecov (= 0.6.1)
|
130
134
|
sqlite3
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ Eastwood
|
|
4
4
|
> Start your client side out right.
|
5
5
|
|
6
6
|
[![Build Status](https://secure.travis-ci.org/jeremyruppel/eastwood.png)](http://travis-ci.org/jeremyruppel/eastwood)
|
7
|
+
[![Dependency Status](https://gemnasium.com/jeremyruppel/eastwood.png)](https://gemnasium.com/jeremyruppel/eastwood)
|
7
8
|
|
8
9
|
About
|
9
10
|
-----
|
@@ -6,14 +6,17 @@ app = { env : "<%= env %>", routes : { } }
|
|
6
6
|
###*
|
7
7
|
* Exports
|
8
8
|
###
|
9
|
+
<% if exports.any? %>
|
9
10
|
app.exports =
|
10
11
|
<% exports.each do |key, value| %>
|
11
12
|
<%= key.to_s %> : <%= value.is_a?( String ) ? "'#{value}'" : value %>
|
12
13
|
<% end %>
|
14
|
+
<% end %>
|
13
15
|
|
14
16
|
###*
|
15
17
|
* Routes
|
16
18
|
###
|
19
|
+
<% if routes.any? or hashes.any? %>
|
17
20
|
app.routes =
|
18
21
|
<% routes.each do |key, route| %>
|
19
22
|
<%= route.coffee_name %> : ( <%= route.coffee_args %> ) -> "<%= route.coffee_path %>"
|
@@ -21,6 +24,7 @@ app.routes =
|
|
21
24
|
<% hashes.each do |key, route| %>
|
22
25
|
<%= route.coffee_name %> : ( <%= route.coffee_args %> ) -> "<%= route.coffee_path %>"
|
23
26
|
<% end %>
|
27
|
+
<% end %>
|
24
28
|
|
25
29
|
###*
|
26
30
|
* Export
|
data/eastwood.gemspec
CHANGED
@@ -18,17 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
22
|
-
# s.add_development_dependency "rspec"
|
23
|
-
# s.add_runtime_dependency "rest-client"
|
24
|
-
|
25
|
-
s.add_dependency 'rails'
|
21
|
+
s.add_dependency 'rails', '>= 3.1.0'
|
26
22
|
s.add_dependency 'coffee-rails'
|
27
23
|
|
28
24
|
s.add_development_dependency 'sqlite3'
|
29
25
|
s.add_development_dependency 'appraisal', '0.4.1'
|
30
|
-
s.add_development_dependency 'rspec-rails', '2.
|
31
|
-
s.add_development_dependency 'shoulda'
|
26
|
+
s.add_development_dependency 'rspec-rails', '2.9.0'
|
27
|
+
s.add_development_dependency 'shoulda', '3.0.1'
|
32
28
|
s.add_development_dependency 'execjs', '1.3.0'
|
33
29
|
s.add_development_dependency 'simplecov', '0.6.1'
|
34
30
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
|
-
remote: /Users/
|
2
|
+
remote: /Users/jeremyruppel/Git/eastwood
|
3
3
|
specs:
|
4
|
-
eastwood (0.3.
|
4
|
+
eastwood (0.3.6)
|
5
5
|
coffee-rails
|
6
|
-
rails
|
6
|
+
rails (>= 3.1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
@@ -91,20 +91,20 @@ GEM
|
|
91
91
|
rake (0.9.2.2)
|
92
92
|
rdoc (3.12)
|
93
93
|
json (~> 1.4)
|
94
|
-
rspec (2.
|
95
|
-
rspec-core (~> 2.
|
96
|
-
rspec-expectations (~> 2.
|
97
|
-
rspec-mocks (~> 2.
|
98
|
-
rspec-core (2.
|
99
|
-
rspec-expectations (2.
|
100
|
-
diff-lcs (~> 1.1.
|
101
|
-
rspec-mocks (2.
|
102
|
-
rspec-rails (2.
|
94
|
+
rspec (2.9.0)
|
95
|
+
rspec-core (~> 2.9.0)
|
96
|
+
rspec-expectations (~> 2.9.0)
|
97
|
+
rspec-mocks (~> 2.9.0)
|
98
|
+
rspec-core (2.9.0)
|
99
|
+
rspec-expectations (2.9.0)
|
100
|
+
diff-lcs (~> 1.1.3)
|
101
|
+
rspec-mocks (2.9.0)
|
102
|
+
rspec-rails (2.9.0)
|
103
103
|
actionpack (>= 3.0)
|
104
104
|
activesupport (>= 3.0)
|
105
105
|
railties (>= 3.0)
|
106
|
-
rspec (~> 2.
|
107
|
-
shoulda (3.0.
|
106
|
+
rspec (~> 2.9.0)
|
107
|
+
shoulda (3.0.1)
|
108
108
|
shoulda-context (~> 1.0.0)
|
109
109
|
shoulda-matchers (~> 1.0.0)
|
110
110
|
shoulda-context (1.0.0)
|
@@ -133,7 +133,7 @@ DEPENDENCIES
|
|
133
133
|
eastwood!
|
134
134
|
execjs (= 1.3.0)
|
135
135
|
rails (= 3.1.0)
|
136
|
-
rspec-rails (= 2.
|
137
|
-
shoulda
|
136
|
+
rspec-rails (= 2.9.0)
|
137
|
+
shoulda (= 3.0.1)
|
138
138
|
simplecov (= 0.6.1)
|
139
139
|
sqlite3
|
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
|
-
remote: /Users/
|
2
|
+
remote: /Users/jeremyruppel/Git/eastwood
|
3
3
|
specs:
|
4
|
-
eastwood (0.3.
|
4
|
+
eastwood (0.3.6)
|
5
5
|
coffee-rails
|
6
|
-
rails
|
6
|
+
rails (>= 3.1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
@@ -87,20 +87,24 @@ GEM
|
|
87
87
|
rake (0.9.2.2)
|
88
88
|
rdoc (3.12)
|
89
89
|
json (~> 1.4)
|
90
|
-
rspec (2.
|
91
|
-
rspec-core (~> 2.
|
92
|
-
rspec-expectations (~> 2.
|
93
|
-
rspec-mocks (~> 2.
|
94
|
-
rspec-core (2.
|
95
|
-
rspec-expectations (2.
|
96
|
-
diff-lcs (~> 1.1.
|
97
|
-
rspec-mocks (2.
|
98
|
-
rspec-rails (2.
|
90
|
+
rspec (2.9.0)
|
91
|
+
rspec-core (~> 2.9.0)
|
92
|
+
rspec-expectations (~> 2.9.0)
|
93
|
+
rspec-mocks (~> 2.9.0)
|
94
|
+
rspec-core (2.9.0)
|
95
|
+
rspec-expectations (2.9.0)
|
96
|
+
diff-lcs (~> 1.1.3)
|
97
|
+
rspec-mocks (2.9.0)
|
98
|
+
rspec-rails (2.9.0)
|
99
99
|
actionpack (>= 3.0)
|
100
100
|
activesupport (>= 3.0)
|
101
101
|
railties (>= 3.0)
|
102
|
-
rspec (~> 2.
|
103
|
-
shoulda (
|
102
|
+
rspec (~> 2.9.0)
|
103
|
+
shoulda (3.0.1)
|
104
|
+
shoulda-context (~> 1.0.0)
|
105
|
+
shoulda-matchers (~> 1.0.0)
|
106
|
+
shoulda-context (1.0.0)
|
107
|
+
shoulda-matchers (1.0.0)
|
104
108
|
simplecov (0.6.1)
|
105
109
|
multi_json (~> 1.0)
|
106
110
|
simplecov-html (~> 0.5.3)
|
@@ -125,7 +129,7 @@ DEPENDENCIES
|
|
125
129
|
eastwood!
|
126
130
|
execjs (= 1.3.0)
|
127
131
|
rails (= 3.2.0)
|
128
|
-
rspec-rails (= 2.
|
129
|
-
shoulda
|
132
|
+
rspec-rails (= 2.9.0)
|
133
|
+
shoulda (= 3.0.1)
|
130
134
|
simplecov (= 0.6.1)
|
131
135
|
sqlite3
|
data/lib/eastwood/config.rb
CHANGED
@@ -25,9 +25,11 @@ module Eastwood
|
|
25
25
|
end
|
26
26
|
|
27
27
|
mattr_accessor :default_route_format
|
28
|
+
mattr_accessor :javascript_route_style
|
28
29
|
|
29
30
|
def reset!
|
30
|
-
@@default_route_format
|
31
|
+
@@default_route_format = :json
|
32
|
+
@@javascript_route_style = :underscore
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Eastwood
|
2
2
|
module Context
|
3
3
|
class ActionRoute < Struct.new( :route, :format )
|
4
|
+
include RouteHelpers
|
4
5
|
|
5
6
|
def name
|
6
7
|
route.name
|
@@ -15,7 +16,7 @@ module Eastwood
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def coffee_name
|
18
|
-
"#{name}_path"
|
19
|
+
style_for_javascript "#{name}_path"
|
19
20
|
end
|
20
21
|
|
21
22
|
def coffee_args
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Eastwood
|
2
2
|
module Context
|
3
3
|
class HashRoute < Struct.new( :key, :hash )
|
4
|
+
include RouteHelpers
|
4
5
|
|
5
6
|
def name
|
6
7
|
key.to_s
|
@@ -15,7 +16,7 @@ module Eastwood
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def coffee_name
|
18
|
-
"#{name}_hash"
|
19
|
+
style_for_javascript "#{name}_hash"
|
19
20
|
end
|
20
21
|
|
21
22
|
def coffee_args
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Eastwood
|
2
2
|
module Context
|
3
3
|
class JourneyRoute < Struct.new( :route, :format )
|
4
|
+
include RouteHelpers
|
4
5
|
|
5
6
|
def name
|
6
7
|
route.name
|
@@ -15,7 +16,7 @@ module Eastwood
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def coffee_name
|
18
|
-
"#{name}_path"
|
19
|
+
style_for_javascript "#{name}_path"
|
19
20
|
end
|
20
21
|
|
21
22
|
def coffee_args
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Eastwood
|
2
|
+
module Context
|
3
|
+
module RouteHelpers
|
4
|
+
|
5
|
+
def style_for_javascript( route )
|
6
|
+
case Eastwood.javascript_route_style.to_sym
|
7
|
+
when :underscore
|
8
|
+
route.underscore
|
9
|
+
when :camelcase
|
10
|
+
route.camelcase :lower
|
11
|
+
else
|
12
|
+
raise InvalidRouteStyleError
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/eastwood/version.rb
CHANGED
data/lib/eastwood.rb
CHANGED
@@ -8,6 +8,7 @@ module Eastwood
|
|
8
8
|
autoload :ActionRoute, 'eastwood/context/action_route'
|
9
9
|
autoload :JourneyRoute, 'eastwood/context/journey_route'
|
10
10
|
autoload :HashRoute, 'eastwood/context/hash_route'
|
11
|
+
autoload :RouteHelpers, 'eastwood/context/route_helpers'
|
11
12
|
end
|
12
13
|
|
13
14
|
class << self
|
@@ -19,6 +20,9 @@ module Eastwood
|
|
19
20
|
|
20
21
|
include Config
|
21
22
|
include Rails
|
23
|
+
|
24
|
+
class EastwoodError < StandardError; end
|
25
|
+
class InvalidRouteStyleError < EastwoodError; end
|
22
26
|
end
|
23
27
|
|
24
28
|
require 'eastwood/engine' if defined?(::Rails)
|
data/spec/unit/config_spec.rb
CHANGED
@@ -70,4 +70,12 @@ describe Eastwood do
|
|
70
70
|
Eastwood.default_route_format.should eq( :json )
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
describe '#default_route_style' do
|
75
|
+
it { should respond_to( :javascript_route_style ) }
|
76
|
+
|
77
|
+
it 'should default to :underscore' do
|
78
|
+
Eastwood.javascript_route_style.should eq( :underscore )
|
79
|
+
end
|
80
|
+
end
|
73
81
|
end
|
data/spec/unit/route_spec.rb
CHANGED
@@ -13,9 +13,33 @@ shared_examples 'a route adapter' do
|
|
13
13
|
its( :name ){ should eq( 'foo' ) }
|
14
14
|
its( :parts ){ should eq( [ :bar, :baz, :format ] ) }
|
15
15
|
its( :path ){ should eq( '/foo/:bar/:baz.:format' ) }
|
16
|
-
its( :coffee_name ){ should eq( 'foo_path' ) }
|
17
16
|
its( :coffee_args ){ should eq( "bar, baz, format='json'" ) }
|
18
17
|
its( :coffee_path ){ should eq( '/foo/#{bar}/#{baz}#{format}' ) }
|
18
|
+
|
19
|
+
context 'when javascript_route_style is :underscore' do
|
20
|
+
before do
|
21
|
+
Eastwood.javascript_route_style = :underscore
|
22
|
+
end
|
23
|
+
its( :coffee_name ){ should eq( 'foo_path' ) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when javascript_route_style is :camelcase' do
|
27
|
+
before do
|
28
|
+
Eastwood.javascript_route_style = :camelcase
|
29
|
+
end
|
30
|
+
its( :coffee_name ){ should eq( 'fooPath' ) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when javascript_route_style is set to anything else' do
|
34
|
+
before do
|
35
|
+
Eastwood.javascript_route_style = :foo
|
36
|
+
end
|
37
|
+
it 'should raise an error' do
|
38
|
+
expect {
|
39
|
+
subject.coffee_name
|
40
|
+
}.to raise_error Eastwood::InvalidRouteStyleError
|
41
|
+
end
|
42
|
+
end
|
19
43
|
end
|
20
44
|
|
21
45
|
describe Eastwood::Context::ActionRoute do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eastwood
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &120730 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *120730
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: coffee-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &120430 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *120430
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &120180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *120180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: appraisal
|
49
|
-
requirement: &
|
49
|
+
requirement: &119830 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - =
|
@@ -54,32 +54,32 @@ dependencies:
|
|
54
54
|
version: 0.4.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *119830
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec-rails
|
60
|
-
requirement: &
|
60
|
+
requirement: &119480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - =
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 2.
|
65
|
+
version: 2.9.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *119480
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: shoulda
|
71
|
-
requirement: &
|
71
|
+
requirement: &119100 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - =
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 3.0.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *119100
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: execjs
|
82
|
-
requirement: &
|
82
|
+
requirement: &118100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - =
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.3.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *118100
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: simplecov
|
93
|
-
requirement: &
|
93
|
+
requirement: &116830 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - =
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 0.6.1
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *116830
|
102
102
|
description: Start your client side out right
|
103
103
|
email:
|
104
104
|
- jeremy.ruppel@gmail.com
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/eastwood/context/action_route.rb
|
128
128
|
- lib/eastwood/context/hash_route.rb
|
129
129
|
- lib/eastwood/context/journey_route.rb
|
130
|
+
- lib/eastwood/context/route_helpers.rb
|
130
131
|
- lib/eastwood/engine.rb
|
131
132
|
- lib/eastwood/rails.rb
|
132
133
|
- lib/eastwood/version.rb
|