atmos-braintree_transparent_redirect_slice 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/LICENSE +20 -0
  2. data/README +41 -0
  3. data/Rakefile +65 -0
  4. data/TODO +15 -0
  5. data/app/controllers/application.rb +5 -0
  6. data/app/controllers/credit_cards.rb +54 -0
  7. data/app/controllers/main.rb +7 -0
  8. data/app/controllers/payments.rb +17 -0
  9. data/app/helpers/application_helper.rb +63 -0
  10. data/app/helpers/credit_cards_helper.rb +15 -0
  11. data/app/models/braintree/gateway_request.rb +55 -0
  12. data/app/models/braintree/gateway_response.rb +101 -0
  13. data/app/models/braintree/query.rb +46 -0
  14. data/app/models/braintree/transaction_info.rb +20 -0
  15. data/app/models/credit_card.rb +18 -0
  16. data/app/models/credit_card_info.rb +31 -0
  17. data/app/models/credit_card_invoice.rb +15 -0
  18. data/app/views/braintree_transparent_redirect_slice/credit_cards/_form.html.haml +27 -0
  19. data/app/views/braintree_transparent_redirect_slice/credit_cards/_gateway_request.html.haml +6 -0
  20. data/app/views/braintree_transparent_redirect_slice/credit_cards/destroy.html.haml +8 -0
  21. data/app/views/braintree_transparent_redirect_slice/credit_cards/edit.html.haml +8 -0
  22. data/app/views/braintree_transparent_redirect_slice/credit_cards/index.html.haml +26 -0
  23. data/app/views/braintree_transparent_redirect_slice/credit_cards/new.html.haml +9 -0
  24. data/app/views/braintree_transparent_redirect_slice/credit_cards/show.html.haml +33 -0
  25. data/app/views/braintree_transparent_redirect_slice/payments/index.html.haml +2 -0
  26. data/app/views/braintree_transparent_redirect_slice/payments/new.html.haml +21 -0
  27. data/app/views/layout/braintree_transparent_redirect_slice.html.haml +26 -0
  28. data/app/views/main/index.html.haml +1 -0
  29. data/lib/braintree_transparent_redirect_slice.rb +103 -0
  30. data/lib/braintree_transparent_redirect_slice/merbtasks.rb +103 -0
  31. data/lib/braintree_transparent_redirect_slice/slicetasks.rb +20 -0
  32. data/lib/braintree_transparent_redirect_slice/spectasks.rb +53 -0
  33. data/lib/braintree_transparent_redirect_slice/version.rb +3 -0
  34. data/public/javascripts/master.js +6 -0
  35. data/public/stylesheets/master.css +153 -0
  36. data/spec/fixtures/user.rb +24 -0
  37. data/spec/models/credit_card_info_spec.rb +30 -0
  38. data/spec/requests/credit_cards/adding_a_card_spec.rb +110 -0
  39. data/spec/requests/credit_cards/deleting_a_card_spec.rb +19 -0
  40. data/spec/requests/credit_cards/updating_a_card_spec.rb +56 -0
  41. data/spec/requests/main_spec.rb +14 -0
  42. data/spec/requests/payments/issuing_a_transaction_spec.rb +49 -0
  43. data/spec/spec_helper.rb +127 -0
  44. data/spec/spec_helpers/braintree/api_helper.rb +14 -0
  45. data/spec/spec_helpers/edit_form_helper.rb +34 -0
  46. data/stubs/app/controllers/application.rb +2 -0
  47. data/stubs/app/controllers/main.rb +2 -0
  48. metadata +212 -0
