Permalink
Browse files

automatic import from ryanb/railscasts-episodes

  • Loading branch information...
ryanb committed Oct 17, 2011
0 parents commit 781e65c1119f12efb6e78606de150d646e0cfc2f
Showing with 1,531 additions and 0 deletions.
  1. +3 −0 README
  2. +5 −0 zip_coder-after/.gitignore
  3. +17 −0 zip_coder-after/Gemfile
  4. +134 −0 zip_coder-after/Gemfile.lock
  5. +6 −0 zip_coder-after/README
  6. +7 −0 zip_coder-after/Rakefile
  7. BIN zip_coder-after/app/assets/images/rails.png
  8. +9 −0 zip_coder-after/app/assets/javascripts/application.js
  9. +3 −0 zip_coder-after/app/assets/javascripts/zip_code_lookup.js.coffee
  10. +96 −0 zip_coder-after/app/assets/stylesheets/application.css
  11. +21 −0 zip_coder-after/app/assets/stylesheets/zip_code_lookup.css.scss
  12. +3 −0 zip_coder-after/app/controllers/application_controller.rb
  13. +5 −0 zip_coder-after/app/controllers/zip_code_lookup_controller.rb
  14. +2 −0 zip_coder-after/app/helpers/application_helper.rb
  15. +2 −0 zip_coder-after/app/helpers/zip_code_lookup_helper.rb
  16. 0 zip_coder-after/app/mailers/.gitkeep
  17. 0 zip_coder-after/app/models/.gitkeep
  18. +18 −0 zip_coder-after/app/models/zip_code.rb
  19. +17 −0 zip_coder-after/app/views/layouts/application.html.erb
  20. +21 −0 zip_coder-after/app/views/zip_code_lookup/index.html.erb
  21. +4 −0 zip_coder-after/config.ru
  22. +48 −0 zip_coder-after/config/application.rb
  23. +6 −0 zip_coder-after/config/boot.rb
  24. +25 −0 zip_coder-after/config/database.yml
  25. +5 −0 zip_coder-after/config/environment.rb
  26. +30 −0 zip_coder-after/config/environments/development.rb
  27. +60 −0 zip_coder-after/config/environments/production.rb
  28. +39 −0 zip_coder-after/config/environments/test.rb
  29. +7 −0 zip_coder-after/config/initializers/backtrace_silencers.rb
  30. +10 −0 zip_coder-after/config/initializers/inflections.rb
  31. +5 −0 zip_coder-after/config/initializers/mime_types.rb
  32. +7 −0 zip_coder-after/config/initializers/secret_token.rb
  33. +8 −0 zip_coder-after/config/initializers/session_store.rb
  34. +14 −0 zip_coder-after/config/initializers/wrap_parameters.rb
  35. +5 −0 zip_coder-after/config/locales/en.yml
  36. +3 −0 zip_coder-after/config/routes.rb
  37. +7 −0 zip_coder-after/db/seeds.rb
  38. +2 −0 zip_coder-after/doc/README_FOR_APP
  39. 0 zip_coder-after/lib/assets/.gitkeep
  40. 0 zip_coder-after/lib/tasks/.gitkeep
  41. 0 zip_coder-after/log/.gitkeep
  42. +26 −0 zip_coder-after/public/404.html
  43. +26 −0 zip_coder-after/public/422.html
  44. +26 −0 zip_coder-after/public/500.html
  45. 0 zip_coder-after/public/favicon.ico
  46. +5 −0 zip_coder-after/public/robots.txt
  47. +6 −0 zip_coder-after/script/rails
  48. 0 zip_coder-after/test/fixtures/.gitkeep
  49. 0 zip_coder-after/test/functional/.gitkeep
  50. +9 −0 zip_coder-after/test/functional/zip_code_lookup_controller_test.rb
  51. 0 zip_coder-after/test/integration/.gitkeep
  52. +12 −0 zip_coder-after/test/performance/browsing_test.rb
  53. +13 −0 zip_coder-after/test/test_helper.rb
  54. 0 zip_coder-after/test/unit/.gitkeep
  55. +4 −0 zip_coder-after/test/unit/helpers/zip_code_lookup_helper_test.rb
  56. 0 zip_coder-after/vendor/assets/stylesheets/.gitkeep
  57. 0 zip_coder-after/vendor/plugins/.gitkeep
  58. +5 −0 zip_coder-before/.gitignore
  59. +16 −0 zip_coder-before/Gemfile
  60. +119 −0 zip_coder-before/Gemfile.lock
  61. +6 −0 zip_coder-before/README
  62. +7 −0 zip_coder-before/Rakefile
  63. BIN zip_coder-before/app/assets/images/rails.png
  64. +9 −0 zip_coder-before/app/assets/javascripts/application.js
  65. +3 −0 zip_coder-before/app/assets/javascripts/zip_code_lookup.js.coffee
  66. +96 −0 zip_coder-before/app/assets/stylesheets/application.css
  67. +21 −0 zip_coder-before/app/assets/stylesheets/zip_code_lookup.css.scss
  68. +3 −0 zip_coder-before/app/controllers/application_controller.rb
  69. +5 −0 zip_coder-before/app/controllers/zip_code_lookup_controller.rb
  70. +2 −0 zip_coder-before/app/helpers/application_helper.rb
  71. +2 −0 zip_coder-before/app/helpers/zip_code_lookup_helper.rb
  72. 0 zip_coder-before/app/mailers/.gitkeep
  73. 0 zip_coder-before/app/models/.gitkeep
  74. +6 −0 zip_coder-before/app/models/zip_code.rb
  75. +17 −0 zip_coder-before/app/views/layouts/application.html.erb
  76. +21 −0 zip_coder-before/app/views/zip_code_lookup/index.html.erb
  77. +4 −0 zip_coder-before/config.ru
  78. +48 −0 zip_coder-before/config/application.rb
  79. +6 −0 zip_coder-before/config/boot.rb
  80. +25 −0 zip_coder-before/config/database.yml
  81. +5 −0 zip_coder-before/config/environment.rb
  82. +30 −0 zip_coder-before/config/environments/development.rb
  83. +60 −0 zip_coder-before/config/environments/production.rb
  84. +39 −0 zip_coder-before/config/environments/test.rb
  85. +7 −0 zip_coder-before/config/initializers/backtrace_silencers.rb
  86. +10 −0 zip_coder-before/config/initializers/inflections.rb
  87. +5 −0 zip_coder-before/config/initializers/mime_types.rb
  88. +7 −0 zip_coder-before/config/initializers/secret_token.rb
  89. +8 −0 zip_coder-before/config/initializers/session_store.rb
  90. +14 −0 zip_coder-before/config/initializers/wrap_parameters.rb
  91. +5 −0 zip_coder-before/config/locales/en.yml
  92. +3 −0 zip_coder-before/config/routes.rb
  93. +7 −0 zip_coder-before/db/seeds.rb
  94. +2 −0 zip_coder-before/doc/README_FOR_APP
  95. 0 zip_coder-before/lib/assets/.gitkeep
  96. 0 zip_coder-before/lib/tasks/.gitkeep
  97. 0 zip_coder-before/log/.gitkeep
  98. +26 −0 zip_coder-before/public/404.html
  99. +26 −0 zip_coder-before/public/422.html
  100. +26 −0 zip_coder-before/public/500.html
  101. 0 zip_coder-before/public/favicon.ico
  102. +5 −0 zip_coder-before/public/robots.txt
  103. +6 −0 zip_coder-before/script/rails
  104. 0 zip_coder-before/test/fixtures/.gitkeep
  105. 0 zip_coder-before/test/functional/.gitkeep
  106. +9 −0 zip_coder-before/test/functional/zip_code_lookup_controller_test.rb
  107. 0 zip_coder-before/test/integration/.gitkeep
  108. +12 −0 zip_coder-before/test/performance/browsing_test.rb
  109. +13 −0 zip_coder-before/test/test_helper.rb
  110. 0 zip_coder-before/test/unit/.gitkeep
  111. +4 −0 zip_coder-before/test/unit/helpers/zip_code_lookup_helper_test.rb
  112. 0 zip_coder-before/vendor/assets/stylesheets/.gitkeep
  113. 0 zip_coder-before/vendor/plugins/.gitkeep
