eastwood 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Appraisals CHANGED
@@ -1,3 +1,6 @@
1
+ appraise 'rails-3.1.0' do
2
+ gem 'rails', '3.1.0'
3
+ end
1
4
  appraise 'rails-3.2.0' do
2
5
  gem 'rails', '3.2.0'
3
6
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eastwood (0.3.0)
4
+ eastwood (0.3.2)
5
5
  coffee-rails
6
6
  rails
7
7
 
@@ -22,5 +22,4 @@ app.routes.<%= route.coffee_name %> = ( <%= route.coffee_args %> ) ->
22
22
  ###*
23
23
  * Export
24
24
  ###
25
- @window ||= { } # For ExecJS
26
- @window.<%= app %> = app
25
+ <%= target %>.<%= app %> = app
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.1.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,134 @@
1
+ PATH
2
+ remote: /Users/jeremyruppel/Git/eastwood
3
+ specs:
4
+ eastwood (0.3.2)
5
+ coffee-rails
6
+ rails
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.1.0)
12
+ actionpack (= 3.1.0)
13
+ mail (~> 2.3.0)
14
+ actionpack (3.1.0)
15
+ activemodel (= 3.1.0)
16
+ activesupport (= 3.1.0)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6)
20
+ rack (~> 1.3.2)
21
+ rack-cache (~> 1.0.3)
22
+ rack-mount (~> 0.8.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.0.0)
25
+ activemodel (3.1.0)
26
+ activesupport (= 3.1.0)
27
+ bcrypt-ruby (~> 3.0.0)
28
+ builder (~> 3.0.0)
29
+ i18n (~> 0.6)
30
+ activerecord (3.1.0)
31
+ activemodel (= 3.1.0)
32
+ activesupport (= 3.1.0)
33
+ arel (~> 2.2.1)
34
+ tzinfo (~> 0.3.29)
35
+ activeresource (3.1.0)
36
+ activemodel (= 3.1.0)
37
+ activesupport (= 3.1.0)
38
+ activesupport (3.1.0)
39
+ multi_json (~> 1.0)
40
+ appraisal (0.4.1)
41
+ bundler
42
+ rake
43
+ arel (2.2.3)
44
+ bcrypt-ruby (3.0.1)
45
+ builder (3.0.0)
46
+ coffee-rails (3.1.1)
47
+ coffee-script (>= 2.2.0)
48
+ railties (~> 3.1.0)
49
+ coffee-script (2.2.0)
50
+ coffee-script-source
51
+ execjs
52
+ coffee-script-source (1.2.0)
53
+ diff-lcs (1.1.3)
54
+ erubis (2.7.0)
55
+ execjs (1.3.0)
56
+ multi_json (~> 1.0)
57
+ hike (1.2.1)
58
+ i18n (0.6.0)
59
+ json (1.6.5)
60
+ mail (2.3.0)
61
+ i18n (>= 0.4.0)
62
+ mime-types (~> 1.16)
63
+ treetop (~> 1.4.8)
64
+ mime-types (1.17.2)
65
+ multi_json (1.1.0)
66
+ polyglot (0.3.3)
67
+ rack (1.3.6)
68
+ rack-cache (1.0.3)
69
+ rack (>= 0.4)
70
+ rack-mount (0.8.3)
71
+ rack (>= 1.0.0)
72
+ rack-ssl (1.3.2)
73
+ rack
74
+ rack-test (0.6.1)
75
+ rack (>= 1.0)
76
+ rails (3.1.0)
77
+ actionmailer (= 3.1.0)
78
+ actionpack (= 3.1.0)
79
+ activerecord (= 3.1.0)
80
+ activeresource (= 3.1.0)
81
+ activesupport (= 3.1.0)
82
+ bundler (~> 1.0)
83
+ railties (= 3.1.0)
84
+ railties (3.1.0)
85
+ actionpack (= 3.1.0)
86
+ activesupport (= 3.1.0)
87
+ rack-ssl (~> 1.3.2)
88
+ rake (>= 0.8.7)
89
+ rdoc (~> 3.4)
90
+ thor (~> 0.14.6)
91
+ rake (0.9.2.2)
92
+ rdoc (3.12)
93
+ json (~> 1.4)
94
+ rspec (2.8.0)
95
+ rspec-core (~> 2.8.0)
96
+ rspec-expectations (~> 2.8.0)
97
+ rspec-mocks (~> 2.8.0)
98
+ rspec-core (2.8.0)
99
+ rspec-expectations (2.8.0)
100
+ diff-lcs (~> 1.1.2)
101
+ rspec-mocks (2.8.0)
102
+ rspec-rails (2.8.1)
103
+ actionpack (>= 3.0)
104
+ activesupport (>= 3.0)
105
+ railties (>= 3.0)
106
+ rspec (~> 2.8.0)
107
+ shoulda (3.0.0)
108
+ shoulda-context (~> 1.0.0)
109
+ shoulda-matchers (~> 1.0.0)
110
+ shoulda-context (1.0.0)
111
+ shoulda-matchers (1.0.0)
112
+ sprockets (2.0.3)
113
+ hike (~> 1.2)
114
+ rack (~> 1.0)
115
+ tilt (~> 1.1, != 1.3.0)
116
+ sqlite3 (1.3.5)
117
+ thor (0.14.6)
118
+ tilt (1.3.3)
119
+ treetop (1.4.10)
120
+ polyglot
121
+ polyglot (>= 0.3.1)
122
+ tzinfo (0.3.31)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ appraisal (= 0.4.1)
129
+ eastwood!
130
+ execjs (= 1.3.0)
131
+ rails (= 3.1.0)
132
+ rspec-rails (= 2.8.1)
133
+ shoulda
134
+ sqlite3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/jeremyruppel/Git/eastwood
3
3
  specs:
