portal_module 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/Gemfile +13 -0
- data/Guardfile +24 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +240 -0
- data/Rakefile +101 -0
- data/bin/portal_module +10 -0
- data/lib/portal_module/assertable.rb +37 -0
- data/lib/portal_module/cli.rb +35 -0
- data/lib/portal_module/client.rb +110 -0
- data/lib/portal_module/command/client_access.rb +41 -0
- data/lib/portal_module/command/config.rb +323 -0
- data/lib/portal_module/command/dts.rb +70 -0
- data/lib/portal_module/command/loan_entry.rb +66 -0
- data/lib/portal_module/command.rb +16 -0
- data/lib/portal_module/config_helper.rb +32 -0
- data/lib/portal_module/dts.rb +99 -0
- data/lib/portal_module/loan_entry.rb +101 -0
- data/lib/portal_module/page_factory.rb +27 -0
- data/lib/portal_module/pages/data_transformation_page.rb +84 -0
- data/lib/portal_module/pages/login_page.rb +73 -0
- data/lib/portal_module/pages/prequal_setup_page.rb +77 -0
- data/lib/portal_module/pages.rb +90 -0
- data/lib/portal_module/rake/dts_tasks.rb +166 -0
- data/lib/portal_module/rake/loan_entry_tasks.rb +166 -0
- data/lib/portal_module/rake.rb +16 -0
- data/lib/portal_module/version.rb +3 -0
- data/lib/portal_module.rb +251 -0
- data/portal_module.gemspec +33 -0
- data/spec/data/dts_import.xml +1 -0
- data/spec/data/le_import.xml +1 -0
- data/spec/lib/portal_module/cli_spec.rb +35 -0
- data/spec/lib/portal_module/client_spec.rb +126 -0
- data/spec/lib/portal_module/command/config_spec.rb +474 -0
- data/spec/lib/portal_module/command/dts_spec.rb +98 -0
- data/spec/lib/portal_module/command/loan_entry_spec.rb +98 -0
- data/spec/lib/portal_module/dts_spec.rb +145 -0
- data/spec/lib/portal_module/loan_entry_spec.rb +113 -0
- data/spec/lib/portal_module_spec.rb +175 -0
- data/spec/spec_helper.rb +52 -0
- data/spec/support/asserts.rb +10 -0
- data/spec/support/dirs.rb +53 -0
- data/spec/support/helpers.rb +44 -0
- data/spec/support/mocks.rb +106 -0
- metadata +247 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: login_page.rb
|
3
|
+
# Purpose:: Login page for Portal Module
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-28
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
require 'page-object'
|
9
|
+
|
10
|
+
module PortalModule::Pages
|
11
|
+
|
12
|
+
class LoginPage
|
13
|
+
include PageObject
|
14
|
+
|
15
|
+
page_url(:get_dynamic_url)
|
16
|
+
|
17
|
+
def get_dynamic_url
|
18
|
+
PortalModule.configuration.base_url
|
19
|
+
end
|
20
|
+
|
21
|
+
text_field(:username, :id => "ctl00_ContentPlaceHolder1_Login1_txtUserName" )
|
22
|
+
text_field(:password_mask, :id => "ctl00_ContentPlaceHolder1_Login1_txtPasswordMask" )
|
23
|
+
text_field(:password, :id => "ctl00_ContentPlaceHolder1_Login1_txtPassword" )
|
24
|
+
button(:login, :id => "ctl00_ContentPlaceHolder1_Login1_btnLogin" )
|
25
|
+
|
26
|
+
def login_as(username, password)
|
27
|
+
if !self.username? && current_url == PortalModule.configuration.base_url + '/User/AppLogin.aspx'
|
28
|
+
# We're still logged in.
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
raise ArgumentError.new("Missing username for login.\nHave you set the HSBC_envname_USER environment variable?") if username.nil?
|
33
|
+
|
34
|
+
raise ArgumentError.new("Missing password for login.\nHave you set the HSBC_envname_PASSWORD environment variable?") if password.nil?
|
35
|
+
|
36
|
+
unless current_url.downcase.include? get_dynamic_url.downcase
|
37
|
+
navigate_to get_dynamic_url
|
38
|
+
end
|
39
|
+
|
40
|
+
self.username = username
|
41
|
+
|
42
|
+
allow_password_entry
|
43
|
+
|
44
|
+
self.password = password
|
45
|
+
login
|
46
|
+
end
|
47
|
+
|
48
|
+
def logout
|
49
|
+
navigate_to get_dynamic_url + '/User/AppLogout.aspx'
|
50
|
+
end
|
51
|
+
|
52
|
+
def allow_password_entry
|
53
|
+
# We used to have to click on the password mask before the page would let us enter the password itself:
|
54
|
+
#
|
55
|
+
# # For some unknown reason, we must click on a password mask input before
|
56
|
+
# # we can access the password field itself.
|
57
|
+
# password_mask_element.click
|
58
|
+
#
|
59
|
+
# Now, we have to use javascript to hide the mask and display the password field.
|
60
|
+
hide_mask_script = <<EOS
|
61
|
+
pwdmasks = document.getElementsByClassName('passwordmask');
|
62
|
+
pwdmasks[0].style.display = 'none';
|
63
|
+
pwds = document.getElementsByClassName('password');
|
64
|
+
pwds[0].style.display = 'block';
|
65
|
+
EOS
|
66
|
+
|
67
|
+
@browser.execute_script(hide_mask_script)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end # module Pages
|
73
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: prequal_setup_page.rb
|
3
|
+
# Purpose:: Loan Entry Setup page for PortalModule
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-28
|
6
|
+
##############################################################################
|
7
|
+
require 'page-object'
|
8
|
+
|
9
|
+
module PortalModule::Pages
|
10
|
+
|
11
|
+
class PrequalSetupPage
|
12
|
+
include PageObject
|
13
|
+
|
14
|
+
# If page_url is not set, page_object will not navigate to this page
|
15
|
+
# when visit is true.
|
16
|
+
page_url(:get_dynamic_url)
|
17
|
+
|
18
|
+
def get_dynamic_url
|
19
|
+
PortalModule.configuration.url(PrequalSetupPage)
|
20
|
+
end
|
21
|
+
|
22
|
+
span(:viewing_span,
|
23
|
+
id: 'ctl00_ContentPlaceHolder1_lblOrganizationName')
|
24
|
+
|
25
|
+
button(:activate_button,
|
26
|
+
id: 'ctl00_ContentPlaceHolder1_btnVersion')
|
27
|
+
|
28
|
+
button(:download_button,
|
29
|
+
id: 'ctl00_ContentPlaceHolder1_btnDownload')
|
30
|
+
|
31
|
+
# Search Orgs
|
32
|
+
text_field(:search_text,
|
33
|
+
id: 'ctl00_ContentPlaceHolder1_txtSrchText')
|
34
|
+
|
35
|
+
button(:search_button,
|
36
|
+
id: 'ctl00_ContentPlaceHolder1_btnSearch')
|
37
|
+
|
38
|
+
# File Upload
|
39
|
+
file_field(:file_input,
|
40
|
+
id: 'ctl00_ContentPlaceHolder1_hdnFileUploader')
|
41
|
+
|
42
|
+
button(:upload_button,
|
43
|
+
id: 'ctl00_ContentPlaceHolder1_btnUploadXMLFile')
|
44
|
+
|
45
|
+
|
46
|
+
def activate
|
47
|
+
self.activate_button
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def download
|
52
|
+
self.download_button
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_org org_string
|
57
|
+
org_name = org_string.split('~')[1]
|
58
|
+
return self if viewing_span == org_name
|
59
|
+
|
60
|
+
self.search_text = org_string
|
61
|
+
self.search_button
|
62
|
+
|
63
|
+
viewing_span_element.wait_until(120, "Org not loaded - #{org_name}") do
|
64
|
+
viewing_span == org_name
|
65
|
+
end
|
66
|
+
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
def upload file_path
|
71
|
+
self.file_input = file_path
|
72
|
+
self.upload_button
|
73
|
+
self
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end # module
|
77
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: pages.rb
|
3
|
+
# Purpose:: Require all Page classes
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-28
|
6
|
+
##############################################################################
|
7
|
+
|
8
|
+
require 'watir-webdriver'
|
9
|
+
require 'ktutils/os'
|
10
|
+
require 'portal_module/pages/login_page'
|
11
|
+
require 'portal_module/pages/data_transformation_page'
|
12
|
+
require 'portal_module/pages/prequal_setup_page'
|
13
|
+
|
14
|
+
module PortalModule::Pages
|
15
|
+
|
16
|
+
##
|
17
|
+
# Return a configured browser object. If a browser has already been created,
|
18
|
+
# this returns the existing browser.
|
19
|
+
#
|
20
|
+
# An +at_exit+ proc is created to close the browser when the program exits.
|
21
|
+
|
22
|
+
def browser
|
23
|
+
if @browser.nil?
|
24
|
+
@browser = configure_browser
|
25
|
+
|
26
|
+
at_exit do
|
27
|
+
@browser.close unless @browser.nil?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@browser
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def chromium_exe
|
37
|
+
if Ktutils::OS.windows?
|
38
|
+
# Downloaded from http://chromium.woolyss.com/
|
39
|
+
# Package: Chromium Package (32-bit)
|
40
|
+
# Version: 37.0.2011.0 (272392)
|
41
|
+
chromium_exe = File.absolute_path(File.join(__FILE__, '../../../bin/chrome-win32/chrome.exe'))
|
42
|
+
else
|
43
|
+
chromium_exe = `which chromium-browser`.chomp
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def configure_browser
|
48
|
+
# Specify chrome browser capabilities.
|
49
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome
|
50
|
+
caps['chromeOptions'] = {'binary' => chromium_exe }
|
51
|
+
#caps['chromeOptions'] = {'binary' => '/opt/bin/test/chrome-27.0.1453.94.exe' }
|
52
|
+
# See http://peter.sh/experiments/chromium-command-line-switches/ for a list of available switches.
|
53
|
+
# See https://sites.google.com/a/chromium.org/chromedriver/capabilities for details on setting ChromeDriver caps.
|
54
|
+
|
55
|
+
# NOTE: The only way I've found to stop the EULA from being displayed is to
|
56
|
+
# use the user-data-dir switch and point to a dir where chrome can put the
|
57
|
+
# data indicating it (EULA) has already been accepted.
|
58
|
+
|
59
|
+
# Store chrome profile at test/chrome-data.
|
60
|
+
# user_data_dir must be expanded to a full (absolute) path. A relative path
|
61
|
+
# results in chromedriver failing to start.
|
62
|
+
user_data_dir = File.expand_path('test/chrome-data')
|
63
|
+
#puts "*** user_data_dir location: #{user_data_dir}"
|
64
|
+
|
65
|
+
# Create the data dir if it doesn't exist (or chromedriver fails to start).
|
66
|
+
unless File.exists?(user_data_dir) and File.directory?(user_data_dir)
|
67
|
+
FileUtils.makedirs user_data_dir
|
68
|
+
end
|
69
|
+
|
70
|
+
# ignore-certificate-errors: Ignores certificate-related errors.
|
71
|
+
# disable-popup-blocking: Disable pop-up blocking.
|
72
|
+
# disable-translate: Allows disabling of translate from the command line to assist with automated browser testing
|
73
|
+
# no-first-run: Skip First Run tasks, whether or not it's actually the First Run.
|
74
|
+
# log-level: Sets the minimum log level. Valid values are from 0 to 3: INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3.
|
75
|
+
switches = %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate --no-first-run --log-level=3]
|
76
|
+
switches << "--user-data-dir=#{user_data_dir}"
|
77
|
+
|
78
|
+
# Create a client so we can adjust the timeout period.
|
79
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
80
|
+
|
81
|
+
# Set the browser timeout. Default is 60 seconds.
|
82
|
+
client.timeout = PortalModule.configuration.browser_timeout
|
83
|
+
|
84
|
+
browser = Watir::Browser.new :chrome,
|
85
|
+
:switches => switches,
|
86
|
+
:http_client => client,
|
87
|
+
:service_log_path => user_data_dir + '/chromedriver.out',
|
88
|
+
:desired_capabilities => caps
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: dts_tasks.rb
|
3
|
+
# Purpose:: DtsTasks definition
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-29
|
6
|
+
#
|
7
|
+
##############################################################################
|
8
|
+
|
9
|
+
require 'portal_module'
|
10
|
+
require 'rake/dsl_definition'
|
11
|
+
require 'rake'
|
12
|
+
|
13
|
+
module PortalModule::Rake
|
14
|
+
|
15
|
+
class DtsTasks
|
16
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
17
|
+
|
18
|
+
attr_accessor :env
|
19
|
+
attr_accessor :org
|
20
|
+
attr_accessor :path
|
21
|
+
attr_reader :action
|
22
|
+
attr_reader :valid_actions
|
23
|
+
attr_reader :stop_on_exception
|
24
|
+
|
25
|
+
def initialize(task_name = 'dts_task', desc = "Modify a DTS configuration")
|
26
|
+
@valid_actions = ['upload', 'download']
|
27
|
+
@task_name, @desc = task_name, desc
|
28
|
+
|
29
|
+
@stop_on_exception = true
|
30
|
+
|
31
|
+
yield self if block_given?
|
32
|
+
|
33
|
+
define_task
|
34
|
+
end
|
35
|
+
|
36
|
+
def define_task #:nodoc:
|
37
|
+
desc @desc
|
38
|
+
task(@task_name, required_args_for_action) do |t,args|
|
39
|
+
set_vars args
|
40
|
+
commit # Call method to perform when invoked.
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_vars args
|
45
|
+
args.each do |arg,val|
|
46
|
+
instance_variable_set "@#{arg}", val
|
47
|
+
end
|
48
|
+
|
49
|
+
args
|
50
|
+
end
|
51
|
+
|
52
|
+
def action=(task_action)
|
53
|
+
raise "action must be one of #{valid_types.join(', ')}" unless valid_actions.include?(task_action.downcase)
|
54
|
+
@action = task_action
|
55
|
+
end
|
56
|
+
|
57
|
+
def stop_on_exception=(do_stop)
|
58
|
+
raise ArgumentError, 'Expecting true or false' unless do_stop === true || do_stop === false
|
59
|
+
@stop_on_exception = do_stop
|
60
|
+
end
|
61
|
+
|
62
|
+
def commit
|
63
|
+
validate_params
|
64
|
+
|
65
|
+
client = PortalModule::Client.new
|
66
|
+
client.env = env
|
67
|
+
|
68
|
+
if self.respond_to? action
|
69
|
+
self.send(action, client)
|
70
|
+
return
|
71
|
+
else
|
72
|
+
raise "Unknown action - #{action}"
|
73
|
+
end
|
74
|
+
|
75
|
+
rescue Exception => e
|
76
|
+
raise e if stop_on_exception == true
|
77
|
+
ensure
|
78
|
+
client.quit unless client.nil?
|
79
|
+
end
|
80
|
+
|
81
|
+
def upload client
|
82
|
+
client.dts.upload org, path
|
83
|
+
end
|
84
|
+
|
85
|
+
def download client
|
86
|
+
client.dts.download org, path
|
87
|
+
end
|
88
|
+
|
89
|
+
def default_params
|
90
|
+
end
|
91
|
+
|
92
|
+
def validate_params
|
93
|
+
assert_provided env, 'Missing "env"'
|
94
|
+
assert_provided action, 'Missing "action"'
|
95
|
+
|
96
|
+
default_params
|
97
|
+
|
98
|
+
assert_provided path, 'Missing "path"'
|
99
|
+
assert_provided org, 'Missing "org"'
|
100
|
+
|
101
|
+
assert_env_is_configured env
|
102
|
+
assert_org_is_configured org
|
103
|
+
end
|
104
|
+
|
105
|
+
def assert_provided value, msg
|
106
|
+
if value.nil? || value.empty?
|
107
|
+
raise msg
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def assert_env_is_configured arg
|
112
|
+
unless PortalModule.configuration.credentials.key? arg
|
113
|
+
init_msg = "Have you initialized your config file?\n Try: portal_module config init <filedir>"
|
114
|
+
env_msg = "Have you configured your environments?\n Try: portal_module config add env <envname> <url>"
|
115
|
+
raise "Unknown environment: #{arg}\n#{init_msg}\n\n#{env_msg}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def assert_org_is_configured arg
|
120
|
+
unless PortalModule.configuration.orgs.key? arg
|
121
|
+
init_msg = "Have you initialized your config file?\n Try: portal_module config init <filedir>"
|
122
|
+
env_msg = "Have you configured your orgs?\n Try: portal_module config add org <orgname> <orgid>"
|
123
|
+
raise "Unknown org: #{arg}\n#{init_msg}\n\n#{env_msg}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def required_args_for_action
|
128
|
+
args = []
|
129
|
+
|
130
|
+
case action
|
131
|
+
when 'upload'
|
132
|
+
args << :org
|
133
|
+
args << :path
|
134
|
+
|
135
|
+
when 'download'
|
136
|
+
args << :org
|
137
|
+
args << :path
|
138
|
+
|
139
|
+
else
|
140
|
+
# Noop
|
141
|
+
end
|
142
|
+
|
143
|
+
args
|
144
|
+
end
|
145
|
+
|
146
|
+
class << self
|
147
|
+
def install
|
148
|
+
new.install
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def install
|
153
|
+
PortalModule.configuration.credentials.keys.each do |e|
|
154
|
+
valid_actions.each do |action|
|
155
|
+
PortalModule::Rake::DtsTasks.new("pm:#{e}:dts:#{action}", "#{action} a #{e} DTS configuration") do |t|
|
156
|
+
t.env = e
|
157
|
+
t.action = action
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end # class
|
163
|
+
end # module
|
164
|
+
|
165
|
+
PortalModule::Rake::DtsTasks.install
|
166
|
+
|
@@ -0,0 +1,166 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: loan_entry_tasks.rb
|
3
|
+
# Purpose:: LoanEntryTasks definition
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 2015-03-29
|
6
|
+
#
|
7
|
+
##############################################################################
|
8
|
+
|
9
|
+
require 'portal_module'
|
10
|
+
require 'rake/dsl_definition'
|
11
|
+
require 'rake'
|
12
|
+
|
13
|
+
module PortalModule::Rake
|
14
|
+
|
15
|
+
class LoanEntryTasks
|
16
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
17
|
+
|
18
|
+
attr_accessor :env
|
19
|
+
attr_accessor :org
|
20
|
+
attr_accessor :path
|
21
|
+
attr_reader :action
|
22
|
+
attr_reader :valid_actions
|
23
|
+
attr_reader :stop_on_exception
|
24
|
+
|
25
|
+
def initialize(task_name = 'loan_entry_task', desc = "Modify a Loan Entry configuration")
|
26
|
+
@valid_actions = ['upload', 'download']
|
27
|
+
@task_name, @desc = task_name, desc
|
28
|
+
|
29
|
+
@stop_on_exception = true
|
30
|
+
|
31
|
+
yield self if block_given?
|
32
|
+
|
33
|
+
define_task
|
34
|
+
end
|
35
|
+
|
36
|
+
def define_task #:nodoc:
|
37
|
+
desc @desc
|
38
|
+
task(@task_name, required_args_for_action) do |t,args|
|
39
|
+
set_vars args
|
40
|
+
commit # Call method to perform when invoked.
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_vars args
|
45
|
+
args.each do |arg,val|
|
46
|
+
instance_variable_set "@#{arg}", val
|
47
|
+
end
|
48
|
+
|
49
|
+
args
|
50
|
+
end
|
51
|
+
|
52
|
+
def action=(task_action)
|
53
|
+
raise "action must be one of #{valid_types.join(', ')}" unless valid_actions.include?(task_action.downcase)
|
54
|
+
@action = task_action
|
55
|
+
end
|
56
|
+
|
57
|
+
def stop_on_exception=(do_stop)
|
58
|
+
raise ArgumentError, 'Expecting true or false' unless do_stop === true || do_stop === false
|
59
|
+
@stop_on_exception = do_stop
|
60
|
+
end
|
61
|
+
|
62
|
+
def commit
|
63
|
+
validate_params
|
64
|
+
|
65
|
+
client = PortalModule::Client.new
|
66
|
+
client.env = env
|
67
|
+
|
68
|
+
if self.respond_to? action
|
69
|
+
self.send(action, client)
|
70
|
+
return
|
71
|
+
else
|
72
|
+
raise "Unknown action - #{action}"
|
73
|
+
end
|
74
|
+
|
75
|
+
rescue Exception => e
|
76
|
+
raise e if stop_on_exception == true
|
77
|
+
ensure
|
78
|
+
client.quit unless client.nil?
|
79
|
+
end
|
80
|
+
|
81
|
+
def upload client
|
82
|
+
client.loan_entry.upload org, path
|
83
|
+
end
|
84
|
+
|
85
|
+
def download client
|
86
|
+
client.loan_entry.download org, path
|
87
|
+
end
|
88
|
+
|
89
|
+
def default_params
|
90
|
+
end
|
91
|
+
|
92
|
+
def validate_params
|
93
|
+
assert_provided env, 'Missing "env"'
|
94
|
+
assert_provided action, 'Missing "action"'
|
95
|
+
|
96
|
+
default_params
|
97
|
+
|
98
|
+
assert_provided path, 'Missing "path"'
|
99
|
+
assert_provided org, 'Missing "org"'
|
100
|
+
|
101
|
+
assert_env_is_configured env
|
102
|
+
assert_org_is_configured org
|
103
|
+
end
|
104
|
+
|
105
|
+
def assert_provided value, msg
|
106
|
+
if value.nil? || value.empty?
|
107
|
+
raise msg
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def assert_env_is_configured arg
|
112
|
+
unless PortalModule.configuration.credentials.key? arg
|
113
|
+
init_msg = "Have you initialized your config file?\n Try: portal_module config init <filedir>"
|
114
|
+
env_msg = "Have you configured your environments?\n Try: portal_module config add env <envname> <url>"
|
115
|
+
raise "Unknown environment: #{arg}\n#{init_msg}\n\n#{env_msg}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def assert_org_is_configured arg
|
120
|
+
unless PortalModule.configuration.orgs.key? arg
|
121
|
+
init_msg = "Have you initialized your config file?\n Try: portal_module config init <filedir>"
|
122
|
+
env_msg = "Have you configured your orgs?\n Try: portal_module config add org <orgname> <orgid>"
|
123
|
+
raise "Unknown org: #{arg}\n#{init_msg}\n\n#{env_msg}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def required_args_for_action
|
128
|
+
args = []
|
129
|
+
|
130
|
+
case action
|
131
|
+
when 'upload'
|
132
|
+
args << :org
|
133
|
+
args << :path
|
134
|
+
|
135
|
+
when 'download'
|
136
|
+
args << :org
|
137
|
+
args << :path
|
138
|
+
|
139
|
+
else
|
140
|
+
# Noop
|
141
|
+
end
|
142
|
+
|
143
|
+
args
|
144
|
+
end
|
145
|
+
|
146
|
+
class << self
|
147
|
+
def install
|
148
|
+
new.install
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def install
|
153
|
+
PortalModule.configuration.credentials.keys.each do |e|
|
154
|
+
valid_actions.each do |action|
|
155
|
+
PortalModule::Rake::LoanEntryTasks.new("pm:#{e}:loan_entry:#{action}", "#{action} a #{e} loan entry configuration") do |t|
|
156
|
+
t.env = e
|
157
|
+
t.action = action
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end # class
|
163
|
+
end # module
|
164
|
+
|
165
|
+
PortalModule::Rake::LoanEntryTasks.install
|
166
|
+
|