eastwood 0.1.2 → 0.3.1

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.
Files changed (66) hide show
  1. data/.gitignore +7 -0
  2. data/.rvmrc +81 -0
  3. data/Appraisals +3 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +125 -0
  6. data/MIT-LICENSE +1 -1
  7. data/Rakefile +25 -34
  8. data/app/assets/javascripts/eastwood.js.coffee.erb +13 -36
  9. data/eastwood.gemspec +33 -0
  10. data/gemfiles/rails-3.2.0.gemfile +7 -0
  11. data/gemfiles/rails-3.2.0.gemfile.lock +126 -0
  12. data/lib/eastwood/config.rb +26 -0
  13. data/lib/eastwood/context.rb +86 -0
  14. data/lib/eastwood/engine.rb +5 -2
  15. data/lib/eastwood/version.rb +1 -1
  16. data/lib/eastwood.rb +6 -4
  17. data/spec/requests/eastwood_spec.rb +78 -0
  18. data/spec/spec_helper.rb +38 -0
  19. data/spec/support/rails_template.rb +24 -0
  20. data/spec/unit/config_spec.rb +48 -0
  21. data/spec/unit/context_spec.rb +108 -0
  22. data/spec/unit/format_spec.rb +71 -0
  23. metadata +84 -105
  24. data/lib/eastwood/helpers.rb +0 -27
  25. data/lib/eastwood/routes.rb +0 -28
  26. data/lib/tasks/eastwood_tasks.rake +0 -4
  27. data/test/asset_test.rb +0 -9
  28. data/test/dummy/Rakefile +0 -7
  29. data/test/dummy/app/assets/javascripts/application.js +0 -9
  30. data/test/dummy/app/assets/stylesheets/application.css +0 -7
  31. data/test/dummy/app/controllers/application_controller.rb +0 -3
  32. data/test/dummy/app/controllers/resources_controller.rb +0 -2
  33. data/test/dummy/app/helpers/application_helper.rb +0 -2
  34. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  35. data/test/dummy/config/application.rb +0 -45
  36. data/test/dummy/config/boot.rb +0 -10
  37. data/test/dummy/config/database.yml +0 -25
  38. data/test/dummy/config/environment.rb +0 -5
  39. data/test/dummy/config/environments/development.rb +0 -30
  40. data/test/dummy/config/environments/production.rb +0 -60
  41. data/test/dummy/config/environments/test.rb +0 -42
  42. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  43. data/test/dummy/config/initializers/inflections.rb +0 -10
  44. data/test/dummy/config/initializers/mime_types.rb +0 -5
  45. data/test/dummy/config/initializers/secret_token.rb +0 -7
  46. data/test/dummy/config/initializers/session_store.rb +0 -8
  47. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  48. data/test/dummy/config/locales/en.yml +0 -5
  49. data/test/dummy/config/routes.rb +0 -61
  50. data/test/dummy/config.ru +0 -4
  51. data/test/dummy/db/test.sqlite3 +0 -0
  52. data/test/dummy/log/development.log +0 -391
  53. data/test/dummy/log/test.log +0 -409
  54. data/test/dummy/public/404.html +0 -26
  55. data/test/dummy/public/422.html +0 -26
  56. data/test/dummy/public/500.html +0 -26
  57. data/test/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/public/index.html +0 -16
  59. data/test/dummy/script/rails +0 -6
  60. data/test/dummy/tmp/cache/assets/CBD/F90/sprockets%2F6d20c2441898d9799e1cdb5e152b3495 +0 -0
  61. data/test/dummy/tmp/cache/assets/D3E/B90/sprockets%2F9df707a0cc19082ff3e094ca09180fe4 +0 -0
  62. data/test/dummy/tmp/cache/assets/D7F/B10/sprockets%2F9ac097fe24e8c8229522feac6fc9337c +0 -0
  63. data/test/eastwood_test.rb +0 -7
  64. data/test/helpers_test.rb +0 -31
  65. data/test/test_helper.rb +0 -10
  66. /data/{test/dummy/db/development.sqlite3 → spec/rails/.gitkeep} +0 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