4
- eastwood (0.3.1)
4
+ eastwood (0.3.2)
5
5
  coffee-rails
6
6
  rails
7
7
 
@@ -1,7 +1,28 @@
1
1
  module Eastwood
2
2
  module Context
3
3
 
4
- class Route < Struct.new( :route, :format )
4
+ class ActionRoute < Struct.new( :route, :format )
5
+ def name
6
+ route.name
7
+ end
8
+ def parts
9
+ route.segment_keys
10
+ end
11
+ def path
12
+ route.path.delete '()'
13
+ end
14
+ def coffee_name
15
+ "#{name}_path"
16
+ end
17
+ def coffee_args
18
+ parts.any? ? "#{parts.join( ', ' )}='#{format}'" : ''
19
+ end
20
+ def coffee_path
21
+ path.delete( '.' ).gsub /:(\w+)/, '#{\1}'
22
+ end
23
+ end
24
+
25
+ class JourneyRoute < Struct.new( :route, :format )
5
26
  def name
6
27
  route.name
7
28
  end
@@ -44,18 +65,22 @@ module Eastwood
44
65
  end
45
66
 
46
67
  def app
47
- Rails.application.class.name.split( '::' ).first
68
+ Eastwood.application_name
48
69
  end
49
70
 
50
71
  def env
51
- Rails.env
72
+ Eastwood.env
73
+ end
74
+
75
+ def target
76
+ env === 'test' ? '( @window = { } )' : 'window'
52
77
  end
53
78
 
54
79
  def routes
55
80
  # TODO would kind of like to find a better way to transform
56
81
  # these values into my routes, but keep as a hash
57
82
  # http://www.ruby-forum.com/topic/185611
58
- named_routes.merge( named_routes ) { |key, route| Route.new route, route_format }
83
+ named_routes.merge( named_routes ) { |key, route| route_class.new route, route_format }
59
84
  end
60
85
 
61
86
  def hashes
@@ -71,6 +96,10 @@ module Eastwood
71
96
 
72
97
  protected
73
98
 
99
+ def route_class
100
+ defined?(Journey) ? JourneyRoute : ActionRoute
101
+ end
102
+
74
103
  def omit_route_format?
75
104
  [ '', false ].include? Eastwood.default_route_format
76
105
  end
@@ -80,7 +109,7 @@ module Eastwood
80
109
  end
81
110
 
82
111
  def named_routes
83
- Rails.application.routes.named_routes.routes
112
+ Eastwood.named_routes
84
113
  end
85
114
  end
86
115
  end
@@ -1,5 +1,5 @@
1
1
  module Eastwood
2
- class Engine < Rails::Engine
2
+ class Engine < ::Rails::Engine
3
3
 
4
4
  initializer 'eastwood.setup' do |app|
5
5
  # include helpers in the sprockets context
@@ -7,7 +7,9 @@ module Eastwood
7
7
  include Eastwood::Context
8
8
  end
9
9
  # watch for changes in eastwood initializer
