Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

commit real code

  • Loading branch information...
commit 1aeb66f10c0ce7cb06fd9b2b1ad763a59445b0e3 1 parent 99095c3
adiastyle authored
10 .gitignore
... ... @@ -0,0 +1,10 @@
  1 +\#*
  2 +*~
  3 +.#*
  4 +.DS_Store
  5 +.idea
  6 +.project
  7 +tmp
  8 +nbproject
  9 +*.swp
  10 +spec/dummy
1  .rspec
... ... @@ -0,0 +1 @@
  1 +--colour
26 LICENSE
... ... @@ -0,0 +1,26 @@
  1 +Copyright (c) 2011 [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.
20 README.md
Source Rendered
... ... @@ -0,0 +1,20 @@
  1 +SpreeStripe
  2 +===========
  3 +
  4 +Introduction goes here.
  5 +
  6 +
  7 +Example
  8 +=======
  9 +
  10 +Example goes here.
  11 +
  12 +Testing
  13 +-------
  14 +
  15 +Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
  16 +
  17 + $ bundle exec rake test app
  18 + $ bundle exec rspec spec
  19 +
  20 +Copyright (c) 2011 [name of extension creator], released under the New BSD License
31 Rakefile
... ... @@ -0,0 +1,31 @@
  1 +require 'rake'
  2 +require 'rake/testtask'
  3 +require 'rake/packagetask'
  4 +require 'rubygems/package_task'
  5 +require 'rspec/core/rake_task'
  6 +require 'cucumber/rake/task'
  7 +require 'spree_core/testing_support/common_rake'
  8 +
  9 +RSpec::Core::RakeTask.new
  10 +Cucumber::Rake::Task.new
  11 +
  12 +task :default => [:spec, :cucumber ]
  13 +
  14 +spec = eval(File.read('spree_stripe.gemspec'))
  15 +
  16 +Gem::PackageTask.new(spec) do |p|
  17 + p.gem_spec = spec
  18 +end
  19 +
  20 +desc "Release to gemcutter"
  21 +task :release => :package do
  22 + require 'rake/gemcutter'
  23 + Rake::Gemcutter::Tasks.new(spec).define
  24 + Rake::Task['gem:push'].invoke
  25 +end
  26 +
  27 +desc "Generates a dummy app for testing"
  28 +task :test_app do
  29 + ENV['LIB_NAME'] = 'spree_stripe'
  30 + Rake::Task['common:test_app'].invoke
  31 +end
9 Versionfile
... ... @@ -0,0 +1,9 @@
  1 +# This file is used to designate compatibilty with different versions of Spree
  2 +# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
  3 +
  4 +# Examples
  5 +#
  6 +# "0.70.x" => { :branch => "master"}
  7 +# "0.60.x" => { :branch => "0-60-stable" }
  8 +# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
  9 +
1  app/assets/javascripts/admin/spree_stripe.js
... ... @@ -0,0 +1 @@
  1 +//= require admin/spree_core
1  app/assets/javascripts/store/spree_stripe.js
... ... @@ -0,0 +1 @@
  1 +//= require store/spree_core
3  app/assets/stylesheets/admin/spree_stripe.css
... ... @@ -0,0 +1,3 @@
  1 +/*
  2 + *= require admin/spree_core
  3 +*/
72 app/assets/stylesheets/store/checkout.js
... ... @@ -0,0 +1,72 @@
  1 +(function($){
  2 + $(document).ready(function(){
  3 + if($('#checkout_form_address').is('*')){
  4 +
  5 + $('#checkout_form_address').validate();
  6 +
  7 + var get_states = function(region){
  8 + country = $('p#' + region + 'country' + ' span#' + region + 'country :only-child').val();
  9 + return state_mapper[country];
  10 + }
  11 +
  12 + var update_state = function(region) {
  13 + states = get_states(region);
  14 +
  15 + state_select = $('p#' + region + 'state select');
  16 + state_input = $('p#' + region + 'state input');
  17 +
  18 + if(states) {
  19 + selected = state_select.val();
  20 + state_select.html('');
  21 + states_with_blank = [["",""]].concat(states);
  22 + $.each(states_with_blank, function(pos,id_nm) {
  23 + var opt = $(document.createElement('option'))
  24 + .attr('value', id_nm[0])
  25 + .html(id_nm[1]);
  26 + if(selected==id_nm[0]){
  27 + opt.prop("selected", true);
  28 + }
  29 + state_select.append(opt);
  30 + });
  31 + state_select.prop("disabled", false).show();
  32 + state_input.hide().prop("disabled", true);
  33 +
  34 + } else {
  35 + state_input.prop("disabled", false).show();
  36 + state_select.hide().prop("disabled", true);
  37 + }
  38 +
  39 + };
  40 +
  41 + $('p#bcountry select').change(function() { update_state('b'); });
  42 + $('p#scountry select').change(function() { update_state('s'); });
  43 + update_state('b');
  44 + update_state('s');
  45 +
  46 + $('input#order_use_billing').click(function() {
  47 + if($(this).is(':checked')) {
  48 + $('#shipping .inner').hide();
  49 + $('#shipping .inner input, #shipping .inner select').prop("disabled", true);
  50 + } else {
  51 + $('#shipping .inner').show();
  52 + $('#shipping .inner input, #shipping .inner select').prop("disabled", false);
  53 + //only want to enable relevant field
  54 + if(get_states('s')){
  55 + $('span#sstate input').hide().prop("disabled", true);
  56 + }else{
  57 + $('span#sstate select').hide().prop("disabled", true);
  58 + }
  59 +
  60 + }
  61 + }).triggerHandler('click');
  62 + }
  63 +
  64 + if($('#checkout_form_payment').is('*')){
  65 + // Show fields for the selected payment method
  66 + $("input[type='radio'][name='order[payments_attributes][][payment_method_id]']").click(function(){
  67 + $('#payment-methods li').hide();
  68 + if(this.checked){ $('#payment_method_'+this.value).show(); }
  69 + }).triggerHandler('click');
  70 + }
  71 + });
  72 +})(jQuery);
3  app/assets/stylesheets/store/spree_stripe.css
... ... @@ -0,0 +1,3 @@
  1 +/*
  2 + *= require store/spree_core
  3 +*/
10 app/models/gateway/stripe.rb
... ... @@ -0,0 +1,10 @@
  1 +class Gateway::Stripe < Gateway
  2 + preference :login, :string
  3 +
  4 + def provider_class
  5 + ActiveMerchant::Billing::StripeGateway
  6 + end
  7 + def payment_profiles_supported?
  8 + false
  9 + end
  10 +end
3  config/routes.rb
... ... @@ -0,0 +1,3 @@
  1 +Rails.application.routes.draw do
  2 + # Add your extension routes here
  3 +end
29 lib/generators/spree_stripe/install/install_generator.rb
... ... @@ -0,0 +1,29 @@
  1 +module SpreeStripe
  2 + module Generators
  3 + class InstallGenerator < Rails::Generators::Base
  4 +
  5 + def add_javascripts
  6 + append_file "app/assets/javascripts/store/all.js", "//= require store/spree_stripe\n"
  7 + append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_stripe\n"
  8 + end
  9 +
  10 + def add_stylesheets
  11 + inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_stripe\n", :before => /\*\//, :verbose => true
  12 + inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_stripe\n", :before => /\*\//, :verbose => true
  13 + end
  14 +
  15 + def add_migrations
  16 + run 'bundle exec rake railties:install:migrations FROM=spree_stripe'
  17 + end
  18 +
  19 + def run_migrations
  20 + res = ask "Would you like to run the migrations now? [Y/n]"
  21 + if res == "" || res.downcase == "y"
  22 + run 'bundle exec rake db:migrate'
  23 + else
  24 + puts "Skiping rake db:migrate, don't forget to run it!"
  25 + end
  26 + end
  27 + end
  28 + end
  29 +end
2  lib/spree_stripe.rb
... ... @@ -0,0 +1,2 @@
  1 +require 'spree_core'
  2 +require 'spree_stripe/engine'
28 lib/spree_stripe/engine.rb
... ... @@ -0,0 +1,28 @@
  1 +module SpreeStripe
  2 + class Engine < Rails::Engine
  3 + engine_name 'spree_stripe'
  4 +
  5 + config.autoload_paths += %W(#{config.root}/lib)
  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.application.config.cache_classes ? require(c) : load(c)
  15 + end
  16 +
  17 + Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
  18 + Rails.application.config.cache_classes ? require(c) : load(c)
  19 + end
  20 + end
  21 + initializer "spree_stripe.register.payment_methods" do |app|
  22 + app.config.spree.payment_methods += [
  23 + Gateway::Stripe
  24 + ]
  25 + end
  26 + config.to_prepare &method(:activate).to_proc
  27 + end
  28 +end
9 script/rails
... ... @@ -0,0 +1,9 @@
  1 +#!/usr/bin/env ruby
  2 +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
  3 +
  4 +
  5 +ENGINE_PATH = File.expand_path('../..', __FILE__)
  6 +APP_PATH = File.expand_path('../../../config/application', __FILE__)
  7 +require File.expand_path('../../../config/boot', __FILE__)
  8 +require 'rails/commands'
  9 +
31 spec/spec_helper.rb
... ... @@ -0,0 +1,31 @@
  1 +# Configure Rails Environment
  2 +ENV["RAILS_ENV"] = "test"
  3 +
  4 +
  5 +require File.expand_path("../../../config/environment.rb", __FILE__)
  6 +
  7 +
  8 +require 'rspec/rails'
  9 +
  10 +# Requires supporting ruby files with custom matchers and macros, etc,
  11 +# in spec/support/ and its subdirectories.
  12 +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  13 +
  14 +RSpec.configure do |config|
  15 + # == Mock Framework
  16 + #
  17 + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  18 + #
  19 + # config.mock_with :mocha
  20 + # config.mock_with :flexmock
  21 + # config.mock_with :rr
  22 + config.mock_with :rspec
  23 +
  24 + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  25 + config.fixture_path = "#{::Rails.root}/spec/fixtures"
  26 +
  27 + # If you're not using ActiveRecord, or you'd prefer not to run each of your
  28 + # examples within a transaction, remove the following line or assign false
  29 + # instead of true.
  30 + config.use_transactional_fixtures = true
  31 +end
23 spree_stripe.gemspec
... ... @@ -0,0 +1,23 @@
  1 +# encoding: UTF-8
  2 +Gem::Specification.new do |s|
  3 + s.platform = Gem::Platform::RUBY
  4 + s.name = 'spree_stripe'
  5 + s.version = '0.70.1'
  6 + s.summary = 'Add gem summary here'
  7 + s.description = 'Add (optional) gem description here'
  8 + s.required_ruby_version = '>= 1.8.7'
  9 +
  10 + # s.author = 'David Heinemeier Hansson'
  11 + # s.email = 'david@loudthinking.com'
  12 + # s.homepage = 'http://www.rubyonrails.org'
  13 + # s.rubyforge_project = 'actionmailer'
  14 +
  15 + #s.files = `git ls-files`.split("\n")
  16 + #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
  17 + s.require_path = 'lib'
  18 + s.requirements << 'none'
  19 +
  20 + s.add_dependency 'spree_core', '>= 0.70.1'
  21 + s.add_development_dependency 'rspec-rails'
  22 +end
  23 +

0 comments on commit 1aeb66f

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