chef-core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2018-2019 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "r18n-desktop"
19
+ require "chef_core/text/text_wrapper"
20
+ require "chef_core/text/error_translation"
21
+
22
+ # A very thin wrapper around R18n, the idea being that we're likely to replace r18n
23
+ # down the road and don't want to have to change all of our commands.
24
+ module ChefCore
25
+ module Text
26
+
27
+ DEFAULT_LOCALIZATION_PATH = File.absolute_path(File.join(File.dirname(__FILE__), "..", "..", "i18n"))
28
+
29
+ # Set up this gem's localization as the only one present
30
+ def self.reset!
31
+ @localization_paths = []
32
+ @raw_localization_paths = []
33
+ add_localization(DEFAULT_LOCALIZATION_PATH)
34
+ end
35
+
36
+ def self.add_localization(base_path)
37
+ return if @raw_localization_paths.include? base_path
38
+ # @localization_paths will get modified by R18n, so we'll
39
+ # keep them as strings as well, to ensure we can avoid duplicate loading.
40
+ errors_path = File.join(base_path, "errors")
41
+ @localization_paths << base_path
42
+ @localization_paths << errors_path
43
+ @raw_localization_paths << base_path
44
+ @raw_localization_paths << errors_path
45
+ reload!
46
+ end
47
+
48
+ def self.add_gem_localization(gem_name)
49
+ spec = Gem::Specification.find_by_name(gem_name)
50
+ path = File.join(spec.gem_dir, "i18n")
51
+ if File.directory? path
52
+ add_localization(path)
53
+ end
54
+ end
55
+
56
+ def self.reload!
57
+ R18n.reset!
58
+ R18n.from_env(@localization_paths)
59
+ t = R18n.get.t
60
+ t.translation_keys.each do |k|
61
+ k = k.to_sym
62
+ define_singleton_method k do |*args|
63
+ # If this is a top-level entry without children
64
+ # (such as 'cancel') it will have no translation
65
+ # keys and doees not need a wrapper
66
+ tree = t.send(k, *args)
67
+ if tree.methods.include?(:translation_keys)
68
+ TextWrapper.new(tree)
69
+ else
70
+ tree.to_s
71
+ end
72
+ end
73
+ end
74
+ end
75
+ # Load this gem's built-in errors during class load to ensure that
76
+ # error display info will be available.
77
+ reset!
78
+ end
79
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2018 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module ChefCore
19
+ VERSION = "0.0.1".freeze
20
+ end
data/lib/chef_core.rb ADDED
@@ -0,0 +1,3 @@
1
+ module ChefCore
2
+
3
+ end
@@ -0,0 +1,40 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2017-2019 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "chef/handler"
19
+ require "chef/log"
20
+ require "chef/file_cache"
21
+ require "chef/resource/directory"
22
+
23
+ module ChefCore
24
+ class ChefRunReporter < ::Chef::Handler
25
+ def report
26
+ if exception
27
+ Chef::Log.error("Creating exception report")
28
+ else
29
+ Chef::Log.info("Creating run report")
30
+ end
31
+
32
+ # ensure start time and end time are output in the json properly in the event activesupport happens to be on the system
33
+ run_data = data
34
+ run_data[:start_time] = run_data[:start_time].to_s
35
+ run_data[:end_time] = run_data[:end_time].to_s
36
+
37
+ Chef::FileCache.store("run-report.json", Chef::JSONCompat.to_json_pretty(run_data), 0640)
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,307 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chef Software, Inc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pastel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-spinner
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-color
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-cursor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mixlib-log
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: train
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: chef-telemetry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: r18n-desktop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: bundler
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: pry-byebug
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: pry-stack_explorer
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: rspec_junit_formatter
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: chefstyle
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ description: Composable common actions for assembling Chef workflows
252
+ email:
253
+ - workstation@chef.io
254
+ executables: []
255
+ extensions: []
256
+ extra_rdoc_files: []
257
+ files:
258
+ - LICENSE
259
+ - i18n/errors/en.yml
260
+ - lib/chef_core.rb
261
+ - lib/chef_core/cliux.rb
262
+ - lib/chef_core/cliux/status_reporter.rb
263
+ - lib/chef_core/cliux/ui/error_printer.rb
264
+ - lib/chef_core/cliux/ui/plain_text_element.rb
265
+ - lib/chef_core/cliux/ui/plain_text_header.rb
266
+ - lib/chef_core/cliux/ui/terminal.rb
267
+ - lib/chef_core/cliux/ui/terminal/job.rb
268
+ - lib/chef_core/error.rb
269
+ - lib/chef_core/errors/standard_error_resolver.rb
270
+ - lib/chef_core/file_fetcher.rb
271
+ - lib/chef_core/log.rb
272
+ - lib/chef_core/target_host.rb
273
+ - lib/chef_core/target_host/linux.rb
274
+ - lib/chef_core/target_host/windows.rb
275
+ - lib/chef_core/target_resolver.rb
276
+ - lib/chef_core/telemeter.rb
277
+ - lib/chef_core/telemeter/patch.rb
278
+ - lib/chef_core/telemeter/sender.rb
279
+ - lib/chef_core/text.rb
280
+ - lib/chef_core/text/error_translation.rb
281
+ - lib/chef_core/text/text_wrapper.rb
282
+ - lib/chef_core/version.rb
283
+ - resources/chef_run_reporter.rb
284
+ homepage: https://github.com/chef/chef_core
285
+ licenses:
286
+ - Apache-2.0
287
+ metadata: {}
288
+ post_install_message:
289
+ rdoc_options: []
290
+ require_paths:
291
+ - lib
292
+ required_ruby_version: !ruby/object:Gem::Requirement
293
+ requirements:
294
+ - - ">="
295
+ - !ruby/object:Gem::Version
296
+ version: 2.5.0
297
+ required_rubygems_version: !ruby/object:Gem::Requirement
298
+ requirements:
299
+ - - ">="
300
+ - !ruby/object:Gem::Version
301
+ version: '0'
302
+ requirements: []
303
+ rubygems_version: 3.0.3
304
+ signing_key:
305
+ specification_version: 4
306
+ summary: Composable common actions for assembling Chef workflows
307
+ test_files: []