7
+ spec/rails/rails-*
data/.rvmrc ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.3-p0@eastwood"
8
+
9
+ #
10
+ # Uncomment the following lines if you want to verify rvm version per project
11
+ #
12
+ # rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+ #
18
+
19
+ #
20
+ # Uncomment following line if you want options to be set only for given project.
21
+ #
22
+ # PROJECT_JRUBY_OPTS=( --1.9 )
23
+ #
24
+ # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
25
+ #
26
+ # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
27
+ #
28
+
29
+ #
30
+ # First we attempt to load the desired environment directly from the environment
31
+ # file. This is very fast and efficient compared to running through the entire
32
+ # CLI and selector. If you want feedback on which environment was used then
33
+ # insert the word 'use' after --create as this triggers verbose mode.
34
+ #
35
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
36
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
37
+ then
38
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
39
+
40
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
41
+ then
42
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
43
+ fi
44
+ else
45
+ # If the environment file has not yet been created, use the RVM CLI to select.
46
+ if ! rvm --create "$environment_id"
47
+ then
48
+ echo "Failed to create RVM environment '${environment_id}'."
49
+ return 1
50
+ fi
51
+ fi
52
+
53
+ #
54
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
55
+ # it be automatically loaded. Uncomment the following and adjust the filename if
56
+ # necessary.
57
+ #
58
+ # filename=".gems"
59
+ # if [[ -s "$filename" ]]
60
+ # then
61
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
62
+ # fi
63
+
64
+ # If you use bundler, this might be useful to you:
65
+ # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
66
+ # then
67
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
68
+ # gem install bundler
69
+ # fi
70
+ # if [[ -s Gemfile ]] && command -v bundle
71
+ # then
72
+ # bundle install
73
+ # fi
74
+
75
+ if [[ $- == *i* ]] # check for interactive shells
76
+ then
77
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
78
+ else
79
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
80
+ fi
81
+
data/Appraisals ADDED
@@ -0,0 +1,3 @@
1
+ appraise 'rails-3.2.0' do
2
+ gem 'rails', '3.2.0'
3
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in wingman.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eastwood (0.3.0)
5
+ coffee-rails
6
+ rails
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.1)
12
+ actionpack (= 3.2.1)
13
+ mail (~> 2.4.0)
14
+ actionpack (3.2.1)
15
+ activemodel (= 3.2.1)
16
+ activesupport (= 3.2.1)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.1)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.1)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.1.2)
24
+ activemodel (3.2.1)
25
+ activesupport (= 3.2.1)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.1)
28
+ activemodel (= 3.2.1)
29
+ activesupport (= 3.2.1)
30
+ arel (~> 3.0.0)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.1)
33
+ activemodel (= 3.2.1)
34
+ activesupport (= 3.2.1)
35
+ activesupport (3.2.1)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ appraisal (0.4.1)
39
+ bundler
40
+ rake
41
+ arel (3.0.2)
42
+ builder (3.0.0)
43
+ coffee-rails (3.2.2)
44
+ coffee-script (>= 2.2.0)
45
+ railties (~> 3.2.0)
46
+ coffee-script (2.2.0)
47
+ coffee-script-source
48
+ execjs
49
+ coffee-script-source (1.2.0)
50
+ diff-lcs (1.1.3)
51
+ erubis (2.7.0)
52
+ execjs (1.3.0)
53
+ multi_json (~> 1.0)
54
+ hike (1.2.1)
55
+ i18n (0.6.0)
56
+ journey (1.0.3)
57
+ json (1.6.5)
58
+ mail (2.4.1)
59
+ i18n (>= 0.4.0)
60
+ mime-types (~> 1.16)
61
+ treetop (~> 1.4.8)
62
+ mime-types (1.17.2)
63
+ multi_json (1.1.0)
64
+ polyglot (0.3.3)
65
+ rack (1.4.1)
66
+ rack-cache (1.1)
67
+ rack (>= 0.4)
68
+ rack-ssl (1.3.2)
69
+ rack
70
+ rack-test (0.6.1)
71
+ rack (>= 1.0)
72
+ rails (3.2.1)
73
+ actionmailer (= 3.2.1)
74
+ actionpack (= 3.2.1)
75
+ activerecord (= 3.2.1)
76
+ activeresource (= 3.2.1)
77
+ activesupport (= 3.2.1)
78
+ bundler (~> 1.0)
79
+ railties (= 3.2.1)
80
+ railties (3.2.1)
81
+ actionpack (= 3.2.1)
82
+ activesupport (= 3.2.1)
83
+ rack-ssl (~> 1.3.2)
84
+ rake (>= 0.8.7)
85
+ rdoc (~> 3.4)
86
+ thor (~> 0.14.6)
87
+ rake (0.9.2.2)
88
+ rdoc (3.12)
89
+ json (~> 1.4)
90
+ rspec (2.8.0)
91
+ rspec-core (~> 2.8.0)
92
+ rspec-expectations (~> 2.8.0)
93
+ rspec-mocks (~> 2.8.0)
94
+ rspec-core (2.8.0)
95
+ rspec-expectations (2.8.0)
96
+ diff-lcs (~> 1.1.2)
97
+ rspec-mocks (2.8.0)
98
+ rspec-rails (2.8.1)
99
+ actionpack (>= 3.0)
100
+ activesupport (>= 3.0)
101
+ railties (>= 3.0)
102
+ rspec (~> 2.8.0)
103
+ shoulda (2.11.3)
104
+ sprockets (2.1.2)
105
+ hike (~> 1.2)
106
+ rack (~> 1.0)
107
+ tilt (~> 1.1, != 1.3.0)
108
+ sqlite3 (1.3.5)
109
+ thor (0.14.6)
110
+ tilt (1.3.3)
111
+ treetop (1.4.10)
112
+ polyglot
113
+ polyglot (>= 0.3.1)
114
+ tzinfo (0.3.31)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ appraisal (= 0.4.1)
121
+ eastwood!
122
+ execjs (= 1.3.0)
123
+ rspec-rails (= 2.8.1)
124
+ shoulda
125
+ sqlite3
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2011 Jeremy Ruppel
1
+ Copyright 2012 Jeremy Ruppel
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,43 +1,34 @@
1
1
  #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Eastwood'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
