nota_nuc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +48 -0
  5. data/README.md +41 -0
  6. data/Rakefile +5 -0
  7. data/db/Quarrier.rb +430 -0
  8. data/db/create_db_Penrhyn.rb +186 -0
  9. data/features/commands.feature +119 -0
  10. data/features/cucumber_LICENCE +22 -0
  11. data/features/offline.feature +65 -0
  12. data/features/passwords.feature +37 -0
  13. data/features/step_definitions/command_steps.rb +142 -0
  14. data/features/step_definitions/offline_steps.rb +211 -0
  15. data/features/step_definitions/password_steps.rb +45 -0
  16. data/images/arrowleft_image.png +0 -0
  17. data/images/arrowright_image.png +0 -0
  18. data/images/arrowright_imageone.png +0 -0
  19. data/images/arrowright_imagetwo.png +0 -0
  20. data/images/blue_light.png +0 -0
  21. data/images/error_symbol.png +0 -0
  22. data/images/gift_glow2.png +0 -0
  23. data/images/gift_nonglow2.png +0 -0
  24. data/images/gift_nonglow2_bottom.png +0 -0
  25. data/images/green_light.png +0 -0
  26. data/images/key_glow.png +0 -0
  27. data/images/key_nonglow.png +0 -0
  28. data/images/lock_image.png +0 -0
  29. data/images/new_slate_icon.png +0 -0
  30. data/images/pencil_glow image.png +0 -0
  31. data/images/pencil_glow_image_red.png +0 -0
  32. data/images/pencil_nonglow.png +0 -0
  33. data/images/red_light.png +0 -0
  34. data/images/settings_icon.png +0 -0
  35. data/images/typing_image.png +0 -0
  36. data/images/updating_image.png +0 -0
  37. data/images/yellow_light.png +0 -0
  38. data/lib/Billboard_module.rb +372 -0
  39. data/lib/Exercitus_romanorum.rb +572 -0
  40. data/lib/error_choose_a_slate.rb +20 -0
  41. data/lib/final_eye.rb +777 -0
  42. data/lib/nota_nuc.rb +5 -0
  43. data/lib/nota_nuc/version.rb +3 -0
  44. data/log/history.log +3 -0
  45. data/log/slate.log +3 -0
  46. data/nota_nuc.gemspec +36 -0
  47. metadata +196 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f713c07c2418d20dc30ecc44c781abb049d3e3f
