Class: PaypalPermissions::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/paypal_permissions/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



58
59
60
# File 'lib/generators/paypal_permissions/install_generator.rb', line 58

def copy_initializer
  template "paypal_permissions.rb", "config/initializers/paypal_permissions.rb"
end

#copy_localeObject



62
63
64
65
# File 'lib/generators/paypal_permissions/install_generator.rb', line 62

def copy_locale
  # Nothing in the locales file yet, but once there is, just uncomment the following.
  # copy_file "../../../config/locales/en.yml", "config/locales/paypal_permissions.en.yml"
end

#show_readmeObject



67
68
69
# File 'lib/generators/paypal_permissions/install_generator.rb', line 67

def show_readme
  readme "README" if behavior == :invoke
end

#update_configurationObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/generators/paypal_permissions/install_generator.rb', line 9

def update_configuration
  dev_test_config = "\#{Rails.application.class.name.split('::').first}::Application.configure do\n  config.after_initialize do\n    ActiveMerchant::Billing::Base.mode = :test\n    permissions_options = {\n:login => 'TODO: your PayPal sandbox caller login',\n:password => 'TODO: your PayPal sandbox caller password',\n:signature => 'TODO: your PayPal sandbox caller signature',\n:app_id => 'APP-80W284485P519543T',  # This is the app_id for all PayPal Permissions Service sandbox test apps\n    }\n    ::PAYPAL_PERMISSIONS_GATEWAY = ActiveMerchant::Billing::PaypalPermissionsGateway.new(permissions_options)\n  end\nend\n  DEV_TEST_CONFIG\n\n  prod_config = <<-PROD_CONFIG\n\#{Rails.application.class.name.split('::').first}::Application.configure do\n  config.after_initialize do\n    ActiveMerchant::Billing::Base.mode = :production\n    permissions_options = {\n:login => 'TODO: your PayPal live caller login',\n:password => 'TODO: your PayPal live caller password',\n:signature => 'TODO: your PayPal live caller signature',\n:app_id => 'TODO: your PayPal live app id',\n    }\n    ::PAYPAL_PERMISSIONS_GATEWAY = ActiveMerchant::Billing::PaypalPermissionsGateway.new(permissions_options)\n  end\nend\n  PROD_CONFIG\n\n  # Don't use... \"application(nil, :env => \"development\") do\" here.\n  # Somewhere along the line, in the case where the :env parameter is supplied,\n  # railties went from using append_file to using inject_into_file after an env_file_sentinel,\n  # which changes the semantics drastically.\n  #\n  append_file(\"config/environments/development.rb\") do\n    \"\\n\#{dev_test_config}\"\n  end\n\n  append_file(\"config/environments/test.rb\") do\n    \"\\n\#{dev_test_config}\"\n  end\n\n  append_file(\"config/environments/production.rb\") do\n    \"\\n\#{prod_config}\"\n  end\nend\n"