2
 
3
+ require 'bundler/gem_tasks'
4
+ require 'appraisal'
5
+ require 'rspec/core/rake_task'
24
6
 
25
- Bundler::GemHelper.install_tasks
7
+ namespace :eastwood do
26
8
 
27
- require 'rake/testtask'
9
+ desc "Set up current environment variables"
10
+ task :env do
11
+ require 'rails/version'
12
+ ENV[ 'EASTWOOD_RAILS_NAME' ] = "rails-#{Rails::VERSION::STRING}"
13
+ ENV[ 'EASTWOOD_RAILS_PATH' ] = "spec/rails/#{ENV[ 'EASTWOOD_RAILS_NAME' ]}"
14
+ end
28
15
 
29
- Rake::TestTask.new(:test => :'cache:clear') do |t|
30
- t.libs << 'lib'
31
- t.libs << 'test'
32
- t.pattern = 'test/**/*_test.rb'
33
- t.verbose = false
34
- end
16
+ desc "Remove all test rails apps"
17
+ task :clean => [ :env ] do
18
+ Dir[ 'spec/rails/rails-*' ].each do |app|
19
+ FileUtils.rm_rf app
20
+ end
21
+ end
35
22
 
36
- namespace :cache do
37
- desc "Clear out the cache"
38
- task :clear do
39
- FileUtils.rm_rf 'test/dummy/tmp/cache'
23
+ desc "Create a test rails app if necessary"
24
+ task :rails do
25
+ if File.exist? ENV[ 'EASTWOOD_RAILS_PATH' ]
26
+ puts "Using existing #{ENV[ 'EASTWOOD_RAILS_NAME' ]} app"
27
+ else
28
+ sh "bundle exec rails new #{ENV[ 'EASTWOOD_RAILS_PATH' ]} -m spec/support/rails_template.rb"
29
+ end
40
30
  end
