Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

commit real code

  • Loading branch information...
commit 1aeb66f10c0ce7cb06fd9b2b1ad763a59445b0e3 1 parent 99095c3
@adiastyle authored
View
10 .gitignore
@@ -0,0 +1,10 @@
+\#*
+*~
+.#*
+.DS_Store
+.idea
+.project
+tmp
+nbproject
+*.swp
+spec/dummy
View
1  .rspec
@@ -0,0 +1 @@
+--colour
View
26 LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2011 [name of plugin creator]
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name Spree nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
20 README.md
@@ -0,0 +1,20 @@
+SpreeStripe
+===========
+
+Introduction goes here.
+
+
+Example
+=======
+
+Example goes here.
+
+Testing
+-------
+
+Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
+
+ $ bundle exec rake test app
+ $ bundle exec rspec spec
+
+Copyright (c) 2011 [name of extension creator], released under the New BSD License
View
31 Rakefile
@@ -0,0 +1,31 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rubygems/package_task'
+require 'rspec/core/rake_task'
+require 'cucumber/rake/task'
+require 'spree_core/testing_support/common_rake'
+
+RSpec::Core::RakeTask.new
+Cucumber::Rake::Task.new
+
+task :default => [:spec, :cucumber ]
+
+spec = eval(File.read('spree_stripe.gemspec'))
+
+Gem::PackageTask.new(spec) do |p|
+ p.gem_spec = spec
+end
+
+desc "Release to gemcutter"
+task :release => :package do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
+end
+
+desc "Generates a dummy app for testing"
+task :test_app do
+ ENV['LIB_NAME'] = 'spree_stripe'
+ Rake::Task['common:test_app'].invoke
+end
View
9 Versionfile
@@ -0,0 +1,9 @@
+# This file is used to designate compatibilty with different versions of Spree
+# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
+
+# Examples
+#
+# "0.70.x" => { :branch => "master"}
+# "0.60.x" => { :branch => "0-60-stable" }
+# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
+
View
1  app/assets/javascripts/admin/spree_stripe.js
@@ -0,0 +1 @@
+//= require admin/spree_core
View
1  app/assets/javascripts/store/spree_stripe.js
@@ -0,0 +1 @@
+//= require store/spree_core
View
3  app/assets/stylesheets/admin/spree_stripe.css
@@ -0,0 +1,3 @@
+/*
+ *= require admin/spree_core
+*/
View
72 app/assets/stylesheets/store/checkout.js
@@ -0,0 +1,72 @@
+(function($){
+ $(document).ready(function(){
+ if($('#checkout_form_address').is('*')){
+
+ $('#checkout_form_address').validate();
+
+ var get_states = function(region){
+ country = $('p#' + region + 'country' + ' span#' + region + 'country :only-child').val();
+ return state_mapper[country];
+ }
+
+ var update_state = function(region) {
+ states = get_states(region);
+
+ state_select = $('p#' + region + 'state select');
+ state_input = $('p#' + region + 'state input');
+
+ if(states) {
+ selected = state_select.val();
+ state_select.html('');
+ states_with_blank = [["",""]].concat(states);
+ $.each(states_with_blank, function(pos,id_nm) {
+ var opt = $(document.createElement('option'))
+ .attr('value', id_nm[0])
+ .html(id_nm[1]);
+ if(selected==id_nm[0]){
+ opt.prop("selected", true);
+ }
+ state_select.append(opt);
+ });
+ state_select.prop("disabled", false).show();
+ state_input.hide().prop("disabled", true);
+
+ } else {
+ state_input.prop("disabled", false).show();
+ state_select.hide().prop("disabled", true);
+ }
+
+ };
+
+ $('p#bcountry select').change(function() { update_state('b'); });
+ $('p#scountry select').change(function() { update_state('s'); });
+ update_state('b');
+ update_state('s');
+
+ $('input#order_use_billing').click(function() {
+ if($(this).is(':checked')) {
+ $('#shipping .inner').hide();
+ $('#shipping .inner input, #shipping .inner select').prop("disabled", true);
+ } else {
+ $('#shipping .inner').show();
+ $('#shipping .inner input, #shipping .inner select').prop("disabled", false);
+ //only want to enable relevant field
+ if(get_states('s')){
+ $('span#sstate input').hide().prop("disabled", true);
+ }else{
+ $('span#sstate select').hide().prop("disabled", true);
+ }
+
+ }
+ }).triggerHandler('click');
+ }
+
+ if($('#checkout_form_payment').is('*')){
+ // Show fields for the selected payment method
+ $("input[type='radio'][name='order[payments_attributes][][payment_method_id]']").click(function(){
+ $('#payment-methods li').hide();
+ if(this.checked){ $('#payment_method_'+this.value).show(); }
+ }).triggerHandler('click');
+ }
+ });
+})(jQuery);
View
3  app/assets/stylesheets/store/spree_stripe.css
@@ -0,0 +1,3 @@
+/*
+ *= require store/spree_core
+*/
View
10 app/models/gateway/stripe.rb
@@ -0,0 +1,10 @@
+class Gateway::Stripe < Gateway
+ preference :login, :string
+
+ def provider_class
+ ActiveMerchant::Billing::StripeGateway
+ end
+ def payment_profiles_supported?
+ false
+ end
+end
View
3  config/routes.rb
@@ -0,0 +1,3 @@
+Rails.application.routes.draw do
+ # Add your extension routes here
+end
View
29 lib/generators/spree_stripe/install/install_generator.rb
@@ -0,0 +1,29 @@
+module SpreeStripe
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+
+ def add_javascripts
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_stripe\n"
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_stripe\n"
+ end
+
+ def add_stylesheets
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_stripe\n", :before => /\*\//, :verbose => true
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_stripe\n", :before => /\*\//, :verbose => true
+ end
+
+ def add_migrations
+ run 'bundle exec rake railties:install:migrations FROM=spree_stripe'
+ end
+
+ def run_migrations
+ res = ask "Would you like to run the migrations now? [Y/n]"
+ if res == "" || res.downcase == "y"
+ run 'bundle exec rake db:migrate'
+ else
+ puts "Skiping rake db:migrate, don't forget to run it!"
+ end
+ end
+ end
+ end
+end
View
2  lib/spree_stripe.rb
@@ -0,0 +1,2 @@
+require 'spree_core'
+require 'spree_stripe/engine'
View
28 lib/spree_stripe/engine.rb
@@ -0,0 +1,28 @@
+module SpreeStripe
+ class Engine < Rails::Engine
+ engine_name 'spree_stripe'
+
+ config.autoload_paths += %W(#{config.root}/lib)
+
+ # use rspec for tests
+ config.generators do |g|
+ g.test_framework :rspec
+ end
+
+ def self.activate
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
+ Rails.application.config.cache_classes ? require(c) : load(c)
+ end
+
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
+ Rails.application.config.cache_classes ? require(c) : load(c)
+ end
+ end
+ initializer "spree_stripe.register.payment_methods" do |app|
+ app.config.spree.payment_methods += [
+ Gateway::Stripe
+ ]
+ end
+ config.to_prepare &method(:activate).to_proc
+ end
+end
View
9 script/rails
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+
+ENGINE_PATH = File.expand_path('../..', __FILE__)
+APP_PATH = File.expand_path('../../../config/application', __FILE__)
+require File.expand_path('../../../config/boot', __FILE__)
+require 'rails/commands'
+
View
31 spec/spec_helper.rb
@@ -0,0 +1,31 @@
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+
+
+require File.expand_path("../../../config/environment.rb", __FILE__)
+
+
+require 'rspec/rails'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+end
View
23 spree_stripe.gemspec
@@ -0,0 +1,23 @@
+# encoding: UTF-8
+Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = 'spree_stripe'
+ s.version = '0.70.1'
+ s.summary = 'Add gem summary here'
+ s.description = 'Add (optional) gem description here'
+ s.required_ruby_version = '>= 1.8.7'
+
+ # s.author = 'David Heinemeier Hansson'
+ # s.email = 'david@loudthinking.com'
+ # s.homepage = 'http://www.rubyonrails.org'
+ # s.rubyforge_project = 'actionmailer'
+
+ #s.files = `git ls-files`.split("\n")
+ #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.require_path = 'lib'
+ s.requirements << 'none'
+
+ s.add_dependency 'spree_core', '>= 0.70.1'
+ s.add_development_dependency 'rspec-rails'
+end
+

0 comments on commit 1aeb66f

Please sign in to comment.
Something went wrong with that request. Please try again.