4
+ data.tar.gz: 843fb98bd78f67a1052aeeef04489ed3bc3dc56e
5
+ SHA512:
6
+ metadata.gz: a7e0f7c71099368f8eadaf5abce97e898ee38d4d9f8cbdca3aaa006c1102f9e862a6c034955c2a6830ee9837ff45d81674bdf7b0b1bd36f57d8c05c94a5bb524
7
+ data.tar.gz: bea245fd80a952497d6db212cc8393f6da41e7213898846307fcebb7e1c8b3a85a0946d9759410e472c8365bb3fe00ee157b4dc001e5454d975d036c6a42ff2b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nota_nuc.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,48 @@
1
+ Open Software License v. 3.0 (OSL-3.0)
2
+
3
+
4
+ This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
5
+
6
+ Licensed under the Open Software License version 3.0
7
+
8
+ 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
9
+
10
+ a) to reproduce the Original Work in copies, either alone or as part of a collective work;
11
+
12
+ b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
13
+
14
+ c) to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
15
+
16
+ d) to perform the Original Work publicly; and
17
+
18
+ e) to display the Original Work publicly.
19
+
20
+ 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
21
+
22
+ 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
23
+
24
+ 4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
25
+
26
+ 5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
27
+
28
+ 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
29
+
30
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
31
+
32
+ 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
33
+
34
+ 9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
35
+
36
+ 10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
37
+
38
+ 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
39
+
40
+ 12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
41
+
42
+ 13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
43
+
44
+ 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
45
+
46
+ 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
47
+
48
+ 16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # NotaNuc
2
+
3
+ This gem installs the software called Slates.
4
+
5
+ Slates is a simple notetaking program that uses a commandline. Multiple sets of slates(notes) are available to the program and can be accessed with both the command line and the buttons.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'nota_nuc'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install nota_nuc
20
+
21
+
22
+
23
+ Slates will only work on linux systems and has only been tested on Ubuntu 12.04 LTS.
24
+
25
+ Slates requires ruby 2.0.0 but may work with newer versions of ruby as well.
26
+
27
+ After you have installed this gem, to see if you have the correct gems installed, you can run `bundle check` which will then ask you to install any gems you may be missing.
28
+
29
+ To use this program, you first need to create the database. To create the database run `ruby create_db_Penrhyn.rb` from the db directory in the directory of the gem.
30
+
31
+ ## Usage
32
+
33
+ To run this program, use the following command: `ruby final_eye.rb` from the lib directory.
34
+
35
+
36
+ ## Contributing
37
+
38
+ `You can find this project at https://bitbucket.org/mfocella/nota_nuc`
39
+
40
+
41
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => []
4
+
5
+
data/db/Quarrier.rb ADDED
@@ -0,0 +1,430 @@
1
+ #Quarrier is a module which accesses the Penrhyn database using activerecord calls, updates and additions
2
+
3
+ =begin
4
+ Activerecord
5
+ The MIT License (MIT)
6
+ Copyright (c) <year> <copyright holders>
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
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
21
+ THE SOFTWARE.
22
+ =end
23
+
24
+
25
+
26
+
27
+ module Quarrier
28
+ require 'active_record'
29
+ require_relative '../lib/Billboard_module.rb'
30
+ include Billboard
31
+ require 'logger'
32
+
33
+
34
+
35
+ ActiveRecord::Base.establish_connection({
36
+ adapter: 'sqlite3',
37
+ database: '../db/Penrhyn.db',
38
+ #user: 'randomstring', (this will be added later if database gets encrypted)
39
+ #password: 'randomtext', (this will be used later if database gets encrypted)
40
+ host: 'localhost'
41
+ })
42
+
43
+
44
+ class Slate < ActiveRecord::Base
45
+ validates :slatename, length: { in: 2..18, message: "The length of the slate name must be between 1 and 18" }
46
+ validates :slatename, uniqueness: { case_sensitive: true, message: "The slate name must be unique (this check is case sensitive)" }
47
+ validates :slatename, :connectionstatus, :commandonly, :viewing, presence: true
48
+ validates :maintext, length: { maximum: 14000, message: "The length of the slates text must not exceed 14000 characters"}
49
+ validates :connectionstatus, :commandonly, :viewing, length: { in: 0..1, message: "The connectionstatus must be either 0 or 1" }
50
+
51
+
52
+ def self.error_handler_slatename(record)
53
+ if record.invalid?
54
+ logger = Logger.new('../log/slate.log', 2, 2000000)
55
+ record.errors.each do |attr, msg|
56
+ if "#{attr}" == "slatename"
57
+ Billboard.alert_slatename_error
58
+ logger.info "#{msg}"
59
+ end
60
+ end
61
+ logger.close
62
+ record.errors.clear
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+
69
+
70
+
71
+ class GeneralSetting < ActiveRecord::Base
72
+ validates :settings, :updatetime, :lockslatecheck, :networkcheck, presence: true
73
+ validates :locktime, length: { in: 1..2, message: "The locktime length must be between 1 and 99" }
74
+ validates :locktime, numericality: { only_integer: true }
75
+ validates :updatetime, length: { in: 1..2, message: "The updatetime length must be between 1 and 99" }
76
+ validates :updatetime, numericality: { only_integer: true }
77
+ validates :lockslatecheck, :networkcheck, length: { in: 0..1, message: "The lockslatecheck length must be either 0 or 1" }
78
+ validates :adminpassword, length: { in: 14..50, message: "The admin password must have between 14 and 50 characters" }
79
+
80
+ def self.error_handler_lock(record)
81
+ if record.invalid?
82
+ logger = Logger.new('../log/slate.log', 2, 2000000)
83
+ record.errors.each do |attr, msg|
84
+ if "#{attr}" == "locktime"
85
+ Billboard.alert_locktime_error
86
+ logger.info "#{msg}"
87
+ end
88
+ end
89
+ logger.close
90
+ record.errors.clear
91
+ end
92
+ end
93
+
94
+ def self.error_handler_utime(record)
95
+ if record.invalid?
96
+ logger = Logger.new('../log/slate.log', 2, 2000000)
97
+ record.errors.each do |attr, msg|
98
+ if "#{attr}" == "updatetime"
99
+ Billboard.alert_updatetime_error
100
+ logger.info "#{msg}"
101
+ end
102
+ end
103
+ logger.close
104
+ record.errors.clear
105
+ end
106
+ end
107
+
108
+ def self.error_handler_password(record)
109
+ if record.invalid?
110
+ logger = Logger.new('../log/slate.log', 2, 2000000)
111
+ record.errors.each do |attr, msg|
112
+ if "#{attr}" == "adminpassword"
113
+ Billboard.alert_password_error
114
+ logger.info "#{msg}"
115
+ end
116
+ end
117
+ logger.close
118
+ record.errors.clear
119
+ end
120
+ end
121
+ end
122
+
123
+
124
+ class Host < ActiveRecord::Base
125
+ validates :hostname, length: { in: 2..40, message: "The name of a host must be between 2 and 50 characters in length" }
126
+ validates :hostname, presence: true
127
+ validates :hostname, uniqueness: { case_sensitive: true, message: "The hostname must be unique (this check is case sensitive)"}
128
+
129
+ #the below error_handler method needs to be fixed
130
+ def error_handler(record)
131
+ if record.errors.invalid?
132
+ if record.errors.added? :hostname do
133
+ Billboard.alert_hostname_error
134
+ logger = Logger.new('slate.log', 2, 2000000)
135
+ logger.info "#{record.errors.messages}"
136
+ logger.close
137
+ end
138
+ end
139
+ record.errors.clear
140
+ end
141
+ end
142
+ end
143
+
144
+
145
+
146
+ class SlateHost < ActiveRecord::Base
147
+ validates :hostid, :slateid, presence: true
148
+ #add here to check that both :slateid and :hostid exist in their respective databases
149
+ end
150
+
151
+ class Status < ActiveRecord::Base
152
+ validates :state, :isadmin, :newtext, :doppelganger, :giftoffers, :cmdlineresponse, presence: true
153
+ end
154
+
155
+
156
+ def nextslate
157
+ sv = Slate.find_by(viewing: 1)
158
+ svn = sv.slatename
159
+ slates = []
160
+ slates = list_slates
161
+ index = slates.find_index("#{svn}")
162
+ nextindex = index + 1
163
+ nextslate = slates[nextindex]
164
+ if slates.last == "#{svn}"
165
+ return slates[0]
166
+ else
167
+ return nextslate
168
+ end
169
+ end
170
+
171
+
172
+ def previousslate
173
+ sv = Slate.find_by(viewing: 1)
174
+ svn = sv.slatename
175
+ slates = []
176
+ slates = list_slates
177
+ index = slates.find_index("#{svn}")
178
+ previousindex = index - 1
179
+ previousslate = slates[previousindex]
180
+ firstslate = slates[0]
181
+ if firstslate == "#{svn}"
182
+ return slates[-1]
183
+ else
184
+ return previousslate
185
+ end
186
+ end
187
+
188
+ def viewing?(slate)
189
+ argument = /^(\w+)\s*$/.match("#{slate}").captures
190
+ arg = argument.join("")
191
+ s = Slate.find_by(viewing: 1)
192
+ n = s.slatename
193
+ if "#{n}" == "#{arg}"
194
+ return 1
195
+ end
196
+ end
197
+
198
+ def set_viewing(slate)
199
+ argument = /^(\w+)\s*$/.match("#{slate}").captures
200
+ arg = argument.join("")
201
+ s = Slate.find_by(viewing: 1)
202
+ s.viewing = 0
203
+ n = Slate.find_by(slatename: "#{arg}")
204
+ n.viewing = 1
205
+ s.save
206
+ n.save
207
+ end
208
+
209
+ #I don't think I need the below method anymore
210
+ def set_viewing_byid(id)
211
+ s = Slate.find_by(viewing: 1)
212
+ s.viewing = 0
213
+ n = Slate.find_by(slateid: "#{id}")
214
+ n.viewing = 1
215
+ s.save
216
+ n.save
217
+ end
218
+
219
+ def set_maintext_viewing
220
+ s = Slate.find_by(viewing: 1)
221
+ t = s.maintext
222
+ return t
223
+ end
224
+
225
+ def is_admin?
226
+ s = Status.find_by(state: 0)
227
+ a = s.isadmin
228
+ return a
229
+ end
230
+
231
+ def set_admin(status)
232
+ s = Status.find_by(state: 0)
233
+ s.isadmin = "#{status}"
234
+ s.save
235
+ end
236
+
237
+ def update_text(text)
238
+ s = Slate.find_by(viewing: 1)
239
+ s.maintext = "#{text}"
240
+ s.save
241
+ end
242
+
243
+ def get_text
244
+ s = Slate.find_by(viewing: 1)
245
+ t = s.maintext
246
+ return t
247
+ end
248
+
249
+ def switch_maintext_L
250
+ newslate = Slate.find_by(slatename: "#{previousslate}")
251
+ s = Slate.find_by(viewing: 1)
252
+ s.viewing = 0
253
+ s.save
254
+ newslate.viewing = 1
255
+ t = newslate.maintext
256
+ newslate.save
257
+ return t
258
+ end
259
+
260
+ def switch_maintext_R
261
+ newslate = Slate.find_by(slatename: "#{nextslate}")
262
+ s = Slate.find_by(viewing: 1)
263
+ s.viewing = 0
264
+ s.save
265
+ newslate.viewing = 1
266
+ t = newslate.maintext
267
+ newslate.save
268
+ return t
269
+ end
270
+
271
+ def get_slatename
272
+ s = Slate.find_by(viewing: 1)
273
+ n = s.slatename
274
+ return n
275
+ end
276
+
277
+
278
+ def set_slatename(slate_id, newslate)
279
+ s = Slate.find_by(slateid: "#{slate_id}")
280
+ slate = Slate.new(slatename: "#{newslate}", viewing: "0", connectionstatus: "0", maintext: "s", commandonly: "0" )
281
+ Slate::error_handler_slatename(slate)
282
+ old = s.slatename
283
+ s.slatename = "#{newslate}"
284
+ s.save
285
+ logger = Logger.new('../log/slate.log', 2, 2000000)
286
+ logger.info "The slate #{old} was renamed to #{newslate}"
287
+ logger.close
288
+ end
289
+
290
+ def get_slateid(name)
291
+ n = Slate.find_by(slatename: "#{name}")
292
+ s = n.slateid
293
+ return s
294
+ end
295
+
296
+ def new_slate(name)
297
+ slate = Slate.new
298
+ test = Slate.new(slatename: "#{name}", viewing: "0", connectionstatus: "0", maintext: "s", commandonly: "0" )
299
+ Slate::error_handler_slatename(test)
300
+ slate.slatename = "#{name}"
301
+ slate.connectionstatus = 0
302
+ slate.commandonly = 0
303
+ slate.viewing = 0
304
+ slate.maintext = "#{name}"
305
+ if slate.invalid?
306
+ nil
307
+ else
308
+ slate.save
309
+ logger = Logger.new('../log/slate.log', 2, 2000000)
310
+ logger.info "The slate #{name} was created"
311
+ logger.close
312
+ end
313
+ end
314
+
315
+ def list_slates
316
+ slatenames = []
317
+ all = Slate.select(:slatename)
318
+ all.each { |r| slatenames << r.slatename }
319
+ return slatenames
320
+ end
321
+
322
+ def list_hosts
323
+ hostnames = []
324
+ all = Host.select(:hostname)
325
+ all.each { |h| hostnames << h.hostname }
326
+ return hostnames
327
+ end
328
+
329
+ def remove_slate(name)
330
+ s = Slate.find_by(slatename: "#{name}")
331
+ s.destroy
332
+ logger = Logger.new('../log/slate.log', 2, 2000000)
333
+ logger.info "The slate #{name} was removed"
334
+ logger.close
335
+ end
336
+
337
+ def get_update_time
338
+ s = GeneralSetting.find_by(settings: "0")
339
+ t = s.updatetime
340
+ return t
341
+ end
342
+
343
+ def set_update_time(seconds)
344
+ s = GeneralSetting.find_by(settings: "0")
345
+ s.updatetime = "#{seconds}"
346
+ setting = GeneralSetting.new(locktime: "7", updatetime: "#{seconds}")
347
+ GeneralSetting::error_handler_utime(setting)
348
+ s.save
349
+ end
350
+
351
+ def get_lock_time
352
+ s = GeneralSetting.find_by(settings: "0")
353
+ t = s.locktime
354
+ return t
355
+ end
356
+
357
+ def set_lock_time(minutes)
358
+ s = GeneralSetting.find_by(settings: "0")
359
+ s.locktime = "#{minutes}"
360
+ setting = GeneralSetting.new(locktime: "#{minutes}", updatetime: "8")
361
+ GeneralSetting::error_handler_lock(setting)
362
+ s.save
363
+ end
364
+
365
+ def get_lock_state
366
+ s = GeneralSetting.find_by(settings: "0")
367
+ l = s.lockslatecheck
368
+ return l
369
+ end
370
+
371
+ def set_lock_state(checked)
372
+ s = GeneralSetting.find_by(settings: "0")
373
+ s.lockslatecheck = "#{checked}"
374
+ s.save
375
+ end
376
+
377
+ def get_admin_status
378
+ s = GeneralSetting.find_by(settings: "0")
379
+ a = s.adminstatus
380
+ return a
381
+ end
382
+
383
+ def set_admin_status(checked)
384
+ s = GeneralSetting.find_by(settings: "0")
385
+ s.adminstatus = "#{checked}"
386
+ s.save
387
+ end
388
+
389
+ def get_admin_password
390
+ s = GeneralSetting.find_by(settings: "0")
391
+ p = s.adminpassword
392
+ return p
393
+ end
394
+
395
+ def set_admin_password(password)
396
+ s = GeneralSetting.find_by(settings: "0")
397
+ s.adminpassword = "#{password}"
398
+ setting = GeneralSetting.new(adminpassword: "#{password}", updatetime: "4")
399
+ GeneralSetting::error_handler_password(setting)
400
+ s.save
401
+ end
402
+
403
+ def get_connectivity
404
+ s = GeneralSetting.find_by(settings: "0")
405
+ c = s.networkcheck
406
+ return c
407
+ end
408
+
409
+ def set_connectivity(connect)
410
+ s = GeneralSetting.find_by(settings: "0")
411
+ s.networkcheck = "#{connect}"
412
+ s.save
413
+ end
414
+
415
+ def using_cmd?
416
+ s = Status.find_by(state: "0")
417
+ u = s.cmdlineresponse
418
+ return u
419
+ end
420
+
421
+ def set_cmd_view(state)
422
+ s = Status.find_by(state: "0")
423
+ s.cmdlineresponse = "#{state}"
424
+ s.save
425
+ end
426
+
427
+ end
428
+
429
+ #Developer : Mark Focella (m.focella@gmail.com)
430
+ #Date : February 17, 2014