31
+
41
32
  end
42
33
 
43
- task :default => :test
34
+ RSpec::Core::RakeTask.new :spec => [ :'eastwood:env', :'eastwood:rails' ]
@@ -1,49 +1,26 @@
1
1
  ###*
2
- * <%= application_name %> Client Settings
3
- *
4
- * Generated automatically by Eastwood and the Rails <%= Rails::version %> Asset Pipeline on <%= DateTime.now %>
2
+ * eastwood.js - <%= app %>
5
3
  ###
6
- app = { env : '<%= env %>', routes : root_path : -> "/" }
4
+ app = { env : "<%= env %>", routes : { } }
7
5
 
8
- <% if named_routes.any? %>
9
6
  ###*
10
- * Server-side routing
7
+ * Routes
11
8
  ###
12
- <% named_routes.each do |r| %>
13
- # name: <%= r.name %>
14
- # conditions: <%= r.conditions %>
15
- # defaults: <%= r.defaults %>
16
- # path: <%= r.path %>
17
- # requirements: <%= r.requirements %>
18
- # verb: <%= r.verb %>
19
- # segment_keys: <%= r.segment_keys %>
20
-
21
- <% unless r.segment_keys.empty? %> # root_path is already taken care of
22
-
23
- app.routes.<%= r.name %>_path = ( <%= r.segment_keys.join ', ' %>='json' ) ->
24
- "<%= r.path.spec.to_s.delete( '()' ).gsub /:(\w+)/, '#{\1}' %>"
25
-
26
- <% end %>
27
- <% end %>
9
+ <% routes.each do |key, route| %>
10
+ app.routes.<%= route.coffee_name %> = ( <%= route.coffee_args %> ) ->
11
+ "<%= route.coffee_path %>"
28
12
  <% end %>
29
13
 
30
- <% if client_routes.any? %>
31
14
  ###*
32
- * Client-side routing
15
+ * Hashes
33
16
  ###
34
- <% client_routes.each do |key, r| %>
35
-
36
- <% if r.segment_keys.empty? %>
37
- app.routes.<%= r.name %>_hash = ->
38
- <% else %>
39
- app.routes.<%= r.name %>_hash = ( <%= r.segment_keys.join ', ' %> ) ->
40
- <% end %>
41
- "<%= r.path.gsub /:(\w+)/, '#{\1}' %>"
42
-
43
- <% end %>
17
+ <% hashes.each do |key, route| %>
18
+ app.routes.<%= route.coffee_name %> = ( <%= route.coffee_args %> ) ->
19
+ "<%= route.coffee_path %>"
44
20
  <% end %>
45
21
 
46
22
  ###*
47
- * Export that shit!
23
+ * Export
48
24
  ###
