opensecret 0.0.913 → 0.0.941

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -0
  3. data/README.md +129 -19
  4. data/Rakefile +0 -9
  5. data/bin/opensecret +1 -1
  6. data/lib/{opensecret/plugins.io/cipher/crypto.rb → crypto/amalgam.rb} +6 -8
  7. data/lib/crypto/collect.rb +139 -0
  8. data/lib/crypto/engineer.rb +201 -0
  9. data/lib/crypto/verify.rb +33 -0
  10. data/lib/extension/array.rb +133 -0
  11. data/lib/{opensecret/additions → extension}/dir.rb +0 -0
  12. data/lib/extension/file.rb +56 -0
  13. data/lib/extension/hash.rb +33 -0
  14. data/lib/extension/string.rb +349 -0
  15. data/lib/factbase/facts.opensecret.io.ini +28 -0
  16. data/lib/logging/gem.logging.rb +133 -0
  17. data/lib/opensecret.rb +102 -45
  18. data/lib/opensecret/executors/crypt.keys/crypt.keys.ini +0 -53
  19. data/lib/session/{session.rb → attributes.rb} +60 -5
  20. data/lib/session/exceptions.rb +53 -0
  21. data/lib/session/fact.finder.rb +684 -0
  22. data/lib/session/user.home.rb +49 -0
  23. data/lib/usecase/usecase.rb +245 -0
  24. data/lib/usecase/usecases/init.rb +190 -0
  25. data/lib/usecase/usecases/on.rb +33 -0
  26. data/lib/usecase/usecases/safe.rb +95 -0
  27. data/lib/version.rb +1 -1
  28. metadata +22 -17
  29. data/lib/opensecret/additions/array.rb +0 -117
  30. data/lib/opensecret/additions/string.rb +0 -312
  31. data/lib/opensecret/commons/eco.cmdline.rb +0 -446
  32. data/lib/opensecret/eco.do.rb +0 -46
  33. data/lib/opensecret/plugins.io/error/eco.exceptions.rb +0 -24
  34. data/lib/opensecret/plugins.io/facts/fact.chars.rb +0 -66
  35. data/lib/opensecret/plugins.io/facts/fact.factor.rb +0 -156
  36. data/lib/opensecret/plugins.io/facts/fact.locator.rb +0 -105
  37. data/lib/opensecret/plugins.io/facts/fact.reader.rb +0 -137
  38. data/lib/opensecret/plugins.io/facts/fact.tree.rb +0 -661
  39. data/lib/opensecret/plugins.io/logs/log.object.rb +0 -89
  40. data/lib/opensecret/plugins.io/logs/logging.rb +0 -203