3 README
@@ -0,0 +1,3 @@
+RailsCasts Episode #290: SOAP with Savon
+
+http://railscasts.com/episodes/290-soap-with-savon
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
@@ -0,0 +1,17 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.1'
+gem 'sqlite3'
+
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.1.4'
+ gem 'coffee-rails', '~> 3.1.1'
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+gem 'savon'
@@ -0,0 +1,134 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.1)
+ actionpack (= 3.1.1)
+ mail (~> 2.3.0)
+ actionpack (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.2)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ activesupport (3.1.1)
+ multi_json (~> 1.0)
+ akami (1.0.0)
+ gyoku (>= 0.4.0)
+ arel (2.2.1)
+ builder (3.0.0)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ erubis (2.7.0)
+ execjs (1.2.9)
+ multi_json (~> 1.0)
+ gyoku (0.4.4)
+ builder (>= 2.1.2)
+ hike (1.2.1)
+ httpi (0.9.5)
+ rack
+ i18n (0.6.0)
+ jquery-rails (1.0.16)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.1)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ nokogiri (1.5.0)
+ nori (1.0.2)
+ polyglot (0.3.2)
+ rack (1.3.4)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.1)
+ actionmailer (= 3.1.1)
+ actionpack (= 3.1.1)
+ activerecord (= 3.1.1)
+ activeresource (= 3.1.1)
+ activesupport (= 3.1.1)
+ bundler (~> 1.0)
+ railties (= 3.1.1)
+ railties (3.1.1)
+ actionpack (= 3.1.1)
+ activesupport (= 3.1.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.10)
+ json (~> 1.4)
+ sass (3.1.10)
+ sass-rails (3.1.4)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
+ sprockets (~> 2.0.0)
+ tilt (~> 1.3.2)
+ savon (0.9.7)
+ akami (~> 1.0)
+ builder (>= 2.1.2)
+ gyoku (>= 0.4.0)
+ httpi (~> 0.9)
+ nokogiri (>= 1.4.0)
+ nori (~> 1.0)
+ wasabi (~> 2.0)
+ sprockets (2.0.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.30)
+ uglifier (1.0.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ wasabi (2.0.0)
+ nokogiri (>= 1.4.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.1)
+ jquery-rails
+ rails (= 3.1.1)
+ sass-rails (~> 3.1.4)
+ savon
+ sqlite3
+ uglifier (>= 1.0.3)
@@ -0,0 +1,6 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rails s
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+ZipCoder::Application.load_tasks
Binary file not shown.
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,96 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= require_self
+ *= require_tree .
+*/
+
+html, body {
+ background-color: #4B7399;
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 75%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+form label {
+ display: block;
+ margin-bottom: 2px;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+.fieldWithErrors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ font-size: 12px;
+}
+
+.error_messages h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 10px;
+ font-size: 12px;
+ margin: 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+.error_messages p {
+ margin: 8px 10px;
+}
+
+.error_messages ul {
+ margin: 15px 0;
+}
@@ -0,0 +1,21 @@
+// Place all the styles related to the zip_code_lookup controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+#zip_info {
+ padding: 20px;
+ border-top: solid 3px #CCC;
+
+ dt {
+ float: left;
+ width: 100px;
+ text-align: right;
+ padding-right: 5px;
+ font-weight: bold;
+ }
+ dd {
+ display: block;
+ }
+ dt, dd {
+ height: 20px;
+ }
+}
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,5 @@
+class ZipCodeLookupController < ApplicationController
+ def index
+ @zip_code = ZipCode.new(params[:zip_code]) if params[:zip_code].present?
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module ZipCodeLookupHelper
+end
No changes.
No changes.
@@ -0,0 +1,18 @@
+class ZipCode
+ attr_reader :state, :city, :area_code, :time_zone
+
+ def initialize(zip)
+ # Gyoku.convert_symbols_to :camelcase
+ client = Savon::Client.new("http://www.webservicex.net/uszip.asmx?WSDL")
+ response = client.request :web, :get_info_by_zip, body: { "USZip" => zip }
+ if response.success?
+ data = response.to_array(:get_info_by_zip_response, :get_info_by_zip_result, :new_data_set, :table).first
+ if data
+ @state = data[:state]
+ @city = data[:city]
+ @area_code = data[:area_code]
+ @time_zone = data[:time_zone]
+ end
+ end
+ end
+end
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Zip Code Lookup</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+ <div id="container">
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ </div>
+</body>
+</html>
@@ -0,0 +1,21 @@
+<h1>Zip Code Lookup</h1>
+
+<%= form_tag root_url, method: :get do %>
+<p>
+ <%= text_field_tag :zip_code, params[:zip_code] %>
+ <%= submit_tag "Lookup", name: nil %>
+</p>
+<% end %>
+
+<% if @zip_code %>
+ <dl id ="zip_info">
+ <dt>City:</dt>
+ <dd><%= @zip_code.city %></dd>
+ <dt>State:</dt>
+ <dd><%= @zip_code.state %></dd>
+ <dt>Area Code:</dt>
+ <dd><%= @zip_code.area_code %></dd>
+ <dt>Time Zone:</dt>
+ <dd><%= @zip_code.time_zone %></dd>
+ </dl>
+<% end %>
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run ZipCoder::Application
Oops, something went wrong.

0 comments on commit 781e65c

Please sign in to comment.