49
- window.<%= application_name %> = app
25
+ @window ||= { } # For ExecJS
26
+ @window.<%= app %> = app
data/eastwood.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "eastwood/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "eastwood"
7
+ s.version = Eastwood::VERSION
8
+ s.authors = ["Jeremy Ruppel"]
9
+ s.email = ["jeremy.ruppel@gmail.com"]
10
+ s.homepage = "https://github.com/jeremyruppel/eastwood"
11
+ s.summary = %q{Start your client side out right}
12
+ s.description = %q{Start your client side out right}
13
+
14
+ s.rubyforge_project = "eastwood"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+
25
+ s.add_dependency 'rails'
26
+ s.add_dependency 'coffee-rails'
27
+
28
+ s.add_development_dependency 'sqlite3'
29
+ s.add_development_dependency 'appraisal', '0.4.1'
30
+ s.add_development_dependency 'rspec-rails', '2.8.1'
31
+ s.add_development_dependency 'shoulda'
32
+ s.add_development_dependency 'execjs', '1.3.0'
33
+ end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.2.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: /Users/jeremyruppel/Git/eastwood
3
+ specs:
4
+ eastwood (0.3.1)
5
+ coffee-rails
6
+ rails
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.0)
12
+ actionpack (= 3.2.0)
13
+ mail (~> 2.4.0)
14
+ actionpack (3.2.0)
15
+ activemodel (= 3.2.0)
16
+ activesupport (= 3.2.0)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.0)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.1)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.1.2)
24
+ activemodel (3.2.0)
25
+ activesupport (= 3.2.0)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.0)
28
+ activemodel (= 3.2.0)
29
+ activesupport (= 3.2.0)
30
+ arel (~> 3.0.0)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.0)
33
+ activemodel (= 3.2.0)
34
+ activesupport (= 3.2.0)
35
+ activesupport (3.2.0)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ appraisal (0.4.1)
39
+ bundler
40
+ rake
41
+ arel (3.0.2)
42
+ builder (3.0.0)
43
+ coffee-rails (3.2.2)
44
+ coffee-script (>= 2.2.0)
45
+ railties (~> 3.2.0)
46
+ coffee-script (2.2.0)
47
+ coffee-script-source
48
+ execjs
49
+ coffee-script-source (1.2.0)
50
+ diff-lcs (1.1.3)
51
+ erubis (2.7.0)
52
+ execjs (1.3.0)
53
+ multi_json (~> 1.0)
54
+ hike (1.2.1)
55
+ i18n (0.6.0)
56
+ journey (1.0.3)
57
+ json (1.6.5)
58
+ mail (2.4.1)
59
+ i18n (>= 0.4.0)
60
+ mime-types (~> 1.16)
61
+ treetop (~> 1.4.8)
62
+ mime-types (1.17.2)
63
+ multi_json (1.1.0)
64
+ polyglot (0.3.3)
65
+ rack (1.4.1)
66
+ rack-cache (1.1)
67
+ rack (>= 0.4)
68
+ rack-ssl (1.3.2)
69
+ rack
70
+ rack-test (0.6.1)
71
+ rack (>= 1.0)
72
+ rails (3.2.0)
73
+ actionmailer (= 3.2.0)
74
+ actionpack (= 3.2.0)
75
+ activerecord (= 3.2.0)
76
+ activeresource (= 3.2.0)
77
+ activesupport (= 3.2.0)
78
+ bundler (~> 1.0)
79
+ railties (= 3.2.0)
80
+ railties (3.2.0)
81
+ actionpack (= 3.2.0)
82
+ activesupport (= 3.2.0)
83
+ rack-ssl (~> 1.3.2)
84
+ rake (>= 0.8.7)
85
+ rdoc (~> 3.4)
86
+ thor (~> 0.14.6)
87
+ rake (0.9.2.2)
88
+ rdoc (3.12)
89
+ json (~> 1.4)
90
+ rspec (2.8.0)
91
+ rspec-core (~> 2.8.0)
92
+ rspec-expectations (~> 2.8.0)
93
+ rspec-mocks (~> 2.8.0)
94
+ rspec-core (2.8.0)
95
+ rspec-expectations (2.8.0)
96
+ diff-lcs (~> 1.1.2)
97
+ rspec-mocks (2.8.0)
98
+ rspec-rails (2.8.1)
99
+ actionpack (>= 3.0)
100
+ activesupport (>= 3.0)
101
+ railties (>= 3.0)
102
+ rspec (~> 2.8.0)
103
+ shoulda (2.11.3)
104
+ sprockets (2.1.2)
105
+ hike (~> 1.2)
106
+ rack (~> 1.0)
107
+ tilt (~> 1.1, != 1.3.0)
108
+ sqlite3 (1.3.5)
109
+ thor (0.14.6)
110
+ tilt (1.3.3)
111
+ treetop (1.4.10)
112
+ polyglot
113
+ polyglot (>= 0.3.1)
114
+ tzinfo (0.3.31)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ appraisal (= 0.4.1)
121
+ eastwood!
122
+ execjs (= 1.3.0)
123
+ rails (= 3.2.0)
124
+ rspec-rails (= 2.8.1)
125
+ shoulda
126
+ sqlite3
@@ -0,0 +1,26 @@
1
+ module Eastwood
2
+ module Config
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ reset!
7
+ end
8
+
9
+ module ClassMethods
10
+
11
+ def hash( name, route )
12
+ hashes[ name ] = route
13
+ end
14
+
15
+ def hashes
16
+ @@hashes ||= Hash.new
17
+ end
18
+
19
+ mattr_accessor :default_route_format
20
+
21
+ def reset!
22
+ @@default_route_format = :json
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,86 @@
1
+ module Eastwood
2
+ module Context
3
+
4
+ class Route < Struct.new( :route, :format )
5
+ def name
6
+ route.name
7
+ end
8
+ def parts
9
+ route.parts
10
+ end
11
+ def path
12
+ route.path.spec.to_s.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 HashRoute < Struct.new( :key, :hash )
26
+ def name
27
+ key.to_s
28
+ end
29
+ def parts
30
+ hash.scan( /:(\w+)/ ).flatten.map &:to_sym
31
+ end
32
+ def path
33
+ hash
34
+ end
35
+ def coffee_name
36
+ "#{name}_hash"
37
+ end
38
+ def coffee_args
39
+ parts.join ', '
40
+ end
41
+ def coffee_path
42
+ path.gsub /:(\w+)/, '#{\1}'
43
+ end
44
+ end
45
+
46
+ def app
47
+ Rails.application.class.name.split( '::' ).first
48
+ end
49
+
50
+ def env
51
+ Rails.env
52
+ end
53
+
54
+ def routes
55
+ # TODO would kind of like to find a better way to transform
56
+ # these values into my routes, but keep as a hash
57
+ # http://www.ruby-forum.com/topic/185611
58
+ named_routes.merge( named_routes ) { |key, route| Route.new route, route_format }
59
+ end
60
+
61
+ def hashes
62
+ # TODO would kind of like to find a better way to transform
63
+ # these values into my routes, but keep as a hash
64
+ # http://www.ruby-forum.com/topic/185611
65
+ named_hashes.merge( named_hashes ){ |key, hash| HashRoute.new key, hash }
66
+ end
67
+
68
+ def route_format
69
+ omit_route_format? ? '' : ".#{Eastwood.default_route_format.to_s}"
70
+ end
71
+
72
+ protected
73
+
74
+ def omit_route_format?
75
+ [ '', false ].include? Eastwood.default_route_format
76
+ end
77
+
78
+ def named_hashes
79
+ Eastwood.hashes
80
+ end
81
+
82
+ def named_routes
83
+ Rails.application.routes.named_routes.routes
84
+ end
85
+ end
86
+ end
@@ -1,10 +1,13 @@
1
1
  module Eastwood