10
- app.config.watchable_files << 'config/initializers/eastwood.rb'
10
+ if app.config.respond_to? :watchable_files
11
+ app.config.watchable_files << 'config/initializers/eastwood.rb'
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,20 @@
1
+ module Eastwood
2
+ module Rails
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+
7
+ def application_name
8
+ ::Rails.application.class.name.split( '::' ).first
9
+ end
10
+
11
+ def env
12
+ ::Rails.env
13
+ end
14
+
15
+ def named_routes
16
+ ::Rails.application.routes.named_routes.routes
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Eastwood
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/lib/eastwood.rb CHANGED
@@ -2,6 +2,7 @@ module Eastwood
2
2
  autoload :Config, 'eastwood/config'
3
3
  autoload :Context, 'eastwood/context'
4
4
  autoload :Engine, 'eastwood/engine'
5
+ autoload :Rails, 'eastwood/rails'
5
6
 
6
7
  class << self
7
8
 
@@ -11,6 +12,7 @@ module Eastwood
11
12
  end
12
13
 
13
14
  include Config
15
+ include Rails
14
16
  end
15
17
 
16
- require 'eastwood/engine' if defined?(Rails)
18
+ require 'eastwood/engine' if defined?(::Rails)
@@ -7,7 +7,7 @@ describe 'eastwood.js' do
7
7
  end
8
8
 
9
9
  let( :context ){ ExecJS.compile response.body }
10
- let( :routes ){ "window.Rails320.routes" }
10
+ let( :routes ){ "window.#{Eastwood.application_name}.routes" }
11
11
 
12
12
  describe 'the response' do
13
13
  subject { response }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'the Sprockets context class' do
4
- subject { Rails.application.assets.context_class.new nil, nil, nil }
4
+ subject { ::Rails.application.assets.context_class.new nil, nil, nil }
5
5
 
6
6
  it 'should have Eastwood::Context mixed in' do
7
7
  subject.class.ancestors.should include( Eastwood::Context )
@@ -9,12 +9,20 @@ describe 'the Sprockets context class' do
9
9
 
10
10
  describe '#app' do
11
11
  it { should respond_to( :app ) }
12
- its( :app ){ should eq( Rails.application.class.name.split( '::' ).first ) }
12
+
13
+ it 'should delegate to Eastwood.application_name' do
14
+ Eastwood.should_receive :application_name
15
+ subject.app
16
+ end
13
17
  end
14
18
 
15
19
  describe '#env' do
16
20
  it { should respond_to( :env ) }
17
- its( :env ){ should eq( Rails.env ) }
21
+
22
+ it 'should delegate to Eastwood.env' do
23
+ Eastwood.should_receive :env
24
+ subject.env
25
+ end
18
26
  end
19
27
 
20
28
  describe '#routes' do
@@ -24,11 +32,41 @@ describe 'the Sprockets context class' do
24
32
 
25
33
  describe '#hashes' do
26
34
  it { should respond_to( :hashes ) }
35
+ its( :hashes ){ should be_a( Hash ) }
36
+ end
37
+
38
+ describe '#target' do
39
+ it { should respond_to( :target ) }
40
+
41
+ context 'when #env is development' do
42
+ before do
43
+ subject.stub( :env ){ 'development' }
44
+ end
45
+ its( :target ){ should eq( 'window' ) }
46
+ end
47
+ context 'when #env is test' do
48
+ before do
49
+ subject.stub( :env ){ 'test' }
50
+ end
51
+ its( :target ){ should eq( '( @window = { } )' ) }
52
+ end
53
+ context 'when #env is production' do
54
+ before do
55
+ subject.stub( :env ){ 'production' }
56
+ end
57
+ its( :target ){ should eq( 'window' ) }
58
+ end
59
+ context 'when #env is something completely different' do
60
+ before do
61
+ subject.stub( :env ){ 'foo' }
62
+ end
63
+ its( :target ){ should eq( 'window' ) }
64
+ end
27
65
  end
28
66
  end
29
67
 
30
68
  describe 'routes' do
31
- let( :context ){ Rails.application.assets.context_class.new nil, nil, nil }
69
+ let( :context ){ ::Rails.application.assets.context_class.new nil, nil, nil }
32
70
 
33
71
  describe 'eastwood_engine' do
34
72
  subject { context.routes[ :eastwood_engine ] }
@@ -68,7 +106,7 @@ describe 'routes' do
68
106
  end
69
107
 
70
108
  describe 'hashes' do
71
- let( :context ){ Rails.application.assets.context_class.new nil, nil, nil }
109
+ let( :context ){ ::Rails.application.assets.context_class.new nil, nil, nil }
72
110
 