@@ -1,89 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # --
4
- # -- Log common objects such as
5
- # --
6
- # -- - files
7
- # -- - maps
8
- # --
9
- # --
10
- class LogObject
11
-
12
- # --
13
- # -- Log the file whose full path is given in the 1st parameter.
14
- # -- The string context is included in the logs which should explain
15
- # -- the whys and wherefores of the file.
16
- # --
17
- # -- An exception is thrown if the file is not found.
18
- # --
19
- def self.file file_path, file_context
20
-
21
- Throw.if_not_exists file_path
22
-
23
- log.debug(ere) { "# -- ------------------------------------------------------------------------ #" }
24
- log.debug(ere) { "# -- ------------------------------------------------------------------------ #" }
25
- log.debug(ere) { "# -- The File Path to Log => #{file_path}" }
26
-
27
- hr_file_size = PrettyPrint.byte_size( File.size(file_path) )
28
- dotless_extension = File.extname( file_path )[1..-1]
29
- parent_dir_name = File.basename( File.dirname( file_path ) )
30
- file_name = File.basename file_path
31
- is_zip = dotless_extension.eql? "zip"
32
-
33
- log.debug(ere) { "# -- ------------------------------------------------------------------------ #" }
34
- log.debug(ere) { "# -- File Name => #{file_name}" }
35
- log.debug(ere) { "# -- File Size => #{hr_file_size}" }
36
- log.debug(ere) { "# -- File Type => #{file_context}" }
37
- log.debug(ere) { "# -- In Folder => #{parent_dir_name}" }
38
- log.debug(ere) { "# -- ------------------------------------------------------------------------ #" }
39
-
40
- log.debug(ere) { "File #{file_name} is a zip (binary) file." } if is_zip
41
- return if is_zip
42
-
43
- File.open( file_path, "r") do | file_obj |
44
- line_no = 1
45
- file_obj.each_line do | file_line |
46
- line_num = sprintf '%03d', line_no
47
- clean_line = file_line.chomp.strip
48
- log.debug(ere) { "# -- [#{line_num}] - #{clean_line}" }
49
- line_no += 1
50
- end
51
- end
52
-
53
- log.debug(ere) { "# -- ------------------------------------------------------------------------ #" }
54
- log.debug(ere) { "# -- [#{file_context}] End of File [ #{File.basename(file_path)} ]" }
55
- log.debug(ere) { "# -- ------------------------------------------------------------------------ #" }
56
-
57
- end
58
-
59
-
60
- # --
61
- # -- Log map with a key-value pair on each line.
62
- # --
63
- # -- Parameter
64
- # -- the_map : the map to log
65
- # --
66
- # -- Dependencies and Assumptions
67
- # -- the map has been instantiated (not nil)
68
- # --
69
- def self.map the_map
70
-
71
- return if the_map.nil?
72
-
73
- log.debug(ere) { "# --- ----------------------------------------------" }
74
- log.debug(ere) { "# --- Map has [#{the_map.length}] key/value pairs." }
75
- log.debug(ere) { "# --- ----------------------------------------------" }
76
-
77
- the_map.each do |the_key, the_value|
78
-
79
- padded_key = sprintf '%-33s', the_key
80
- log.debug(ere) { "# --- #{padded_key} => #{the_value}" }
81
-
82
- end
83
-
84
- log.debug(ere) { "# --- ----------------------------------------------" }
85
-
86
- end
87
-
88
-
89
- end
@@ -1,203 +0,0 @@
1
- # --
2
- # -- [MIXIN] magic is deployed to hand out DevOps quality logging
3
- # -- features to any class that includes the logging module.
4
- # --
5
- # -- When logging facilities are not ready we need to log just to
6
- # -- stdout but when they are we need to use them.
7
- # --
8
- # -- mixin power enables one class to give the logfile path and all
9
- # -- classes will suddenly retrieve a another logger and use that.
10
- # --
11
- # -- include Logging
12
- # -- def doImportant
13
- # -- log.warn(ere) "unhappy about doing this"
14
- # -- do_anyway
15
- # -- log.debug(ere) "all good it was okay"
16
- # -- end
17
- # --
18
- # -- -----------------------
19
- # -- What are Mixins?
20
- # -- -----------------------
21
- # --
22
- # -- Refer to the below link for excellent coverage of mixins.
23
- # -- http://ruby-doc.com/docs/ProgrammingRuby/html/tut_modules.html
24
- # --
25
- module Logging
26
-
27
- @@log_path = nil
28
- @@log_class = nil
29
-
30
- # --
31
- # -- Classes that include (MIXIN) this logging module will
32
- # -- have access to this logger method.
33
- # --
34
- # -- [memoization] is implemented here for performance and
35
- # -- will only initiate a logger under 2 circumstances
36
- # --
37
- # -- [1] - the first call (returns a STDOUT logger)
38
- # -- [2] - the call after the logfile path is set
39
- # -- (returns a more sophisticated logger)
40
- # --
41
- def log
42
-
43
- @@log_class ||= get_logger
44
-
45
- end
46
-
47
-
48
- # --
49
- # -- log.info(ere) {i woz ere}
50
- # --
51
- # -- [ere] is borrowed from the common graffiti phrase (i woz ere)
52
- # --
53
- # -- In software terms it allows the logger to print 3 crucial
54
- # -- pieces of information for the troubleshooter (detective) to
55
- # -- determine who called the logger (who was here). The
56
- # --
57
- # -- [1] - [module name] of the caller
58
- # -- [2] - [method name] the call came from
59
- # -- [3] - [line number] of the call
60
- # --
61
- # --
62
- def ere
63
-
64
- module_name = File.basename caller_locations(1,1).first.absolute_path, ".rb"
65
- method_name = caller_locations(1,1).first.base_label
66
- line_number = caller_locations(1,1).first.lineno
67
-
68
- "#{module_name} | #{method_name} | (line #{line_number}) "
69
-
70
- end
71
-
72
- # --
73
- # -- If logger is used at the [BEGINNING] when
74
- # -- the runtime logfile path has not yet been
75
- # -- ascertained then STDOUT is used.
76
- # --
77
- # -- However if we have been informed (via the
78
- # -- set_logfile_path) that the logfile path is
79
- # -- now known the logger returned will be set
80
- # -- to log to the specified file.
81
- # --
82
- # -- [memoization] should be used so that this
83
- # -- method gets called only [TWICE].
84
- # --
85
- # -- [1] - at the [beginning] when the logfile path is not known
86
- # -- [2] - just [after] the logfile dir is evaluated and created
87
- # --
88
- def get_logger
89
-
90
- expensive_initializr = "EXPENSIVE(x2) => This log message should only appear [TWICE]."
91
- Logger.new(STDOUT).warn "#{expensive_initializr}"
92
-
93
- return get_stdout_logger if @@log_path.nil?
94
-
95
- file_logger = Logger.new( Logging.initializr_str )
96
- original_formatter = Logger::Formatter.new
97
-
98
- file_logger.formatter = proc { |severity, datetime, progname, msg|
99
- ######## original_formatter.call(severity, datetime, progname, msg.dump.chomp.strip.delete("\"\\"))
100
- original_formatter.call( severity, datetime, progname, msg.dump.chomp.strip )
101
- }
102
-
103
- if CmdLine.has? "--debug" then
104
- file_logger.level = Logger::DEBUG
105
- else
106
- file_logger.level = Logger::INFO
107
- end
108
-
109
- return file_logger
110
-
111
- end
112
-
113
-
114
- # --
115
- # -- Get the logger class initiaze string.
116
- # -- The OS platform "Windows" vs "Linux" dictates
117
- # -- what is returned as the "tee" command used to
118
- # -- redirect logging output bot the console and a
119
- # -- standard log file is not available on Windows.
120
- # --
121
- # -- Return the initializer for the logging statement.
122
- # --
123
- # -- ------------
124
- # -- Windows
125
- # -- ------------
126
- # --
127
- # -- Continue logging solely to STANDARD OUT.
128
- # -- We could log to a file but not to both.
129
- # --
130
- # -- ------------
131
- # -- Linux
132
- # -- ------------
133
- # --
134
- # -- Send back TEE command so that logs pipe to
135
- # -- both standard out and the designated logfile.
136
- # --
137
- def self.initializr_str
138
-
139
- return STDOUT if Gem.win_platform?
140
- return "| tee #{@@log_path}"
141
-
142
- end
143
-
144
-
145
- # --
146
- # -- Get a simple STDOUT logger using the
147
- # -- designated log level.
148
- # --
149
- # -- As the early stage when we do not have a
150
- # -- log file destination the logs are set to
151
- # -- the DEBUG (max) level.
152
- # --
153
- # -- If you need just INFO level logs right
154
- # -- from the get go - go amend this method.
155
- # --
156
- def get_stdout_logger
157
-
158
- stdout_logger = Logger.new(STDOUT)
159
- stdout_logger.level = Logger::DEBUG
160
- return stdout_logger
161
-
162
- end
163
-
164
-
165
- #--
166
- #-- Set logfile path and [INVALIDATE] the
167
- #-- cache so that memoization reads the new
168
- #-- @log_class object.
169
- #--
170
- def set_logfile_path path_to_set
171
-
172
- @@log_path = path_to_set
173
- @@log_class = nil
174
-
175
- end
176
-
177
-
178
- #--
179
- #-- Return the filename and its two immediate
180
- #-- parent folders (parent and grandparent).
181
- #--
182
- #-- When this is not possible when the filepath
183
- #-- is near the filesystem's root - it returns
184
- #-- whatever is possible.
185
- #--
186
- #-- IMPLEMENT ABOVE FUNCTIONALITY WHEN NEEDED.
187
- #-- CURRENTLY IT JUST BLUNDERS IN WITH NEITHER
188
- #-- RHYME NOR REASON.
189
- #--
190
- def nickname object_path
191
-
192
- object_name = File.basename object_path
193
- parent_folder = File.dirname object_path
194
- parent_name = File.basename parent_folder
195
- granny_folder = File.dirname parent_folder
196
- granny_name = File.basename granny_folder
197
-
198
- return [granny_name,parent_name,object_name].join("/")
199
-
200
- end
201
-
202
-
203
- end