@@ -0,0 +1,46 @@
1
+ module Braintree
2
+ class Query
3
+ include LibXML
4
+ def self.xml_attrs(*args)
5
+ args.each do |xml_attr|
6
+ class_eval <<-METHOD_DEF
7
+ def #{xml_attr}
8
+ @#{xml_attr} = xml_attribute('#{xml_attr}')
9
+ end
10
+ METHOD_DEF
11
+ end
12
+ end
13
+
14
+ def xml_attribute(path)
15
+ result = @info.find("/nm_response/transaction/#{path}")
16
+ (result.nil?||result.first.nil?) ? '' : result.first.content
17
+ end
18
+
19
+ def initialize(query_params)
20
+ @query_params = query_params.merge({
21
+ 'username' => BraintreeTransparentRedirectSlice.config[:username],
22
+ 'password' => BraintreeTransparentRedirectSlice.config[:password]})
23
+ end
24
+
25
+ def run
26
+ uri = Addressable::URI.parse(BraintreeTransparentRedirectSlice.config[:query_api_url])
27
+
28
+ server = Net::HTTP.new(uri.host, 443)
29
+ server.use_ssl = true
30
+ server.read_timeout = 20
31
+ server.verify_mode = OpenSSL::SSL::VERIFY_NONE
32
+
33
+ resp = server.start do |http|
34
+ req = Net::HTTP::Post.new(uri.path)
35
+ req.set_form_data(@query_params)
36
+ http.request(req)
37
+ end
38
+ case resp
39
+ when Net::HTTPSuccess, Net::HTTPRedirection
40
+ result = LibXML::XML::Document.string(resp.body)
41
+ else
42
+ resp.error!
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ module Braintree
2
+ class TransactionInfo < Query
3
+ xml_attrs :first_name, :last_name, :email, :address_1, :city, :state, :postal_code, :country
4
+ xml_attrs :cc_number, :cc_exp
5
+
6
+ def initialize(transaction_id = nil)
7
+ super({:transaction_id => transaction_id, :transaction_type => 'cc', :action_type => 'sale'})
8
+ @transaction_id = transaction_id
9
+ @info = Braintree::Query.new(@query_params).run
10
+ end
11
+
12
+ def date
13
+ xml_attribute('action/date')
14
+ end
15
+
16
+ def amount
17
+ xml_attribute('action/amount')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ class CreditCard
2
+ include LibXML
3
+ include DataMapper::Resource
4
+
5
+ property :id, Serial
6
+ property :token, String, :nullable => false
7
+
8
+ belongs_to :user
9
+ # validates_is_unique :token, :scope => [:user_id]
10
+
11
+ def info
12
+ @info ||= CreditCardInfo.new(token)
13
+ end
14
+
15
+ def invoices
16
+ @invoices ||= CreditCardInvoice.parse(self)
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ class CreditCardInfo
2
+ include LibXML
3
+ attr_reader :name, :address
4
+
5
+ def initialize(token = nil)
6
+ params = { 'customer_vault_id' => token, 'report_type' => 'customer_vault'}
7
+ collect_card_info(Braintree::Query.new(params).run) unless token.nil? or token.blank?
8
+ end
9
+
10
+ def method_missing(sym, *args, &block)
11
+ begin
12
+ if %w(first_name last_name email address_1 city state postal_code country cc_exp cc_number).include?(sym.to_s)
13
+ fetch(@customer, sym.to_s)
14
+ end
15
+ rescue
16
+ super(sym, args, &block)
17
+ end
18
+ end
19
+
20
+ private
21
+ def collect_card_info(doc)
22
+ @customer = doc.find('/nm_response/customer_vault/customer').first
23
+ @name = "#{fetch(@customer,'first_name')} #{fetch(@customer,'last_name')}"
24
+ @address = "#{fetch(@customer,'address_1')} (#{fetch(@customer,'postal_code')})"
25
+ end
26
+
27
+ def fetch(node, name)
28
+ return '' if node.nil?
29
+ node.find(name).first.content
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ class CreditCardInvoice
2
+ include LibXML
3
+ attr_accessor :transaction_info
4
+ def self.parse(credit_card)
5
+ params = { 'customer_vault_id' => credit_card.token }
6
+
7
+ doc = Braintree::Query.new(params).run
8
+ doc.find('/nm_response/transaction').map do |node|
9
+ invoice = new
10
+ transaction_id = node.find('transaction_id').first.content
11
+ invoice.transaction_info = Braintree::TransactionInfo.new(transaction_id)
12
+ invoice
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ - info = @credit_card_info
2
+ = text_field :id => 'firstname', :name => 'firstname', :label => 'First Name', :value => info.first_name, :class => 'required'
3
+ = text_field :id => 'lastname', :name => 'lastname', :label => 'Last Name', :value => info.last_name, :class => 'required'
4
+ = text_field :id => 'email', :name => 'email', :value => info.email, :label => 'Email Address', :class => 'required'
5
+ = text_field :id => 'address1', :name => 'address1', :value => info.address_1, :label => 'Address', :class => 'required'
6
+ = text_field :id => 'city', :name => 'city', :value => info.city, :label => 'City', :class => 'required'
7
+ = text_field :id => 'state', :name => 'state', :value => info.state, :size => 2, :label => 'State', :class => 'required'
8
+ = text_field :id => 'zip', :name => 'zip', :value => info.postal_code, :label => 'Postal Code', :class => 'required'
9
+ = text_field :id => 'country', :name => 'country', :value => info.country, :label => 'Country', :class => 'required'
10
+
11
+ = partial "gateway_request"
12
+
13
+ - if @credit_card.new_record?
14
+ = text_field :id => 'ccnumber', :name => 'ccnumber', :value => '', :label => 'Credit Card Number', :class => 'required'
15
+ = text_field :id => 'cvv', :name => 'cvv', :value => '', :label => 'CVV', :class => 'required'
16
+ = text_field :id => 'ccexp', :name => 'ccexp', :value => info.cc_exp, :label => 'Expiration Date(MMYY)', :class => 'required'
17
+ = hidden_field :id => 'orderid', :name => 'orderid', :value => ''
18
+
19
+ - if @credit_card.new_record?
20
+ = hidden_field :id => 'customer_vault', :name => 'customer_vault', :value => 'add_customer'
21
+ = hidden_field :id => 'redirect', :name => 'redirect', :value => absolute_url(:new_response_credit_cards)
22
+ = hidden_field :id => 'type', :name => 'type', :value => 'sale'
23
+ = hidden_field :id => 'amount', :name => 'amount', :value => '10.00'
24
+ - else
25
+ = hidden_field :id => 'customer_vault', :name => 'customer_vault', :value => 'update_customer'
26
+ = hidden_field :id => 'customer_vault_id', :name => 'customer_vault_id', :value => @credit_card.token
27
+ = hidden_field :id => 'redirect', :name => 'redirect', :value => absolute_url(:edit_response_credit_card, @credit_card.id)
@@ -0,0 +1,6 @@
1
+ = hidden_field :id => 'payment', :name => 'payment', :value => 'creditcard'
2
+ = hidden_field :id => 'key_id', :name => 'key_id', :value => @gateway_request.key_id
3
+ = hidden_field :id => 'order_id', :name => 'order_id', :value => @gateway_request.orderid
4
+ = hidden_field :id => 'amount', :name => 'amount', :value => @gateway_request.amount
5
+ = hidden_field :id => 'time', :name => 'time', :value => @gateway_request.time
6
+ = hidden_field :id => 'hash', :name => 'hash', :value => @gateway_request.hash
@@ -0,0 +1,8 @@
1
+ = form :action => BraintreeTransparentRedirectSlice.config[:transact_api_url], :id => 'delete_vault_form' do
2
+ %fieldset
3
+ %legend I'm about to delete your billing information, are you sure you want to?
4
+ = partial "gateway_request"
5
+ = hidden_field :id => 'customer_vault', :name => 'customer_vault', :value => 'delete_customer'
6
+ = hidden_field :id => 'customer_vault_id', :name => 'customer_vault_id', :value => @credit_card.token
7
+ = hidden_field :id => 'redirect', :name => 'redirect', :value => absolute_url(:credit_cards)
8
+ %input{:type => 'submit', :name => 'submit', :value => 'Delete'}
@@ -0,0 +1,8 @@
1
+ #braintree-message
2
+ = message[:notice]
3
+ = form :action => BraintreeTransparentRedirectSlice.config[:transact_api_url], :id => 'edit_vault_form' do
4
+ %fieldset
5
+ %legend This is what you can update for this credit card
6
+ = partial "form"
7
+ %input{:type => 'submit', :name => 'submit', :value => 'Update'}
8
+
@@ -0,0 +1,26 @@
1
+ #braintree-message
2
+ = message[:notice]
3
+ %h2 Hey, here's what we know about your account
4
+ %hr
5
+ %h3 Cards Setup
6
+ - unless session.user.credit_cards.empty?
7
+ %table#braintree-card-info
8
+ %thead
9
+ %tr
10
+ %th Name
11
+ %th Address
12
+ %th Number
13
+ %th Show
14
+ %tbody
15
+ - session.user.credit_cards.each do |cc|
16
+ %tr
17
+ %td= cc.info.name
18
+ %td= cc.info.address
19
+ %td= cc.info.cc_number
20
+ %td= link_to('More Info', slice_url(:credit_card, cc))
21
+ %a{:href => slice_url(:new_credit_card)} Add another?
22
+ - else
23
+ %p
24
+ You don't have anything on file currently.
25
+ %a{:href => slice_url(:new_credit_card)} Add one now?
26
+ %hr
@@ -0,0 +1,9 @@
1
+ #braintree-message
2
+ = message[:notice]
3
+
4
+ = form :action => BraintreeTransparentRedirectSlice.config[:transact_api_url], :id => 'new_vault_form' do
5
+ %fieldset
6
+ %legend Add the necessary billing info below
7
+ = partial "form"
8
+ %input{:type => 'submit', :name => 'submit', :value => 'Submit'}
9
+
@@ -0,0 +1,33 @@
1
+ #braintree-message
2
+ = message[:notice]
3
+
4
+ %h3 This Card
5
+ %table
6
+ %thead
7
+ %tr
8
+ %th Name
9
+ %th Address
10
+ %th Number
11
+ %th Edit
12
+ %tbody
13
+ %tr
14
+ %td= @credit_card.info.name
15
+ %td= @credit_card.info.address
16
+ %td= @credit_card.info.cc_number
17
+ %td= link_to('Edit', url(:edit_credit_card, @credit_card))
18
+ %h3 Invoices
19
+ - unless @credit_card.invoices.empty?
20
+ %table
21
+ %thead
22
+ %tr
23
+ %th Date
24
+ %th Amount
25
+ %th Card
26
+ %tbody
27
+ - @credit_card.invoices.each do |invoice|
28
+ %tr
29
+ %td= braintree_date_reformatter(invoice.transaction_info.date)
30
+ %td= invoice.transaction_info.amount
31
+ %td= invoice.transaction_info.cc_number
32
+ - else
33
+ %p No invoices on file for this billing information.
@@ -0,0 +1,2 @@
1
+ %h2 Hey, here's what we know about your payments
2
+ %hr
@@ -0,0 +1,21 @@
1
+ #braintree-message
2
+ = message[:notice]
3
+
4
+ = form :action => BraintreeTransparentRedirectSlice.config[:transact_api_url], :id => 'new_payment_form' do
5
+ %fieldset
6
+ %legend You're about to be charged
7
+
8
+ %p
9
+ %span= @gateway_request.amount
10
+
11
+ = hidden_field :id => 'customer_vault_id', :name => 'customer_vault_id', :value => @credit_card.token
12
+ = hidden_field :id => 'type', :name => 'type', :value => 'sale'
13
+
14
+ = hidden_field :id => 'key_id', :name => 'key_id', :value => @gateway_request.key_id
15
+ = hidden_field :id => 'order_id', :name => 'order_id', :value => @gateway_request.orderid
16
+ = hidden_field :id => 'amount', :name => 'amount', :value => @gateway_request.amount
17
+ = hidden_field :id => 'time', :name => 'time', :value => @gateway_request.time
18
+ = hidden_field :id => 'hash', :name => 'hash', :value => @gateway_request.hash
19
+ = hidden_field :id => 'redirect', :name => 'redirect', :value => absolute_url(:new_response_credit_card_payments, @credit_card)
20
+ %input{:type => 'submit', :name => 'submit', :value => 'Submit'}
21
+
@@ -0,0 +1,26 @@
1
+ !!! 1.0
2
+ %html{:xmlns => "http://www.w3.org/1999/xhtml"}
3
+ %head
4
+ %base{:href => "#{request.protocol}://#{request.host}#{@base_tag}" }
5
+ %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" }
6
+ %meta{"http-equiv" => "Content-Language", :content => "en" }
7
+ %meta{:name => 'author', :content => "Corey Donohoe" }
8
+ %title Your Braintree Billing Information
9
+ %link{:href => public_path_for(:stylesheet, 'master.css')}
10
+ %script{:src => public_path_for(:javascript, 'master.js') }
11
+
12
+ %body
13
+ #container
14
+ #header-container
15
+ - if session.authenticated?
16
+ %h2= "Welcome, #{session.user.login}!"
17
+ %hr
18
+ #left-container
19
+ - if session.authenticated?
20
+ %ul
21
+ %li
22
+ %a{:href => '/'} Summary
23
+ #main-container
24
+ = message[:notice]
25
+ = catch_content :for_layout
26
+
@@ -0,0 +1 @@
1
+ <strong><%= slice.description %></strong> (v. <%= slice.version %>)
@@ -0,0 +1,103 @@
1
+ if defined?(Merb::Plugins)
2
+ $:.unshift File.dirname(__FILE__)
3
+
4
+ dependency 'merb-slices', :immediate => true
5
+ dependency 'libxml-ruby', '=0.9.7', :require_as => 'libxml'
6
+ dependency 'dm-core', '>=0.9.8'
7
+ dependency 'dm-validations', '>=0.9.8'
8
+ dependency 'merb-auth-core'
9
+ dependency 'merb-auth-more'
10
+ dependency 'merb-haml'
11
+ dependency 'merb-helpers'
12
+ dependency 'merb-assets'
13
+ dependency 'merb-action-args'
14
+ require 'net/https'
15
+
16
+ Merb::Plugins.add_rakefiles "braintree_transparent_redirect_slice/merbtasks", "braintree_transparent_redirect_slice/slicetasks", "braintree_transparent_redirect_slice/spectasks"
17
+
18
+ # Register the Slice for the current host application
19
+ Merb::Slices::register(__FILE__)
20
+
21
+ # Slice configuration - set this in a before_app_loads callback.
22
+ # By default a Slice uses its own layout, so you can swicht to
23
+ # the main application layout or no layout at all if needed.
24
+ #
25
+ # Configuration options:
26
+ # :layout - the layout to use; defaults to :braintree_transparent_redirect_slice
27
+ # :mirror - which path component types to use on copy operations; defaults to all
28
+ Merb::Slices::config[:braintree_transparent_redirect_slice][:layout] ||= :braintree_transparent_redirect_slice
29
+
30
+ # All Slice code is expected to be namespaced inside a module
31
+ module BraintreeTransparentRedirectSlice
32
+ # Slice metadata
33
+ self.description = "BraintreeTransparentRedirectSlice is like going to heaven and finding god smoking crack!"
34
+ self.version = BraintreeTransparentRedirectSlice::VERSION
35
+ self.author = "Corey Donohoe / Engine Yard"
36
+
37
+ # Stub classes loaded hook - runs before LoadClasses BootLoader
38
+ # right after a slice's classes have been loaded internally.
39
+ def self.loaded
40
+ end
41
+
42
+ def self.config
43
+ @config ||= { }
44
+ end
45
+
46
+ # Initialization hook - runs before AfterAppLoads BootLoader
47
+ def self.init
48
+ bt = YAML.load_file(Merb.root / 'config' / 'braintree.yml')
49
+ if bt[Merb.env]
50
+ bt[Merb.env].each do |k,v|
51
+ config[k.to_sym] = v
52
+ end
53
+ end
54
+ end
55
+
56
+ # Activation hook - runs after AfterAppLoads BootLoader
57
+ def self.activate
58
+ end
59
+
60
+ # Deactivation hook - triggered by Merb::Slices.deactivate(BraintreeTransparentRedirectSlice)
61
+ def self.deactivate
62
+ end
63
+
64
+ # Setup routes inside the host application
65
+ #
66
+ # @param scope<Merb::Router::Behaviour>
67
+ # Routes will be added within this scope (namespace). In fact, any
68
+ # router behaviour is a valid namespace, so you can attach
69
+ # routes at any level of your router setup.
70
+ #
71
+ # @note prefix your named routes with :braintree_transparent_redirect_slice_
72
+ # to avoid potential conflicts with global named routes.
73
+ def self.setup_router(scope)
74
+ scope.resources :credit_cards, :member => {:edit_response => :get},
75
+ :collection => {:new_response => :get} do |cards|
76
+ cards.resources :payments, :collection => {:new_response => :get}
77
+ end
78
+ # example of a named route
79
+ #scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
80
+ # the slice is mounted at /braintree_transparent_redirect_slice - note that it comes before default_routes
81
+ scope.match('/').to(:controller => :credit_cards).name(:braintree_home)
82
+ # enable slice-level default routes by default
83
+ # scope.default_routes
84
+ end
85
+ end
86
+
87
+ # Setup the slice layout for BraintreeTransparentRedirectSlice
88
+ #
89
+ # Use BraintreeTransparentRedirectSlice.push_path and BraintreeTransparentRedirectSlice.push_app_path
90
+ # to set paths to braintree_transparent_redirect_slice-level and app-level paths. Example:
91
+ #
92
+ # BraintreeTransparentRedirectSlice.push_path(:application, BraintreeTransparentRedirectSlice.root)
93
+ # BraintreeTransparentRedirectSlice.push_app_path(:application, Merb.root / 'slices' / 'braintree_transparent_redirect_slice')
94
+ Merb.push_path(:view, BraintreeTransparentRedirectSlice.root / "app" / "views", "**/*.rb")
95
+ # ...
96
+ #
97
+ # Any component path that hasn't been set will default to BraintreeTransparentRedirectSlice.root
98
+ #
99
+ # Or just call setup_default_structure! to setup a basic Merb MVC structure.
100
+ BraintreeTransparentRedirectSlice.setup_default_structure!
101
+ # Add dependencies for other BraintreeTransparentRedirectSlice classes below. Example:
102
+ # dependency "braintree_transparent_redirect_slice/other"
103
+ end
@@ -0,0 +1,103 @@
1
+ namespace :slices do
2
+ namespace :braintree_transparent_redirect_slice do
3
+
4
+ desc "Install BraintreeTransparentRedirectSlice"
5
+ task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
6
+
7
+ desc "Test for any dependencies"
8
+ task :preflight do # see slicetasks.rb
9
+ end
10
+
11
+ desc "Setup directories"
12
+ task :setup_directories do
13
+ puts "Creating directories for host application"
14
+ BraintreeTransparentRedirectSlice.mirrored_components.each do |type|
15
+ if File.directory?(BraintreeTransparentRedirectSlice.dir_for(type))
16
+ if !File.directory?(dst_path = BraintreeTransparentRedirectSlice.app_dir_for(type))
17
+ relative_path = dst_path.relative_path_from(Merb.root)
18
+ puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
19
+ mkdir_p(dst_path)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ # desc "Copy stub files to host application"
26
+ # task :stubs do
27
+ # puts "Copying stubs for BraintreeTransparentRedirectSlice - resolves any collisions"
28
+ # copied, preserved = BraintreeTransparentRedirectSlice.mirror_stubs!
29
+ # puts "- no files to copy" if copied.empty? && preserved.empty?
30
+ # copied.each { |f| puts "- copied #{f}" }
31
+ # preserved.each { |f| puts "! preserved override as #{f}" }
32
+ # end
33
+
34
+ # desc "Copy stub files and views to host application"
35
+ # task :patch => [ "stubs", "freeze:views" ]
36
+
37
+ desc "Copy public assets to host application"
38
+ task :copy_assets do
39
+ puts "Copying assets for BraintreeTransparentRedirectSlice - resolves any collisions"
40
+ copied, preserved = BraintreeTransparentRedirectSlice.mirror_public!
41
+ puts "- no files to copy" if copied.empty? && preserved.empty?
42
+ copied.each { |f| puts "- copied #{f}" }
43
+ preserved.each { |f| puts "! preserved override as #{f}" }
44
+ end
45
+
46
+ desc "Migrate the database"
47
+ task :migrate do # see slicetasks.rb
48
+ end
49
+
50
+ desc "Freeze BraintreeTransparentRedirectSlice into your app (only braintree_transparent_redirect_slice/app)"
51
+ task :freeze => [ "freeze:app" ]
52
+
53
+ namespace :freeze do
54
+
55
+ # desc "Freezes BraintreeTransparentRedirectSlice by installing the gem into application/gems"
56
+ # task :gem do
57
+ # ENV["GEM"] ||= "braintree_transparent_redirect_slice"
58
+ # Rake::Task['slices:install_as_gem'].invoke
59
+ # end
60
+
61
+ desc "Freezes BraintreeTransparentRedirectSlice by copying all files from braintree_transparent_redirect_slice/app to your application"
62
+ task :app do
63
+ puts "Copying all braintree_transparent_redirect_slice/app files to your application - resolves any collisions"
64
+ copied, preserved = BraintreeTransparentRedirectSlice.mirror_app!
65
+ puts "- no files to copy" if copied.empty? && preserved.empty?
66
+ copied.each { |f| puts "- copied #{f}" }
67
+ preserved.each { |f| puts "! preserved override as #{f}" }
68
+ end
69
+
70
+ desc "Freeze all views into your application for easy modification"
71
+ task :views do
72
+ puts "Copying all view templates to your application - resolves any collisions"
73
+ copied, preserved = BraintreeTransparentRedirectSlice.mirror_files_for :view
74
+ puts "- no files to copy" if copied.empty? && preserved.empty?
75
+ copied.each { |f| puts "- copied #{f}" }
76
+ preserved.each { |f| puts "! preserved override as #{f}" }
77
+ end
78
+
79
+ desc "Freeze all models into your application for easy modification"
80
+ task :models do
81
+ puts "Copying all models to your application - resolves any collisions"
82
+ copied, preserved = BraintreeTransparentRedirectSlice.mirror_files_for :model
83
+ puts "- no files to copy" if copied.empty? && preserved.empty?
84
+ copied.each { |f| puts "- copied #{f}" }
85
+ preserved.each { |f| puts "! preserved override as #{f}" }
86
+ end
87
+
88
+ desc "Freezes BraintreeTransparentRedirectSlice as a gem and copies over braintree_transparent_redirect_slice/app"
89
+ task :app_with_gem => [:gem, :app]
90
+
91
+ desc "Freezes BraintreeTransparentRedirectSlice by unpacking all files into your application"
92
+ task :unpack do
93
+ puts "Unpacking BraintreeTransparentRedirectSlice files to your application - resolves any collisions"
94
+ copied, preserved = BraintreeTransparentRedirectSlice.unpack_slice!
95
+ puts "- no files to copy" if copied.empty? && preserved.empty?
96
+ copied.each { |f| puts "- copied #{f}" }
97
+ preserved.each { |f| puts "! preserved override as #{f}" }
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+ end