spree_smarty_street 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8960ceaa73e8a2be89459988953d613f6f83a99c
4
+ data.tar.gz: 5b5f359c393d8f698b4058d7d5d85012925ad0f0
5
+ SHA512:
6
+ metadata.gz: 5823fa262f328ecdacac76277bbd8fde355b6f86702e4b2058b650a5ae9a857e22767f78e79ad797b34caf64f10e495116c069466d5d76934f7a308f5aa1a353
7
+ data.tar.gz: d5542e8f4eabc4ae3b541e687d723e45b635822b1d94f0db22502ca6e23d9b14a84a941236266ded044101735de19fc82474d3bfb92e17c5d12d4a116769cce5
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '3-0-stable'
4
+ # Provides basic authentication functionality for testing parts of your engine
5
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
6
+
7
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2015 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ SpreeSmartyStreet
2
+ ================
3
+
4
+ This extension is to integrate Smarty Street jquery API into spree 3.0 checkout step. Please noticed that there will be NO API calls in Ruby.
5
+
6
+
7
+ Installation
8
+ ------------
9
+
10
+ Add spree_smarty_street to your Gemfile:
11
+
12
+ ```ruby
13
+ gem 'spree_smarty_street'
14
+ ```
15
+
16
+ Bundle your dependencies and run the installation generator:
17
+
18
+ ```shell
19
+ bundle
20
+ bundle exec rails g spree_smarty_street:install
21
+ ```
22
+
23
+ Testing
24
+ -------
25
+
26
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
27
+
28
+ ```shell
29
+ bundle
30
+ bundle exec rake
31
+ ```
32
+
33
+ When testing your applications integration with this extension you may use it's factories.
34
+ Simply add this require statement to your spec_helper:
35
+
36
+ ```ruby
37
+ require 'spree_smarty_street/factories'
38
+ ```
39
+
40
+ Copyright (c) 2015 Natural Wellbeing Distribution Inc., released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_smarty_street'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ class SmartyStreetConfiguration
3
+
4
+ def self.account
5
+ bronto_yml=File.join(Rails.root,'config/smarty_street.yml')
6
+ if File.exist? bronto_yml
7
+ bronto_yml=File.join(Rails.root,'config/smarty_street.yml')
8
+ YAML.load(File.read(bronto_yml))
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/checkout/_address",
3
+ :name => "smarty_street_tags",
4
+ :insert_after => "[data-hook='billing_fieldset_wrapper']",
5
+ :partial => "spree/shared/smarty_street_tags",
6
+ :disabled => false)
@@ -0,0 +1,158 @@
1
+ <% content_for :head do -%>
2
+ <% api_url= Spree::SmartyStreetConfiguration.account['default']['api_url'] %>
3
+ <%= javascript_include_tag api_url %>
4
+ <% end %>
5
+ <% qualified_address_key= Spree::SmartyStreetConfiguration.account['default']['qualified_address_key'] %>
6
+ <script type="text/javascript">
7
+ function set_display_value(address, field){
8
+ var field_name ;
9
+
10
+ var disp = $("#order_" + address + "_address_attributes_" + field + "_name");
11
+
12
+ if(field=='country'){
13
+ disp.val(countries_isos[$("#order_" + address + "_address_attributes_" + field + "_id :selected").text()]);
14
+ set_display_value(address, 'state');
15
+ disp.change();
16
+ }
17
+ else
18
+ disp.val(us_states_abbrs[$("#order_" + address + "_address_attributes_" + field + "_id :selected").text()]);
19
+ }
20
+
21
+ var us_states_abbrs={"DC":"District of Columbia", "UT":"Utah", "LA":"Louisiana", "VA":"Virginia", "ND":"North Dakota", "WY":"Wyoming", "NM":"New Mexico", "CT":"Connecticut", "WV":"West Virginia", "WI":"Wisconsin", "NC":"North Carolina", "NV":"Nevada", "HI":"Hawaii", "OK":"Oklahoma", "FL":"Florida", "CA":"California", "OR":"Oregon", "KY":"Kentucky", "MA":"Massachusetts", "AK":"Alaska", "WA":"Washington", "NH":"New Hampshire", "AR":"Arkansas", "PA":"Pennsylvania", "RI":"Rhode Island", "MD":"Maryland", "OH":"Ohio", "TX":"Texas", "MS":"Mississippi", "CO":"Colorado", "SC":"South Carolina", "SD":"South Dakota", "IL":"Illinois", "MO":"Missouri", "NE":"Nebraska", "DE":"Delaware", "TN":"Tennessee", "NJ":"New Jersey", "IN":"Indiana", "IA":"Iowa", "GA":"Georgia", "NY":"New York", "MI":"Michigan", "AZ":"Arizona", "KS":"Kansas", "ID":"Idaho", "VT":"Vermont", "MT":"Montana", "MN":"Minnesota", "ME":"Maine", "AL":"Alabama", "AE":"Armed Forces Europe", "PR":"Puerto Rico", "AS":"American Samoa", "FM":"Federated States of Micronesia","MH":"Marshall Islands", "MP":"Northern Mariana Islands","PW":"Palau", "VI":"Virgin Islands", "AE":"Armed Forces Africa", "AE":"Armed Forces Canada", "AE":"Armed Forces Middle East","AP":"Armed Forces Pacific", "AA":"Armed Forces Americas", "GU":"Guam"}
22
+ var countries_isos={"Afghanistan":"AF","Albania":"AL","Algeria":"DZ","American Samoa":"AS","Andorra":"AD","Angola":"AO","Anguilla":"AI","Antigua and Barbuda":"AG","Argentina":"AR","Armenia":"AM","Aruba":"AW","Australia":"AU","Austria":"AT","Azerbaijan":"AZ","Bahamas":"BS","Bahrain":"BH","Bangladesh":"BD","Barbados":"BB","Belarus":"BY","Belgium":"BE","Belize":"BZ","Benin":"BJ","Bermuda":"BM","Bhutan":"BT","Bolivia":"BO","Bosnia and Herzegovina":"BA","Botswana":"BW","Brazil":"BR","Brunei Darussalam":"BN","Bulgaria":"BG","Burkina Faso":"BF","Burundi":"BI","Cambodia":"KH","Cameroon":"CM","Canada":"CA","Cape Verde":"CV","Cayman Islands":"KY","Central African Republic":"CF","Chad":"TD","Chile":"CL","China":"CN","Colombia":"CO","Comoros":"KM","Congo":"CG","Congo, the Democratic Republic of the":"CD","Cook Islands":"CK","Costa Rica":"CR","Cote D'Ivoire":"CI","Croatia":"HR","Cuba":"CU","Cyprus":"CY","Czech Republic":"CZ","Denmark":"DK","Djibouti":"DJ","Dominica":"DM","Dominican Republic":"DO","Ecuador":"EC","Egypt":"EG","El Salvador":"SV","Equatorial Guinea":"GQ","Eritrea":"ER","Estonia":"EE","Ethiopia":"ET","Falkland Islands (Malvinas)":"FK","Faroe Islands":"FO","Fiji":"FJ","Finland":"FI","France":"FR","French Guiana":"GF","French Polynesia":"PF","Gabon":"GA","Gambia":"GM","Georgia":"GE","Germany":"DE","Ghana":"GH","Gibraltar":"GI","Greece":"GR","Greenland":"GL","Grenada":"GD","Guadeloupe":"GP","Guam":"GU","Guatemala":"GT","Guinea":"GN","Guinea-Bissau":"GW","Guyana":"GY","Haiti":"HT","Holy See (Vatican City State)":"VA","Honduras":"HN","Hong Kong":"HK","Hungary":"HU","Iceland":"IS","India":"IN","Indonesia":"ID","Iran, Islamic Republic of":"IR","Iraq":"IQ","Ireland":"IE","Israel":"IL","Italy":"IT","Jamaica":"JM","Japan":"JP","Jordan":"JO","Kazakhstan":"KZ","Kenya":"KE","Kiribati":"KI","North Korea":"KP","South Korea":"KR","Kuwait":"KW","Kyrgyzstan":"KG","Lao People's Democratic Republic":"LA","Latvia":"LV","Lebanon":"LB","Lesotho":"LS","Liberia":"LR","Libyan Arab Jamahiriya":"LY","Liechtenstein":"LI","Lithuania":"LT","Luxembourg":"LU","Macao":"MO","Macedonia":"MK","Madagascar":"MG","Malawi":"MW","Malaysia":"MY","Maldives":"MV","Mali":"ML","Malta":"MT","Marshall Islands":"MH","Martinique":"MQ","Mauritania":"MR","Mauritius":"MU","Mexico":"MX","Micronesia, Federated States of":"FM","Moldova, Republic of":"MD","Monaco":"MC","Mongolia":"MN","Montserrat":"MS","Morocco":"MA","Mozambique":"MZ","Myanmar":"MM","Namibia":"NA","Nauru":"NR","Nepal":"NP","Netherlands":"NL","Netherlands Antilles":"AN","New Caledonia":"NC","New Zealand":"NZ","Nicaragua":"NI","Niger":"NE","Nigeria":"NG","Niue":"NU","Norfolk Island":"NF","Northern Mariana Islands":"MP","Norway":"NO","Oman":"OM","Pakistan":"PK","Palau":"PW","Panama":"PA","Papua New Guinea":"PG","Paraguay":"PY","Peru":"PE","Philippines":"PH","Pitcairn":"PN","Poland":"PL","Portugal":"PT","Puerto Rico":"PR","Qatar":"QA","Reunion":"RE","Romania":"RO","Russian Federation":"RU","Rwanda":"RW","Saint Helena":"SH","Saint Kitts and Nevis":"KN","Saint Lucia":"LC","Saint Pierre and Miquelon":"PM","Saint Vincent and the Grenadines":"VC","Samoa":"WS","San Marino":"SM","Sao Tome and Principe":"ST","Saudi Arabia":"SA","Senegal":"SN","Seychelles":"SC","Sierra Leone":"SL","Singapore":"SG","Slovakia":"SK","Slovenia":"SI","Solomon Islands":"SB","Somalia":"SO","South Africa":"ZA","Spain":"ES","Sri Lanka":"LK","Sudan":"SD","Suriname":"SR","Svalbard and Jan Mayen":"SJ","Swaziland":"SZ","Sweden":"SE","Switzerland":"CH","Syrian Arab Republic":"SY","Taiwan":"TW","Tajikistan":"TJ","Tanzania, United Republic of":"TZ","Thailand":"TH","Togo":"TG","Tokelau":"TK","Tonga":"TO","Trinidad and Tobago":"TT","Tunisia":"TN","Turkey":"TR","Turkmenistan":"TM","Turks and Caicos Islands":"TC","Tuvalu":"TV","Uganda":"UG","Ukraine":"UA","United Arab Emirates":"AE","United Kingdom":"GB","United States":"US","Uruguay":"UY","Uzbekistan":"UZ","Vanuatu":"VU","Venezuela":"VE","Viet Nam":"VN","Virgin Islands, British":"VG","Virgin Islands, U.S.":"VI","Wallis and Futuna":"WF","Western Sahara":"EH","Yemen":"YE","Zambia":"ZM","Zimbabwe":"ZW"}
23
+
24
+ function set_actual_value(address, field){
25
+ var actual = $("#order_" + address + "_address_attributes_" + field + "_id :selected");
26
+ var value = $("#order_" + address + "_address_attributes_" + field + "_name").val();
27
+ if(value.length==2){ //only update if the value is a 2 digital state abbr
28
+ actual.val(value);
29
+ $("#order_" + address + "_address_attributes_" + field + "_id option")
30
+ .each(function() { this.selected = (this.text == us_states_abbrs[value]); });
31
+ }
32
+ }
33
+
34
+
35
+ function turn_off_validation()
36
+ {
37
+ //liveaddress.deactivate(); //clear all old one
38
+ $("#order_ship_address_attributes_address").attr('style','');
39
+ $("#order_ship_address_attributes_city").attr('style','');
40
+ $("#order_ship_address_attributes_zipcode").attr('style','');
41
+
42
+ $("#order_bill_address_attributes_address").attr('style','');
43
+ $("#order_bill_address_attributes_city").attr('style','');
44
+ $("#order_bill_address_attributes_zipcode").attr('style','');
45
+ }
46
+
47
+ function turn_on_validation()
48
+ {
49
+ turn_off_validation();
50
+ liveaddress.mapFields();
51
+ }
52
+
53
+ //pop up the state based on zip code if it is there
54
+
55
+ if ((typeof($("#order_ship_address_attributes_zipcode").val()) != 'undefined') && (typeof($("#order_ship_address_attributes_city").val()) != 'undefined') && (typeof($("#order_ship_address_attributes_state_name").val()) != 'undefined'))
56
+ {
57
+ $.getJSON( "https://api.smartystreets.com/zipcode?zipcode=" + $("#order_ship_address_attributes_zipcode").val() + "&key=<%= qualified_address_key %>",
58
+ function( data ) {
59
+ if (data.length>0)
60
+ {
61
+ var city_states=data[0].city_states;
62
+ $("#order_ship_address_attributes_city").val(city_states[0].city);
63
+ $("#order_ship_address_attributes_state_name").val(city_states[0].state_abbreviation);
64
+ set_actual_value('ship', 'state');
65
+ create_liveaddress ();
66
+ }
67
+ else
68
+ create_liveaddress();
69
+
70
+ }
71
+ );
72
+
73
+ }
74
+ else
75
+ create_liveaddress();
76
+
77
+ // functions and objects for smarty street jquery plugin
78
+ var liveaddress={}
79
+ function create_liveaddress(){
80
+ liveaddress=$.LiveAddress({
81
+ key: <%= qualified_address_key %>,
82
+ debug: false,
83
+ autoVerify: false,
84
+ addresses: [{
85
+ id: 'ship_address_object',
86
+ street: "#order_ship_address_attributes_address1",
87
+ city: "#order_ship_address_attributes_city",
88
+ state: "#order_ship_address_attributes_state_name",
89
+ zipcode: "#order_ship_address_attributes_zipcode",
90
+ country: "#order_ship_address_attributes_country_name"
91
+ },
92
+ {
93
+ id: 'bill_address_object',
94
+ street: "#order_bill_address_attributes_address1",
95
+ city: "#order_bill_address_attributes_city",
96
+ state: "#order_bill_address_attributes_state_name",
97
+ zipcode: "#order_bill_address_attributes_zipcode",
98
+ country: "#order_bill_address_attributes_country_name"
99
+ }]
100
+ });
101
+ liveaddress.on("AddressChanged",function(event,data, previousHandler){
102
+ //alert(data.address);
103
+
104
+ if($("select#order_bill_address_attributes_country_id").val()==214){
105
+ set_actual_value('bill', 'state');
106
+ }
107
+ if($("select#order_ship_address_attributes_country_id").val()==214){
108
+ set_actual_value('ship', 'state');
109
+ }
110
+ //return false;
111
+ });
112
+ }
113
+
114
+
115
+ jQuery(document).ready(function(){
116
+
117
+ set_display_value('bill', 'country');
118
+ set_display_value('ship', 'country');
119
+
120
+ $(".to_upper input").change(function(){
121
+ var that = $(this);
122
+ that.val( that.val().toUpperCase());
123
+ });
124
+
125
+ //setup handlers for changes
126
+ $("select#order_bill_address_attributes_country_id").change(function(){set_display_value('bill', 'country');});
127
+ $("select#order_ship_address_attributes_country_id").change(function(){set_display_value('ship', 'country');});
128
+ $("select#order_bill_address_attributes_state_id").change(function(){set_display_value('bill', 'state');});
129
+ $("select#order_ship_address_attributes_state_id").change(function(){set_display_value('ship', 'state');});
130
+
131
+ $('input#order_use_billing').click(function() {
132
+ if(this.checked){
133
+ $("input#order_bill_address_attributes_country_name").val("Use Billing");
134
+ }else{
135
+ set_display_value('bill', 'country');
136
+ }
137
+ if ($("select#order_ship_address_attributes_country_id")==214)
138
+ turn_on_validation();
139
+ });
140
+
141
+ function set_bill_state( init ){
142
+ var use_shipping = ( $(" input[name='order[use_billing]']:checked ").val() == 1);
143
+ if (use_shipping) {
144
+ $('.billing_address_set .inner input').attr('disabled', 'disabled');
145
+ $('.billing_address_set .inner select').attr('disabled', 'disabled');
146
+ $("input#order_bill_address_attributes_country_display").val("Use Billing");
147
+ $("input#order_bill_address_attributes_country_display").change(); //hi smarty, I am not the one you saw
148
+ }else{
149
+ set_display_value('bill', 'country');
150
+ $('.billing_address_set .inner input').removeAttr('disabled', 'disabled');
151
+ $('.billing_address_set .inner select').removeAttr('disabled', 'disabled');
152
+ };
153
+ }
154
+ set_bill_state(); //We create the function and immeditately call it.
155
+ $(" input[name='order[use_billing]'] ").click(set_bill_state);
156
+
157
+ });
158
+ </script>
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_smarty_street/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # liveaddress jquery plugin from smartyStreet.com
4
+
5
+ default:
6
+ api_url: //d79i1fxsrar4t.cloudfront.net/jquery.liveaddress/2.4/jquery.liveaddress.min.js
7
+ qualified_address_key: your_key_here
@@ -0,0 +1,31 @@
1
+ module SpreeSmartyStreet
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ class_option :auto_run_migrations, :type => :boolean, :default => false
6
+
7
+ def add_javascripts
8
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_smarty_street\n"
9
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_smarty_street\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_smarty_street\n", :before => /\*\//, :verbose => true
14
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_smarty_street\n", :before => /\*\//, :verbose => true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=spree_smarty_street'
19
+ end
20
+
21
+ def run_migrations
22
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
23
+ if run_migrations
24
+ run 'bundle exec rake db:migrate'
25
+ else
26
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeSmartyStreet
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_smarty_street'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_smarty_street/factories'
6
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_smarty_street/engine'
@@ -0,0 +1,87 @@
1
+ # Run Coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec/dummy'
5
+ add_group 'Controllers', 'app/controllers'
6
+ add_group 'Helpers', 'app/helpers'
7
+ add_group 'Mailers', 'app/mailers'
8
+ add_group 'Models', 'app/models'
9
+ add_group 'Views', 'app/views'
10
+ add_group 'Libraries', 'lib'
11
+ end
12
+
13
+ # Configure Rails Environment
14
+ ENV['RAILS_ENV'] = 'test'
15
+
16
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
17
+
18
+ require 'rspec/rails'
19
+ require 'database_cleaner'
20
+ require 'ffaker'
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
25
+
26
+ # Requires factories and other useful helpers defined in spree_core.
27
+ require 'spree/testing_support/authorization_helpers'
28
+ require 'spree/testing_support/capybara_ext'
29
+ require 'spree/testing_support/controller_requests'
30
+ require 'spree/testing_support/factories'
31
+ require 'spree/testing_support/url_helpers'
32
+
33
+ # Requires factories defined in lib/spree_smarty_street/factories.rb
34
+ require 'spree_smarty_street/factories'
35
+
36
+ RSpec.configure do |config|
37
+ config.include FactoryGirl::Syntax::Methods
38
+
39
+ # Infer an example group's spec type from the file location.
40
+ config.infer_spec_type_from_file_location!
41
+
42
+ # == URL Helpers
43
+ #
44
+ # Allows access to Spree's routes in specs:
45
+ #
46
+ # visit spree.admin_path
47
+ # current_path.should eql(spree.products_path)
48
+ config.include Spree::TestingSupport::UrlHelpers
49
+
50
+ # == Mock Framework
51
+ #
52
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
53
+ #
54
+ # config.mock_with :mocha
55
+ # config.mock_with :flexmock
56
+ # config.mock_with :rr
57
+ config.mock_with :rspec
58
+ config.color = true
59
+
60
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
61
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
62
+
63
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
64
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
65
+ # to setup a test will be unavailable to the browser, which runs under a separate server instance.
66
+ config.use_transactional_fixtures = false
67
+
68
+ # Ensure Suite is set to use transactions for speed.
69
+ config.before :suite do
70
+ DatabaseCleaner.strategy = :transaction
71
+ DatabaseCleaner.clean_with :truncation
72
+ end
73
+
74
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
75
+ config.before :each do
76
+ DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
77
+ DatabaseCleaner.start
78
+ end
79
+
80
+ # After each spec clean the database.
81
+ config.after :each do
82
+ DatabaseCleaner.clean
83
+ end
84
+
85
+ config.fail_fast = ENV['FAIL_FAST'] || false
86
+ config.order = "random"
87
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_smarty_street
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Albert Liu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: spree_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coffee-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: database_cleaner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_girl
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ffaker
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sass-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 5.0.0.beta1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 5.0.0.beta1
125
+ - !ruby/object:Gem::Dependency
126
+ name: selenium-webdriver
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: spree checkout address step intelligently fill in address while customer
168
+ typing.
169
+ email: albertliu@naturalwellbeing.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - Gemfile
177
+ - LICENSE
178
+ - README.md
179
+ - Rakefile
180
+ - app/assets/javascripts/spree/backend/spree_smarty_street.js
181
+ - app/assets/javascripts/spree/frontend/spree_smarty_street.js
182
+ - app/assets/stylesheets/spree/backend/spree_smarty_street.css
183
+ - app/assets/stylesheets/spree/frontend/spree_smarty_street.css
184
+ - app/models/spree/smarty_street_configuration.rb
185
+ - app/overrides/decorate_smarty_street_tags.rb
186
+ - app/views/spree/shared/_smarty_street_tags.html.erb
187
+ - bin/rails
188
+ - config/locales/en.yml
189
+ - config/routes.rb
190
+ - config/smarty_street.yml
191
+ - lib/generators/spree_smarty_street/install/install_generator.rb
192
+ - lib/spree_smarty_street.rb
193
+ - lib/spree_smarty_street/engine.rb
194
+ - lib/spree_smarty_street/factories.rb
195
+ - spec/spec_helper.rb
196
+ homepage: http://www.naturalwellbeing.com
197
+ licenses: []
198
+ metadata: {}
199
+ post_install_message:
200
+ rdoc_options: []
201
+ require_paths:
202
+ - lib
203
+ required_ruby_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: 2.0.0
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ requirements:
214
+ - none
215
+ rubyforge_project:
216
+ rubygems_version: 2.4.5
217
+ signing_key:
218
+ specification_version: 4
219
+ summary: spree checkout address step intelligently fill in address while customer
220
+ typing.
221
+ test_files:
222
+ - spec/spec_helper.rb