admin_module 0.1.4

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.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +24 -0
  6. data/LICENSE +22 -0
  7. data/README.md +281 -0
  8. data/Rakefile +98 -0
  9. data/admin_module.gemspec +34 -0
  10. data/bin/admin_module +13 -0
  11. data/lib/admin_module.rb +260 -0
  12. data/lib/admin_module/cli.rb +54 -0
  13. data/lib/admin_module/cli/cli_guideline.rb +80 -0
  14. data/lib/admin_module/cli/cli_lock.rb +149 -0
  15. data/lib/admin_module/cli/cli_parameter.rb +66 -0
  16. data/lib/admin_module/cli/cli_task.rb +149 -0
  17. data/lib/admin_module/cli_old.rb +92 -0
  18. data/lib/admin_module/client.rb +146 -0
  19. data/lib/admin_module/command.rb +25 -0
  20. data/lib/admin_module/command/client_access.rb +43 -0
  21. data/lib/admin_module/command/config.rb +310 -0
  22. data/lib/admin_module/command/dc.rb +110 -0
  23. data/lib/admin_module/command/gdl.rb +71 -0
  24. data/lib/admin_module/command/lock.rb +110 -0
  25. data/lib/admin_module/command/ppm.rb +142 -0
  26. data/lib/admin_module/command/rule.rb +77 -0
  27. data/lib/admin_module/command/ruleset.rb +56 -0
  28. data/lib/admin_module/command/snapshot.rb +110 -0
  29. data/lib/admin_module/command/stage.rb +131 -0
  30. data/lib/admin_module/command/task.rb +110 -0
  31. data/lib/admin_module/config_helper.rb +33 -0
  32. data/lib/admin_module/dc.rb +133 -0
  33. data/lib/admin_module/guideline.rb +86 -0
  34. data/lib/admin_module/locks.rb +142 -0
  35. data/lib/admin_module/page_factory.rb +55 -0
  36. data/lib/admin_module/pages.rb +120 -0
  37. data/lib/admin_module/pages/dc_definitions_page.rb +73 -0
  38. data/lib/admin_module/pages/dc_detail_page.rb +187 -0
  39. data/lib/admin_module/pages/guideline_page.rb +35 -0
  40. data/lib/admin_module/pages/guideline_version_page.rb +140 -0
  41. data/lib/admin_module/pages/guidelines_page.rb +59 -0
  42. data/lib/admin_module/pages/guidelines_version_all_page.rb +116 -0
  43. data/lib/admin_module/pages/lock_definition_page.rb +178 -0
  44. data/lib/admin_module/pages/lock_definitions_page.rb +69 -0
  45. data/lib/admin_module/pages/login_page.rb +75 -0
  46. data/lib/admin_module/pages/parameter_page.rb +62 -0
  47. data/lib/admin_module/pages/parameters_page.rb +46 -0
  48. data/lib/admin_module/pages/ppms_page.rb +110 -0
  49. data/lib/admin_module/pages/rule_page.rb +68 -0
  50. data/lib/admin_module/pages/rules_page.rb +74 -0
  51. data/lib/admin_module/pages/ruleset_page.rb +64 -0
  52. data/lib/admin_module/pages/rulesets_page.rb +60 -0
  53. data/lib/admin_module/pages/select_list_syncable.rb +64 -0
  54. data/lib/admin_module/pages/snapshot_definitions_page.rb +73 -0
  55. data/lib/admin_module/pages/snapshot_detail_page.rb +246 -0
  56. data/lib/admin_module/pages/workflow_detail_page.rb +451 -0
  57. data/lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb +172 -0
  58. data/lib/admin_module/pages/workflow_detail_task_mappings_page.rb +163 -0
  59. data/lib/admin_module/pages/workflow_detail_task_screens_page.rb +75 -0
  60. data/lib/admin_module/pages/workflow_details_page.rb +67 -0
  61. data/lib/admin_module/pages/workflow_task_page.rb +107 -0
  62. data/lib/admin_module/pages/workflow_tasks_page.rb +111 -0
  63. data/lib/admin_module/ppms.rb +78 -0
  64. data/lib/admin_module/rake.rb +22 -0
  65. data/lib/admin_module/rake/dc_tasks.rb +185 -0
  66. data/lib/admin_module/rake/deploy_task.rb +59 -0
  67. data/lib/admin_module/rake/gdl_tasks.rb +189 -0
  68. data/lib/admin_module/rake/lock_tasks.rb +189 -0
  69. data/lib/admin_module/rake/parameter_task.rb +86 -0
  70. data/lib/admin_module/rake/ppm_tasks.rb +248 -0
  71. data/lib/admin_module/rake/rule_tasks.rb +157 -0
  72. data/lib/admin_module/rake/snapshot_tasks.rb +223 -0
  73. data/lib/admin_module/rake/stage_tasks.rb +197 -0
  74. data/lib/admin_module/rake/stages_task.rb +197 -0
  75. data/lib/admin_module/rake/task_tasks.rb +189 -0
  76. data/lib/admin_module/rules.rb +50 -0
  77. data/lib/admin_module/rulesets.rb +42 -0
  78. data/lib/admin_module/snapshots.rb +133 -0
  79. data/lib/admin_module/stages.rb +171 -0
  80. data/lib/admin_module/tasks.rb +147 -0
  81. data/lib/admin_module/version.rb +3 -0
  82. data/old_spec/lib/admin_module/cli_configuration_spec.rb +126 -0
  83. data/old_spec/lib/admin_module/cli_create_stage_spec.rb +89 -0
  84. data/old_spec/lib/admin_module/cli_delete_rule_spec.rb +57 -0
  85. data/old_spec/lib/admin_module/cli_deploy_spec.rb +57 -0
  86. data/old_spec/lib/admin_module/cli_export_locks_spec.rb +62 -0
  87. data/old_spec/lib/admin_module/cli_export_stages_spec.rb +62 -0
  88. data/old_spec/lib/admin_module/cli_guidelines_version_all_spec.rb +58 -0
  89. data/old_spec/lib/admin_module/cli_import_locks_spec.rb +153 -0
  90. data/old_spec/lib/admin_module/cli_import_stages_spec.rb +173 -0
  91. data/old_spec/lib/admin_module/cli_modify_locks_spec.rb +128 -0
  92. data/old_spec/lib/admin_module/cli_modify_stages_spec.rb +88 -0
  93. data/old_spec/lib/admin_module/cli_rename_rule_spec.rb +53 -0
  94. data/old_spec/lib/admin_module/cli_rename_ruleset_spec.rb +53 -0
  95. data/old_spec/lib/admin_module/cli_var_spec.rb +41 -0
  96. data/old_spec/lib/admin_module/rake/deploy_task_spec.rb +85 -0
  97. data/old_spec/lib/admin_module/rake/parameter_task_spec.rb +58 -0
  98. data/old_spec/lib/admin_module/rake/rules_task_spec.rb +75 -0
  99. data/spec/data/build/test1.xml +0 -0
  100. data/spec/data/build/test2.xml +1 -0
  101. data/spec/data/import_dcs.yml +31 -0
  102. data/spec/data/import_locks.yml +4 -0
  103. data/spec/data/import_snapshots.yml +35 -0
  104. data/spec/data/import_stages.yml +4 -0
  105. data/spec/data/import_tasks.yml +25 -0
  106. data/spec/data/patch-test.xml +1 -0
  107. data/spec/data/remove_test_del_rule.xml +1 -0
  108. data/spec/data/stages.yml +518 -0
  109. data/spec/data/test_del_rule.xml +1 -0
  110. data/spec/lib/admin_module/admin_module_spec.rb +175 -0
  111. data/spec/lib/admin_module/cli_spec.rb +36 -0
  112. data/spec/lib/admin_module/client_spec.rb +158 -0
  113. data/spec/lib/admin_module/command/config_spec.rb +477 -0
  114. data/spec/lib/admin_module/command/dc_spec.rb +202 -0
  115. data/spec/lib/admin_module/command/gdl_spec.rb +139 -0
  116. data/spec/lib/admin_module/command/lock_spec.rb +207 -0
  117. data/spec/lib/admin_module/command/rule_spec.rb +163 -0
  118. data/spec/lib/admin_module/command/ruleset_spec.rb +124 -0
  119. data/spec/lib/admin_module/command/snapshot_spec.rb +202 -0
  120. data/spec/lib/admin_module/command/stage_spec.rb +259 -0
  121. data/spec/lib/admin_module/command/task_spec.rb +207 -0
  122. data/spec/lib/admin_module/dc_spec.rb +192 -0
  123. data/spec/lib/admin_module/guideline_spec.rb +177 -0
  124. data/spec/lib/admin_module/locks_spec.rb +188 -0
  125. data/spec/lib/admin_module/rules_spec.rb +110 -0
  126. data/spec/lib/admin_module/rulesets_spec.rb +85 -0
  127. data/spec/lib/admin_module/snapshot_spec.rb +192 -0
  128. data/spec/lib/admin_module/stages_spec.rb +179 -0
  129. data/spec/lib/admin_module/tasks_spec.rb +196 -0
  130. data/spec/spec_helper.rb +54 -0
  131. data/spec/support/asserts.rb +13 -0
  132. data/spec/support/data_clearing.rb +28 -0
  133. data/spec/support/dirs.rb +54 -0
  134. data/spec/support/helpers.rb +83 -0
  135. data/spec/support/lock.rb +23 -0
  136. data/spec/support/mocks.rb +213 -0
  137. data/spec/support/snapshot.rb +28 -0
  138. data/spec/support/stage.rb +22 -0
  139. data/spec/support/stage_factory.rb +138 -0
  140. data/spec/support/task.rb +23 -0
  141. metadata +381 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c8c29c19b7d3792f8c9ca04979028f956df0583
