portal_module 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +13 -0
  5. data/Guardfile +24 -0
  6. data/LICENSE +22 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +240 -0
  9. data/Rakefile +101 -0
  10. data/bin/portal_module +10 -0
  11. data/lib/portal_module/assertable.rb +37 -0
  12. data/lib/portal_module/cli.rb +35 -0
  13. data/lib/portal_module/client.rb +110 -0
  14. data/lib/portal_module/command/client_access.rb +41 -0
  15. data/lib/portal_module/command/config.rb +323 -0
  16. data/lib/portal_module/command/dts.rb +70 -0
  17. data/lib/portal_module/command/loan_entry.rb +66 -0
  18. data/lib/portal_module/command.rb +16 -0
  19. data/lib/portal_module/config_helper.rb +32 -0
  20. data/lib/portal_module/dts.rb +99 -0
  21. data/lib/portal_module/loan_entry.rb +101 -0
  22. data/lib/portal_module/page_factory.rb +27 -0
  23. data/lib/portal_module/pages/data_transformation_page.rb +84 -0
  24. data/lib/portal_module/pages/login_page.rb +73 -0
  25. data/lib/portal_module/pages/prequal_setup_page.rb +77 -0
  26. data/lib/portal_module/pages.rb +90 -0
  27. data/lib/portal_module/rake/dts_tasks.rb +166 -0
  28. data/lib/portal_module/rake/loan_entry_tasks.rb +166 -0
  29. data/lib/portal_module/rake.rb +16 -0
  30. data/lib/portal_module/version.rb +3 -0
  31. data/lib/portal_module.rb +251 -0
  32. data/portal_module.gemspec +33 -0
  33. data/spec/data/dts_import.xml +1 -0
  34. data/spec/data/le_import.xml +1 -0
  35. data/spec/lib/portal_module/cli_spec.rb +35 -0
  36. data/spec/lib/portal_module/client_spec.rb +126 -0
  37. data/spec/lib/portal_module/command/config_spec.rb +474 -0
  38. data/spec/lib/portal_module/command/dts_spec.rb +98 -0
  39. data/spec/lib/portal_module/command/loan_entry_spec.rb +98 -0
  40. data/spec/lib/portal_module/dts_spec.rb +145 -0
  41. data/spec/lib/portal_module/loan_entry_spec.rb +113 -0
  42. data/spec/lib/portal_module_spec.rb +175 -0
  43. data/spec/spec_helper.rb +52 -0
  44. data/spec/support/asserts.rb +10 -0
  45. data/spec/support/dirs.rb +53 -0
  46. data/spec/support/helpers.rb +44 -0
  47. data/spec/support/mocks.rb +106 -0
  48. metadata +247 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa176e874d96ecf9837f0c6e4b1b1bd442ac3603