2
2
  class Engine < Rails::Engine
3
-
3
+
4
4
  initializer 'eastwood.setup' do |app|
5
+ # include helpers in the sprockets context
5
6
  app.assets.context_class.instance_eval do
6
- include Eastwood::Helpers
7
+ include Eastwood::Context
7
8
  end
9
+ # watch for changes in eastwood initializer
10
+ app.config.watchable_files << 'config/initializers/eastwood.rb'
8
11
  end
9
12
  end
10
13
  end
@@ -1,3 +1,3 @@
1
1
  module Eastwood
2
- VERSION = "0.1.2"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/eastwood.rb CHANGED
@@ -1,14 +1,16 @@
1
1
  module Eastwood
2
+ autoload :Config, 'eastwood/config'
3
+ autoload :Context, 'eastwood/context'
2
4
  autoload :Engine, 'eastwood/engine'
3
- autoload :Helpers, 'eastwood/helpers'
4
- autoload :Routes, 'eastwood/routes'
5
5
 
6
6
  class << self
7
7
 
8
- def routes
9
- @routes ||= Routes.new
8
+ def configure
9
+ yield self
10
10
  end
11
11
  end
12
+
13
+ include Config
12
14
  end
13
15
 
14
16
  require 'eastwood/engine' if defined?(Rails)