hammer_cli_foreman_openscap 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4053093fab70333c87945c70a8dfaa09ee5b9e9
4
- data.tar.gz: 9c106bcf1b4f8b3545c031c8ef72416811e44649
3
+ metadata.gz: 7f615d3216c436b10ee3ce5648adafb7a4a99cdb
4
+ data.tar.gz: 62ba1ea938ff2b8a028a6df9a24edcd4d5e9c90a
5
5
  SHA512:
6
- metadata.gz: b451aa054eda45c22d136a20296b44176af0c5eb8fa87a0f8b783a1ed58b9522b302bbf6901a4f2e668241f9f2b5a7563252a1c980cfdbf9c1141f9a7829a868
7
- data.tar.gz: 9a067a4e6502b95804fd8792a21caab0f23c33f18d1747d01ec6363fb962f7d1944f089e9f75634c79dd2a6497b1735eac84dd9f1c9cbf624a723aadf46896a3
6
+ metadata.gz: e5003bedf626c98610254a8f7a1af2a2c50067777b9521f49a0539eefd7e4e85b56f3ddde30e4c58c25b71b6c92b4e4c6efe91599813d823dd0e913aacab06bb
7
+ data.tar.gz: fabf00f0f67644cc20ff42af54a0cb431ac83bd1bb559534e544710ee7b84918d7ba6289f4dac5c9dba9e82cad84421c011ca47b8a7de9a671747bafc57d4edb
@@ -1,6 +1,7 @@
1
1
  require 'hammer_cli_foreman'
2
2
  require 'hammer_cli_foreman_openscap/id_resolver'
3
3
  require 'hammer_cli_foreman_openscap/commands'
4
+ require 'hammer_cli_foreman_openscap/error'
4
5
  require 'hammer_cli_foreman_openscap/exception_handler'
5
6
 
6
7
  module HammerCLIForemanOpenscap
@@ -33,6 +33,15 @@ module HammerCLIForemanOpenscap
33
33
  build_options
34
34
  end
35
35
 
36
+ class DownloadCommand < HammerCLIForemanOpenscap::DownloadCommand
37
+ success_message _("Arf report downloaded")
38
+ failure_message _("Could not download the Arf report")
39
+
40
+ option "--path", "PATH", _("Path where to save downloaded file"),
41
+ :attribute_name => :option_path
42
+ build_options
43
+ end
44
+
36
45
  autoload_subcommands
37
46
  end
38
47
  end
@@ -28,4 +28,26 @@ module HammerCLIForemanOpenscap
28
28
  class CreateCommand < HammerCLIForeman::CreateCommand
29
29
  include HammerCLIForemanOpenscap::ResolverCommons
30
30
  end
31
+
32
+ class DownloadCommand < HammerCLIForeman::Command
33
+ include HammerCLIForemanOpenscap::ResolverCommons
34
+ action :download
35
+
36
+ def self.command_name(name = nil)
37
+ super(name) || "download"
38
+ end
39
+
40
+ def request_options
41
+ { :response => :raw }
42
+ end
43
+
44
+ def print_data(response)
45
+ # get file name from header, remove leading and trailing quotes
46
+ filename = response.headers[:content_disposition].match(/filename=(.*)/)[1].chop.reverse.chop.reverse
47
+ path = option_path.dup || '.'
48
+ path << '/' unless path.end_with? '/'
49
+ raise HammerCLIForemanOpenscap::DownloadError.new "Cannot save file: #{path} does not exist" unless File.directory?(path)
50
+ File.write(path + filename, response.body)
51
+ end
52
+ end
31
53
  end
@@ -0,0 +1,4 @@
1
+ module HammerCLIForemanOpenscap
2
+ class DownloadError < RuntimeError
3
+ end
4
+ end
@@ -3,12 +3,18 @@ module HammerCLIForemanOpenscap
3
3
  def mappings
4
4
  [
5
5
  [RestClient::InternalServerError, :handle_internal_error],
6
- [RestClient::UnprocessableEntity, :handle_unprocessable_entity]
6
+ [RestClient::UnprocessableEntity, :handle_unprocessable_entity],
7
+ [HammerCLIForemanOpenscap::DownloadError, :handle_download_error]
7
8
  ] + super
8
9
  end
9
10
 
10
11
  protected
11
12
 
13
+ def handle_download_error(e)
14
+ print_error e.message
15
+ log_full_error e
16
+ end
17
+
12
18
  def handle_internal_error(e)
13
19
  handle_scap_error(e)
14
20
  HammerCLI::EX_SOFTWARE
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanOpenscap
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.1.1'
3
+ @version ||= Gem::Version.new '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Foreman team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-06 00:00:00.000000000 Z
11
+ date: 2016-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -36,6 +36,7 @@ files:
36
36
  - lib/hammer_cli_foreman_openscap.rb
37
37
  - lib/hammer_cli_foreman_openscap/arf_report.rb
38
38
  - lib/hammer_cli_foreman_openscap/commands.rb
39
+ - lib/hammer_cli_foreman_openscap/error.rb
39
40
  - lib/hammer_cli_foreman_openscap/exception_handler.rb
40
41
  - lib/hammer_cli_foreman_openscap/id_resolver.rb
41
42
  - lib/hammer_cli_foreman_openscap/policy.rb
@@ -70,7 +71,7 @@ rubyforge_project:
70
71
  rubygems_version: 2.4.6
71
72
  signing_key:
72
73
  specification_version: 4
73
- summary: ForemanOpenscap commands for Hammer
74
+ summary: Foreman OpenSCAP commands for Hammer
74
75
  test_files:
75
76
  - test/compliance_resource_mock.rb
76
77
  - test/test_helper.rb