4
+ data.tar.gz: 239dd78a8944a1c525a70cf47606f7d33e7b3b76
5
+ SHA512:
6
+ metadata.gz: 0d9043d0cff5b73c8dcb9af85e800bd6122e13594f84aed49db645d12020bec3b9be254589c1aee8296c56815aa62f7f06b8955a54f871f7f6cf431edbf54b46
7
+ data.tar.gz: 6f6eddb6a856e9c72bc5f8e28944a8db797a2891088ddfc8df848fee7d553fc263e3a5c2adf44dc3f122f37f3c9eaafc1ad6afeaba906090f98fb7e5327ab584
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ test/chrome-data
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ #--format progress
3
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'pry-byebug', :git => 'git://github.com/deivid-rodriguez/pry-byebug.git'#, :tag => 'v1.3.3'
5
+ gem 'pry-doc'
6
+ gem 'pry-docmore'
7
+ gem 'pry-rescue'
8
+ gem 'pry-stack_explorer'
9
+ end
10
+
11
+ # Specify your gem's dependencies in admin_module.gemspec
12
+ gemspec
13
+
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, cmd: "bundle exec rspec" do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jeff McAffee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jeff McAffee
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,240 @@
1
+ # PortalModule
2
+
3
+ PortalModule is a tool to allow maintenance and configuration of AMS
4
+ Portal environments through the command line or Rake tasks.
5
+
6
+ Because it is scriptable, it can be used to create efficient and repeatable
7
+ migrations resulting in low risk deployments.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'portal_module'
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install portal_module
22
+
23
+ ## Usage
24
+
25
+ ### Command Line Help
26
+
27
+ Thor's usage help is messed up related to subcommands (ie. subcommand help is
28
+ sometimes listed without the subcommand's parent). For this reason, the 'help'
29
+ is listed here.
30
+
31
+ $ portal_module help
32
+
33
+ Commands:
34
+ portal_module help [COMMAND] # Describe available commands or one specific command
35
+ portal_module config [COMMAND] # modify configuration values
36
+ portal_module dts [COMMAND] # run a dts command
37
+ portal_module loan_entry [COMMAND] # run a Loan Entry command
38
+
39
+
40
+ #### Config Commands
41
+
42
+ $ portal_module config help
43
+
44
+ Commands:
45
+ portal_module config help [COMMAND] # Describe subcommands or one specific subcommand
46
+ portal_module config defenv <envname> # show or set the default environment
47
+ portal_module config download_dir <dir> # show or set the system download directory
48
+ portal_module config init <filedir> # create a configuration file
49
+ portal_module config timeout <seconds> # show or set the browser timeout period
50
+ portal_module config show [CATEGORY] # display configuration values for [CATEGORY]
51
+ portal_module config add [CATEGORY] # add a configuration value
52
+ portal_module config del [CATEGORY] # delete a configuration value for [CATEGORY]
53
+
54
+
55
+ ##### Config Show Commands
56
+
57
+ $ portal_module config show help
58
+
59
+ Commands:
60
+ portal_module config show help [COMMAND] # Describe subcommands or one specific subcommand
61
+ portal_module config show credentials <envname> # display configured credentials for an environment
62
+ portal_module config show envs # display configured environments
63
+ portal_module config show orgs # display configured Org Units
64
+
65
+
66
+ ##### Config Add Commands
67
+
68
+ $ portal_module config add help
69
+
70
+ Commands:
71
+ portal_module config add help [COMMAND] # Describe subcommands or one specific subcommand
72
+ portal_module config add credentials <envname> <username> <pass> # add login credentials for an environment
73
+ portal_module config add env <envname> <url> # add a environment url
74
+ portal_module config add org <orgname> <orgid> # add an Org Unit and ID
75
+
76
+
77
+ ##### Config Del Commands
78
+
79
+ $ portal_module config del help
80
+
81
+ Commands:
82
+ portal_module config del help [COMMAND] # Describe subcommands or one specific subcommand
83
+ portal_module config del credentials <envname> # delete credentials for an environment
84
+ portal_module config del env <envname> # delete an environment configuration
85
+ portal_module config del org <orgname> # delete an Org Unit
86
+
87
+
88
+ #### DTS Commands
89
+
90
+ $ portal_module dts help
91
+
92
+ Commands:
93
+ portal_module dts help [COMMAND] # Describe subcommands or one specific subcommand
94
+ portal_module dts download <org> <filepath> # Export a DTS configuration file from the environment
95
+ portal_module dts upload <org> <filepath> # Upload a DTS configuration file into the environment
96
+
97
+ Options:
98
+ e, [--environment=dev]
99
+
100
+
101
+ #### Loan Entry Commands
102
+
103
+ $ portal_module loan_entry help
104
+
105
+ Commands:
106
+ portal_module loan_entry help [COMMAND] # Describe subcommands or one specific subcommand
107
+ portal_module loan_entry download <org> <filepath> # Download a Loan Entry configuration file from the environment
108
+ portal_module loan_entry upload <org> <filepath> # Upload a Loan Entry configuration file into the environment
109
+
110
+ Options:
111
+ e, [--environment=dev]
112
+
113
+
114
+
115
+
116
+
117
+
118
+ ### Tasks
119
+
120
+ PortalModule provides tasks you can use in your rake file.
121
+
122
+ #### DTS Tasks
123
+
124
+ Add `require 'portal_module/rake/dts_tasks'` to your rake file and
125
+ `portal_module` will add a set of `dts` tasks for each configured
126
+ environment. All tasks are prefixed with `am:ENV_NAME:`.
127
+
128
+ Task options are displayed within brackets like so: `am:dev:dts:upload[org,filepath]`.
129
+ If the option contains spaces, surround the option, or the entire task name
130
+ with single or double quotes:
131
+
132
+ rake am:dev:dts:upload['Some Org Name','file/path with/spaces/file.xml']
133
+
134
+ # or
135
+
136
+ rake 'am:dev:dts:upload[Some Org Name,file/path with/spaces/file.xml]'
137
+
138
+
139
+ Tasks include:
140
+
141
+ - `dts:upload` uploads a DTS configuration file
142
+ - `dts:download` downloads a DTS configuration file
143
+
144
+ #### Loan Entry Tasks
145
+
146
+ Add `require 'portal_module/rake/loan_entry_tasks'` to your rake file and
147
+ `portal_module` will add a set of `loan_entry` tasks for each configured
148
+ environment. All tasks are prefixed with `am:ENV_NAME:`.
149
+
150
+ Task options are displayed within brackets like so: `am:dev:loan_entry:upload[org,filepath]`.
151
+ If the option contains spaces, surround the option, or the entire task name
152
+ with single or double quotes:
153
+
154
+ rake am:dev:loan_entry:upload['Some Org Name','file/path with/spaces/file.xml']
155
+
156
+ # or
157
+
158
+ rake 'am:dev:loan_entry:upload[Some Org Name,file/path with/spaces/file.xml]'
159
+
160
+
161
+ Tasks include:
162
+
163
+ - `loan_entry:upload` uploads a Loan Entry configuration file
164
+ - `loan_entry:download` downloads a Loan Entry configuration file
165
+
166
+
167
+ ## Scripting
168
+
169
+ You can use the Client for scripting.
170
+
171
+
172
+
173
+ ## Contributing
174
+
175
+ 1. Fork it
176
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
177
+ 3. Create your tests (you do have tests, don't you?)
178
+ 4. Write your code
179
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
180
+ 6. Push to the branch (`git push origin my-new-feature`)
181
+ 7. Create new Pull Request
182
+
183
+ ## ToDo
184
+
185
+ * document CLI
186
+
187
+ ## Process Flow (CLI)
188
+
189
+ - Command entered in console
190
+ - `lib/portal_module/cli.rb` processes args
191
+ - `cli.rb` hands command off to `lib/portal_module/command/dts.rb`
192
+ - `dts.rb` validates command and hands off to `lib/portal_module/dts.rb`
193
+ - `dts.rb` processes command and uses `lib/portal_module/page_factory.rb`
194
+ to get instance of web page objects needed to fulfill command request
195
+ - `dts.rb` completes command
196
+
197
+ ## Process Flow (Rake Task)
198
+
199
+ - Rake imports/requires `lib/portal_module/rake/dts_task.rb`
200
+ - Rake task requires API object `lib/portal_module/dts.rb`
201
+ - API object processes task request, gets needed page objects from `page_factory.rb`
202
+ - API object completes task request, returns control to task
203
+
204
+ ## Testing
205
+
206
+ All tests can be run with
207
+
208
+ bundle exec rspec spec/
209
+
210
+ There's an included `Guardfile` that can be started with
211
+
212
+ bundle exec guard
213
+
214
+ ### Creating a Command Spec
215
+
216
+ Create a new spec file `spec/lib/portal_module/command/dts_spec.rb`.
217
+
218
+ Create a new Command object `lib/portal_module/command/dts.rb`.
219
+
220
+ Edit `lib/portal_module/cli.rb` creating new base command pointing to new object
221
+ (`PortalModule::Command::Dts` in this case).
222
+
223
+ Create `lib/portal_module/dts.rb` which is an object that provides an API
224
+ interface to the actual DTS (DataTransformationPage) page object.
225
+
226
+ - The DataTransformationPage page object only contains functionality that the actual webpage
227
+ contains, ie. Activate, Save, Loan Org Unit
228
+ - The Dts API object contains functionality that manipulates the webpage
229
+ object to provide results. Maybe this means it uses the page object to lookup
230
+ the available org units, or throw an error if a org doesn't exist.
231
+ - The API object also hides the fact that the app may need to go to a multiple
232
+ pages to accomplish the request.
233
+
234
+ ## LICENSE
235
+
236
+ PortalModule is licensed under the MIT license.
237
+
238
+ See [LICENSE](https://github.com/jmcaffee/portal_module/blob/master/LICENSE) for
239
+ details.
240
+
data/Rakefile ADDED
@@ -0,0 +1,101 @@
1
+ require "bundler/gem_tasks"
2
+ require 'ktutils/os'
3
+
4
+ require 'rake/clean'
5
+
6
+ # Setup common clean and clobber targets
7
+
8
+ CLEAN.include("pkg/**/*.*")
9
+ CLEAN.include("tmp/**/*.*")
10
+
11
+ CLOBBER.include("pkg")
12
+ CLOBBER.include("tmp")
13
+
14
+ ##############################################################################
15
+
16
+ desc 'start a console'
17
+ task :console do
18
+ require 'pry'
19
+ require 'portal_module'
20
+ ARGV.clear
21
+
22
+ PortalModule.configure do |config|
23
+ config.credentials = { :dev => [ ENV['DEV_USER'], ENV['DEV_PASSWORD'] ] }
24
+ end
25
+
26
+ def console_help
27
+ puts <<CONSOLE_HELP
28
+ CONSOLE HELP
29
+ -------------
30
+
31
+ 'cli' returns an initialized CLI object
32
+
33
+ The default environment is :dev.
34
+ To interact with a different environment, add credentials
35
+ and activate the new environment:
36
+
37
+ Ex:
38
+ add_credentials ENV, USERNAME, PASSWORD
39
+ cli.environment = :ENV
40
+ cli.login
41
+
42
+ or, call 'activate_env ENV, USERNAME, PASSWORD'
43
+
44
+
45
+ Avaliable commands/methods:
46
+
47
+ cli
48
+ add_credentials ENV, USERNAME, PASSWORD
49
+ activate_env ENV, USERNAME, PASSWORD
50
+ add_org ORG_NAME, ORG_ID
51
+ console_help
52
+
53
+ CONSOLE_HELP
54
+ end
55
+
56
+ def cli
57
+ @cli ||= PortalModule::CLI.new
58
+ @cli
59
+ end
60
+
61
+ def add_credentials env, username, pwd
62
+ PortalModule.configure do |config|
63
+ config.credentials[env.to_sym] = [username, pwd]
64
+ end
65
+ end
66
+
67
+ def activate_env env, username, pwd
68
+ add_credentials env, username, pwd
69
+ cli.environment = env.to_sym
70
+ end
71
+
72
+ def add_org org, id
73
+ PortalModule.configure do |config|
74
+ config.orgs[org] = id
75
+ end
76
+ end
77
+
78
+ console_help
79
+ Pry.start
80
+ end
81
+
82
+ ##############################################################################
83
+
84
+ desc 'Start chrome with data dir'
85
+ task :start_chrome do
86
+ user_data_dir = File.expand_path('test/chrome-data')
87
+ mkdirs user_data_dir unless File.exists?(user_data_dir) and File.directory?(user_data_dir)
88
+
89
+ if Ktutils::OS.windows?
90
+ chrome_path = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"'
91
+ win_user_data_dir = user_data_dir.gsub('/','\\')
92
+ cmd = chrome_path + ' --user-data-dir=' + win_user_data_dir
93
+
94
+ sh(cmd)
95
+ else
96
+ chrome = `which chromium-browser`.chomp
97
+
98
+ sh("#{chrome} --user-data-dir=#{user_data_dir}")
99
+ end
100
+ end
101
+