73
111
  describe 'home' do
74
112
  subject { context.hashes[ :home ] }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'route formatting' do
4
4
 
5
5
  describe 'setting the default route format' do
6
- subject { Rails.application.assets.context_class.new nil, nil, nil }
6
+ subject { ::Rails.application.assets.context_class.new nil, nil, nil }
7
7
 
8
8
  it { should respond_to( :route_format ) }
9
9
 
@@ -45,7 +45,7 @@ describe 'route formatting' do
45
45
  end
46
46
 
47
47
  describe 'including the format in routes' do
48
- let( :context ){ Rails.application.assets.context_class.new nil, nil, nil }
48
+ let( :context ){ ::Rails.application.assets.context_class.new nil, nil, nil }
49
49
  subject { context.routes[ :match ] }
50
50
 
51
51
  context 'default format' do
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Eastwood do
4
+
5
+ describe '#application_name' do
6
+ it { should respond_to( :application_name ) }
7
+ its( :application_name ){ should eq( ::Rails.application.class.name.split( '::' ).first ) }
8
+ end
9
+
10
+ describe '#env' do
11
+ it { should respond_to( :env ) }
12
+
13
+ it 'should delegate to the rails env' do
14
+ ::Rails.should_receive :env
15
+ Eastwood.env
16
+ end
17
+ end
18
+
19
+ describe '#named_routes' do
20
+ it { should respond_to( :named_routes ) }
21
+
22
+ it 'should delegate to the rails named routes' do
23
+ ::Rails.application.routes.named_routes.should_receive :routes
24
+ Eastwood.named_routes
25
+ end
26
+ end
27
+ end
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.1
4
+ version: 0.3.2
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-02-25 00:00:00.000000000 Z
12
+ date: 2012-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &136100 !ruby/object:Gem::Requirement
16
+ requirement: &97190 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *136100
24
+ version_requirements: *97190
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: coffee-rails
27
- requirement: &135210 !ruby/object:Gem::Requirement
27
+ requirement: &96550 !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: *135210
35
+ version_requirements: *96550
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &134720 !ruby/object:Gem::Requirement
38
+ requirement: &95890 !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: *134720
46
+ version_requirements: *95890
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: appraisal
49
- requirement: &134220 !ruby/object:Gem::Requirement
49
+ requirement: &94610 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.4.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *134220
57
+ version_requirements: *94610
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec-rails
60
- requirement: &126450 !ruby/object:Gem::Requirement
60
+ requirement: &93320 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.8.1
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *126450
68
+ version_requirements: *93320
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shoulda
71
- requirement: &125110 !ruby/object:Gem::Requirement
71
+ requirement: &92860 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *125110
79
+ version_requirements: *92860
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: execjs
82
- requirement: &123910 !ruby/object:Gem::Requirement
82
+ requirement: &92110 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - =
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 1.3.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *123910
90
+ version_requirements: *92110
91
91
  description: Start your client side out right
92
92
  email:
93
93
  - jeremy.ruppel@gmail.com
@@ -105,12 +105,15 @@ files:
105
105
  - Rakefile
106
106
  - app/assets/javascripts/eastwood.js.coffee.erb
107
107
  - eastwood.gemspec
108
+ - gemfiles/rails-3.1.0.gemfile
109
+ - gemfiles/rails-3.1.0.gemfile.lock
108
110
  - gemfiles/rails-3.2.0.gemfile
109
111
  - gemfiles/rails-3.2.0.gemfile.lock
110
112
  - lib/eastwood.rb
111
113
  - lib/eastwood/config.rb
112
114
  - lib/eastwood/context.rb
113
115
  - lib/eastwood/engine.rb
116
+ - lib/eastwood/rails.rb
114
117
  - lib/eastwood/version.rb
115
118
  - spec/rails/.gitkeep
116
119
  - spec/requests/eastwood_spec.rb
@@ -119,6 +122,7 @@ files:
119
122
  - spec/unit/config_spec.rb
120
123
  - spec/unit/context_spec.rb
121
124
  - spec/unit/format_spec.rb
125
+ - spec/unit/rails_spec.rb
122
126
  homepage: https://github.com/jeremyruppel/eastwood
123
127
  licenses: []
124
128
  post_install_message:
@@ -151,3 +155,4 @@ test_files:
151
155
  - spec/unit/config_spec.rb
152
156
  - spec/unit/context_spec.rb
153
157
  - spec/unit/format_spec.rb
158
+ - spec/unit/rails_spec.rb