imagemaster3000 0.8.0 → 0.9.0

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: 706709ff8db7e68916455fdcf0546dc7ede63310
4
- data.tar.gz: ec12cdd3da410ec605a07fd52e3eaf098fff4133
3
+ metadata.gz: 61e5dc4473085611c7b91bb0308463f307f660ee
4
+ data.tar.gz: d4f951f7dede795722204617023a45bcf68a6b0d
5
5
  SHA512:
6
- metadata.gz: 575d4700bc20c4a01fb3256d6e37c9b6d0107f2508f6013c89871920876239b88b860ebd8adc3baed1b82822ffe8de56407e4fe6f78bd7d5101d09e44241f863
7
- data.tar.gz: 7fb0e0e92515b2a699bcd7c0f7410d8fe8f861d9479ddfb3e97d96af9761b6a637a3f6f3f05139932093d50994f80107c6e553e084416d214426d8741eba8876
6
+ metadata.gz: f551c535fdf3b69d30b34bf07557a3812af67126a651ebcc35dab8e46975b1aded752e256d3ae7c981f9715802db9b2e459d79986ed4a56173e4113226bd232b
7
+ data.tar.gz: bf0a1b4734bb0c8923edbdbd11834530fd8d2b34dddb6cba3f73254622a0a516ac93ef22983bb7001d4f623f939190f60e02d43c266e20d03cf1fc0691fe44db
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'imagemaster3000/version'
4
4
 
@@ -2,5 +2,6 @@ module Imagemaster3000
2
2
  module Actions
3
3
  autoload :Copy, 'imagemaster3000/actions/copy'
4
4
  autoload :Remove, 'imagemaster3000/actions/remove'
5
+ autoload :Link, 'imagemaster3000/actions/link'
5
6
  end
6
7
  end
@@ -0,0 +1,35 @@
1
+ module Imagemaster3000
2
+ module Actions
3
+ class Link
4
+ attr_accessor :target, :link, :symbolic
5
+
6
+ def initialize(target: nil, link: nil, symbolic: false)
7
+ raise Imagemaster3000::Errors::ArgumentError, 'neither target nor link can be nil' if target.empty? || link.empty?
8
+
9
+ @target = target
10
+ @link = link
11
+ @symbolic = symbolic
12
+ logger.debug "Created action #{inspect}"
13
+ end
14
+
15
+ def run(image_file)
16
+ logger.debug "Running 'link' action with target #{target.inspect} and link #{link.inspect} on file #{image_file.inspect}"
17
+ ln image_file
18
+ rescue Imagemaster3000::Errors::CommandExecutionError => ex
19
+ raise Imagemaster3000::Errors::ActionError, ex
20
+ end
21
+
22
+ def ln(image_file)
23
+ ln_command = symbolic ? 'ln-s' : 'ln'
24
+
25
+ Imagemaster3000::Utils::CommandExecutioner.execute Imagemaster3000::Settings[:'binaries-guestfish'],
26
+ '-a',
27
+ image_file,
28
+ '-i',
29
+ ln_command,
30
+ target,
31
+ link
32
+ end
33
+ end
34
+ end
35
+ end
@@ -20,6 +20,18 @@
20
20
  "title":"Name",
21
21
  "type":"string"
22
22
  },
23
+ "linkname":{
24
+ "description":"Link file",
25
+ "id":"#linkname",
26
+ "title":"Link",
27
+ "type":"string"
28
+ },
29
+ "symbolic":{
30
+ "description":"Whether created link should be symbolic",
31
+ "id":"#symbolic",
32
+ "title":"Symbolic",
33
+ "type":"boolean"
34
+ },
23
35
  "copy":{
24
36
  "additionalItems":false,
25
37
  "id":"#copy",
@@ -54,6 +66,30 @@
54
66
  },
55
67
  "type":"array"
56
68
  },
69
+ "link":{
70
+ "additionalItems":false,
71
+ "id":"#link",
72
+ "items":{
73
+ "additionalProperties":false,
74
+ "properties":{
75
+ "target":{
76
+ "$ref":"#/definitions/target"
77
+ },
78
+ "link":{
79
+ "$ref":"#/definitions/linkname"
80
+ },
81
+ "symbolic":{
82
+ "$ref":"#/definitions/symbolic"
83
+ }
84
+ },
85
+ "required":[
86
+ "target",
87
+ "link"
88
+ ],
89
+ "type":"object"
90
+ },
91
+ "type":"array"
92
+ },
57
93
  "actions":{
58
94
  "additionalProperties":false,
59
95
  "id":"#actions",
@@ -63,6 +99,9 @@
63
99
  },
64
100
  "remove":{
65
101
  "$ref":"#/definitions/remove"
102
+ },
103
+ "link":{
104
+ "$ref":"#/definitions/link"
66
105
  }
67
106
  },
68
107
  "type":"object"
@@ -32,7 +32,7 @@ module Imagemaster3000
32
32
  end
33
33
 
34
34
  response.value
35
- open(filename, 'w') { |file| response.read_body { |chunk| file.write(chunk) } }
35
+ File.open(filename, 'w') { |file| response.read_body { |chunk| file.write(chunk) } }
36
36
  end
37
37
  end
38
38
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::HTTPBadResponse,
@@ -1,4 +1,3 @@
1
- require 'open-uri'
2
1
  require 'tempfile'
3
2
 
4
3
  module Imagemaster3000
@@ -6,8 +5,8 @@ module Imagemaster3000
6
5
  class Tmp
7
6
  def self.download(url)
8
7
  file = Tempfile.new('imagemaster3000')
9
- download = open(url)
10
8
  logger.debug "Downloading file from url #{url} to tempfile #{file.path.inspect}"
9
+ download = URI.parse(url).open
11
10
  IO.copy_stream(download, file)
12
11
 
13
12
  file.rewind
@@ -15,6 +14,8 @@ module Imagemaster3000
15
14
  end
16
15
 
17
16
  def self.destroy(file)
17
+ return unless file
18
+
18
19
  logger.debug "Closing tempfile #{file.path.inspect}"
19
20
  file.close
20
21
  file.unlink
@@ -1,3 +1,3 @@
1
1
  module Imagemaster3000
2
- VERSION = '0.8.0'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagemaster3000
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kimle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-22 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -293,6 +293,7 @@ files:
293
293
  - lib/imagemaster3000.rb
294
294
  - lib/imagemaster3000/actions.rb
295
295
  - lib/imagemaster3000/actions/copy.rb
296
+ - lib/imagemaster3000/actions/link.rb
296
297
  - lib/imagemaster3000/actions/remove.rb
297
298
  - lib/imagemaster3000/cleaner.rb
298
299
  - lib/imagemaster3000/cli.rb