4
+ data.tar.gz: 22ec04a187770d3dd9b1355b0290b511dca42dcb
5
+ SHA512:
6
+ metadata.gz: efb79e23d04db36f2183b2a5e9b291af2c11140ddf327c54d1b0e04977e3bef5ea1d025bd9043fb04f488396ff1dbcf6e556f89f70ed215d504f5845ff8772ec
7
+ data.tar.gz: 43bcab64b34dab3222cf8522cf224ff08d67f362daa4a7c69db556810dfb7e3cce794266ba20294dc7d4a3cd560c7fd70814ecb4007abb8fd43dc612d8b6eb9a
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
19
+ .admin_module
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ #--format progress
3
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'activesupport'
5
+ gem 'pry-byebug', :git => 'git://github.com/deivid-rodriguez/pry-byebug.git'#, :tag => 'v1.3.3'
6
+ gem 'pry-doc'
7
+ gem 'pry-docmore'
8
+ gem 'pry-rescue'
9
+ gem 'pry-stack_explorer'
10
+ end
11
+
12
+ # Specify your gem's dependencies in admin_module.gemspec
13
+ gemspec
14
+
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/README.md ADDED
@@ -0,0 +1,281 @@
1
+ # AdminModule
2
+
3
+ AdminModule is a tool to allow maintenance and configuration of AMS
4
+ 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 'admin_module'
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install admin_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
+ $ admin_module help
32
+
33
+ Commands:
34
+ admin_module help [COMMAND] # Describe available commands or one specific command
35
+ admin_module config [COMMAND] # modify configuration values
36
+ admin_module gdl [COMMAND] # run a guideline command
37
+ admin_module lock [COMMAND] # run a lock command
38
+ admin_module rule [COMMAND] # run a rule command
39
+ admin_module ruleset [COMMAND] # run a ruleset command
40
+ admin_module stage [COMMAND] # run a stage command
41
+
42
+
43
+ #### Config Commands
44
+
45
+ $ admin_module config help
46
+
47
+ Commands:
48
+ admin_module config help [COMMAND] # Describe subcommands or one specific subcommand
49
+ admin_module config defcomment '<comment>' # show or set the default comment
50
+ admin_module config defenv <envname> # show or set the default environment
51
+ admin_module config init <filedir> # create a configuration file
52
+ admin_module config timeout <seconds> # show or set the browser timeout period
53
+ admin_module config show [CATEGORY] # display configuration values for [CATEGORY]
54
+ admin_module config add [CATEGORY] # add a configuration value
55
+ admin_module config del [CATEGORY] # delete a configuration value for [CATEGORY]
56
+
57
+
58
+ ##### Config Show Commands
59
+
60
+ $ admin_module config show help
61
+
62
+ Commands:
63
+ admin_module config show help [COMMAND] # Describe subcommands or one specific subcommand
64
+ admin_module config show credentials <envname> # display configured credentials for an environment
65
+ admin_module config show envs # display configured environments
66
+ admin_module config show xmlmaps # display configured xmlmaps
67
+
68
+
69
+ ##### Config Add Commands
70
+
71
+ $ admin_module config add help
72
+
73
+ Commands:
74
+ admin_module config add help [COMMAND] # Describe subcommands or one specific subcommand
75
+ admin_module config add credentials <envname> <username> <pass> # add login credentials for an environment
76
+ admin_module config add env <envname> <url> # add a environment url
77
+ admin_module config add xmlmap <xmlfile> <gdlname> # map an xml file name to a guideline
78
+
79
+
80
+ ##### Config Del Commands
81
+
82
+ $ admin_module config del help
83
+
84
+ Commands:
85
+ admin_module config del help [COMMAND] # Describe subcommands or one specific subcommand
86
+ admin_module config del credentials <envname> # delete credentials for an environment
87
+ admin_module config del env <envname> # delete an environment configuration
88
+ admin_module config del xmlmap <xmlfile> # delete an xml file to guideline mapping
89
+
90
+
91
+ #### Gdl Commands
92
+
93
+ $ admin_module gdl help
94
+
95
+ Commands:
96
+ admin_module gdl help [COMMAND] # Describe subcommands or one specific subcommand
97
+ admin_module gdl deploy <srcdir> <comments> # Deploy all XML files in <srcdir> with version <comments>
98
+ admin_module gdl version <comments> # Version guidelines with <comments>
99
+
100
+ Options:
101
+ e, [--environment=dev]
102
+
103
+
104
+ #### Lock Commands
105
+
106
+ $ admin_module lock help
107
+
108
+ Commands:
109
+ admin_module lock help [COMMAND] # Describe subcommands or one specific subcommand
110
+ admin_module lock export <filepath> # Export a lock configuration file from the environment
111
+ admin_module lock import <filepath> # Import a lock configuration file into the environment
112
+ admin_module lock list # List all locks in the environment
113
+ admin_module lock read <name> # Emit a lock's configuration from the environment in YAML format
114
+ admin_module lock rename <srcname> <destname> # Rename a lock named <srcname> to <destname>
115
+
116
+ Options:
117
+ e, [--environment=dev]
118
+
119
+
120
+ #### Rule Commands
121
+
122
+ $ admin_module rule help
123
+
124
+ Commands:
125
+ admin_module rule help [COMMAND] # Describe subcommands or one specific subcommand
126
+ admin_module rule delete <rulename> # Delete a rule named <rulename>
127
+ admin_module rule list # List all rules in the environment
128
+ admin_module rule rename <srcname> <destname> # Rename a rule named <srcname> to <destname>
129
+
130
+ Options:
131
+ e, [--environment=dev]
132
+
133
+
134
+ #### Ruleset Commands
135
+
136
+ $ admin_module ruleset help
137
+
138
+ Commands:
139
+ admin_module ruleset help [COMMAND] # Describe subcommands or one specific subcommand
140
+ admin_module ruleset list # List all rulesets in the environment
141
+ admin_module ruleset rename <srcname> <destname> # Rename a ruleset named <srcname> to <destname>
142
+
143
+ Options:
144
+ e, [--environment=dev]
145
+
146
+
147
+ #### Stage Commands
148
+
149
+ $ admin_module stage help
150
+
151
+ Commands:
152
+ admin_module stage help [COMMAND] # Describe subcommands or one specific subcommand
153
+ admin_module stage delete <name> # Delete a stage from the environment
154
+ admin_module stage export <filepath> # Export a stage configuration file from the environment
155
+ admin_module stage import <filepath> # Import a stage configuration file into the environment
156
+ admin_module stage list # List all stages in the environment
157
+ admin_module stage read <name> # Emit a stage's configuration from the environment in YAML format
158
+ admin_module stage rename <srcname> <destname> # Rename a stage from <srcname> to <destname>
159
+
160
+ Options:
161
+ e, [--environment=dev]
162
+
163
+
164
+
165
+
166
+ ### Tasks
167
+
168
+ AdminModule provides tasks you can use in your rake file.
169
+
170
+ #### Stage Tasks
171
+
172
+ Add `require 'admin_module/rake/stage_tasks'` to your rake file and
173
+ `admin_module` will add a set of `stage` tasks for each configured
174
+ environment. All tasks are prefixed with `am:ENV_NAME:`.
175
+
176
+ Task options are displayed within brackets like so: `am:dev:stage:read[name]`.
177
+ If the option contains spaces, surround the option, or the entire task name
178
+ with single or double quotes:
179
+
180
+ rake am:dev:stage:read['Some Stage Name']
181
+
182
+ # or
183
+
184
+ rake 'am:dev:stage:read[Some Stage Name]'
185
+
186
+
187
+ Tasks include:
188
+
189
+ - `stage:delete` deletes a stage
190
+ - `stage:export` exports all stages to a yaml file
191
+ - `stage:import` imports stage configs from a yaml file
192
+ - the `allow_create` flag is optional. Default: `false`. If `true`, stages can be created during import.
193
+ - `stage:list` list all stage names
194
+ - `stage:read` output a stage configuration in yaml format
195
+ - `stage:rename` rename an existing stage
196
+
197
+
198
+ ## Scripting
199
+
200
+ You can use the Client for scripting.
201
+
202
+
203
+
204
+ ## Contributing
205
+
206
+ 1. Fork it ( https://github.com/jmcaffee/admin_module/fork )
207
+ 1. Clone it (`git clone git@github.com:[my-github-username]/admin_module.git`)
208
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
209
+ 3. Create tests for your feature branch
210
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
211
+ 5. Push to the branch (`git push origin my-new-feature`)
212
+ 6. Create a new Pull Request
213
+
214
+ ## ToDo
215
+
216
+ * complete conversion to `thor`
217
+ * PPM configuration specs
218
+ * clean up (remove) old `cli` files
219
+ * document new commands in README
220
+ + PPMs
221
+ + Tasks
222
+ + Snapshots
223
+
224
+
225
+ ## Process Flow (CLI)
226
+
227
+ - Command entered in console
228
+ - `lib/admin_module/cli.rb` processes args
229
+ - `cli.rb` hands command off to `lib/admin_module/cli/gdl.rb`
230
+ - `gdl.rb` validates command and hands off to `lib/admin_module/guideline.rb`
231
+ - `guideline.rb` processes command and uses `lib/admin_module/page_factory.rb`
232
+ to get instance of web page objects needed to fulfill command request
233
+ - `guideline.rb` completes command
234
+
235
+ ## Process Flow (Rake Task)
236
+
237
+ - Rake imports/requires `lib/admin_module/rake/deploy_task.rb`
238
+ - Rake task requires API object `lib/admin_module/guideline.rb`
239
+ - API object processes task request, gets needed page objects from `page_factory.rb`
240
+ - API object completes task request, returns control to task
241
+
242
+ ## Thor Conversion Process
243
+
244
+ Detailing the conversion steps taken while converting to Thor CLI interface.
245
+
246
+ 1. Create CLI spec for new interface (`spec/lib/admin_module/cli/gdl_spec.rb`)
247
+ 2. Create new CLI object (`lib/admin_module/cli/gdl.rb`)
248
+ 3. Create API spec for API object (`spec/lib/admin_module/guideline_spec.rb`)
249
+ 4. Create new/modify existing API object (`lib/admin_module/guideline.rb`)
250
+ 5. Make tests/specs pass
251
+ 6. Delete old CLI object (`lib/admin_module/cli/cli_guideline.rb`)
252
+
253
+ ### Create CLI Spec
254
+
255
+ Create a new spec file `spec/lib/admin_module/cli/gdl_spec.rb`.
256
+
257
+ Create a new CLI object `lib/admin_module/cli/gdl.rb`.
258
+
259
+ Edit `lib/admin_module/cli.rb` creating new base command pointing to new object
260
+ (`AdminModule::Gdl` in this case).
261
+
262
+ Create `lib/admin_module/guideline.rb` which is an object that provides an API
263
+ interface to the actual Guideline page object.
264
+
265
+ - The Guideline page object only contains functionality that the actual webpage
266
+ contains, ie. Add, Modify, Delete
267
+ - The Guideline API object contains functionality that manipulates the webpage
268
+ object to provide results. Maybe this means it uses the page object to lookup
269
+ the available guidelines, throw an error if a guidline doesn't exist, or
270
+ deletes a guideline if exists.
271
+ - The API object also hides the fact that the app needs to go to a _Guidelines_
272
+ page, select a guideline, then go to the _GuidelineDetails_ page before it can
273
+ manipulate a guideline, say, to change its name.
274
+
275
+ ## LICENSE
276
+
277
+ AdminModule is licensed under the MIT license.
278
+
279
+ See [LICENSE](https://github.com/jmcaffee/admin_module/blob/master/LICENSE) for
280
+ details.
281
+
data/Rakefile ADDED
@@ -0,0 +1,98 @@
1
+ require "bundler/gem_tasks"
2
+ require 'ktutils/os'
3
+
4
+ require 'rake/clean'
5
+ require 'rspec/core/rake_task'
6
+
7
+ # Windows Locations
8
+
9
+ CHROME_PATH = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"'
10
+
11
+ # Setup common clean and clobber targets
12
+
13
+ CLEAN.include("pkg")
14
+ CLOBBER.include("pkg")
15
+
16
+ ##############################################################################
17
+
18
+ desc 'start a console'
19
+ task :console do
20
+ require 'pry'
21
+ require 'admin_module'
22
+ ARGV.clear
23
+
24
+ AdminModule.configure do |config|
25
+ config.credentials = { :dev => ['admin', 'Password1*'] }
26
+ end
27
+
28
+ def console_help
29
+ puts <<CONSOLE_HELP
30
+ CONSOLE HELP
31
+ -------------
32
+
33
+ 'cli' returns an initialized CLI object
34
+
35
+ The default environment is :dev.
36
+ To interact with a different environment, add credentials
37
+ and activate the new environment:
38
+
39
+ Ex:
40
+ add_credentials ENV, USERNAME, PASSWORD
41
+ cli.environment = :ENV
42
+ cli.login
43
+
44
+ or, call 'activate_env ENV, USERNAME, PASSWORD'
45
+
46
+
47
+ Avaliable commands/methods:
48
+
49
+ cli
50
+ add_credentials ENV, USERNAME, PASSWORD
51
+ activate_env ENV, USERNAME, PASSWORD
52
+ console_help
53
+
54
+ CONSOLE_HELP
55
+ end
56
+
57
+ def cli
58
+ @cli ||= AdminModule::CLI.new
59
+ @cli
60
+ end
61
+
62
+ def add_credentials env, username, pwd
63
+ AdminModule.configure do |config|
64
+ config.credentials[env.to_sym] = [username, pwd]
65
+ end
66
+ end
67
+
68
+ def activate_env env, username, pwd
69
+ add_credentials env, username, pwd
70
+ cli.environment = env.to_sym
71
+ end
72
+
73
+ console_help
74
+ Pry.start
75
+ end
76
+
77
+ ##############################################################################
78
+
79
+ desc 'Start chrome with data dir'
80
+ task :start_chrome do
81
+ user_data_dir = File.expand_path('test/chrome-data')
82
+ mkdirs user_data_dir unless File.exists?(user_data_dir) and File.directory?(user_data_dir)
83
+
84
+ if Ktutils::OS.windows?
85
+ user_data_dir = user_data_dir.gsub('/', '\\')
86
+ sh("#{CHROME_PATH} --user-data-dir=#{user_data_dir}")
87
+ else
88
+ chrome = `which chromium-browser`.chomp
89
+ sh("#{chrome} --user-data-dir=#{user_data_dir}")
90
+ end
91
+ end
92
+
93
+ #############################################################################
94
+ desc "Run all specs"
95
+ RSpec::Core::RakeTask.new do |t|
96
+ #t.rcov = true
97
+ end
98
+