percheron 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.cane +4 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +31 -0
  5. data/.travis.yml +4 -1
  6. data/Guardfile +3 -3
  7. data/README.md +19 -3
  8. data/Rakefile +24 -1
  9. data/bin/percheron +2 -20
  10. data/lib/percheron/actions/base.rb +0 -39
  11. data/lib/percheron/actions/build.rb +9 -7
  12. data/lib/percheron/actions/create.rb +64 -38
  13. data/lib/percheron/actions/exec.rb +40 -8
  14. data/lib/percheron/actions/exec_local.rb +4 -4
  15. data/lib/percheron/actions/logs.rb +44 -0
  16. data/lib/percheron/actions/purge.rb +15 -4
  17. data/lib/percheron/actions/recreate.rb +15 -65
  18. data/lib/percheron/actions/restart.rb +2 -1
  19. data/lib/percheron/actions/shell.rb +27 -0
  20. data/lib/percheron/actions/start.rb +10 -7
  21. data/lib/percheron/actions.rb +2 -1
  22. data/lib/percheron/commands/abstract.rb +20 -8
  23. data/lib/percheron/commands/build.rb +13 -0
  24. data/lib/percheron/commands/console.rb +53 -0
  25. data/lib/percheron/commands/create.rb +3 -3
  26. data/lib/percheron/commands/list.rb +7 -3
  27. data/lib/percheron/commands/logs.rb +16 -0
  28. data/lib/percheron/commands/main.rb +5 -2
  29. data/lib/percheron/commands/purge.rb +2 -2
  30. data/lib/percheron/commands/recreate.rb +3 -11
  31. data/lib/percheron/commands/restart.rb +2 -2
  32. data/lib/percheron/commands/shell.rb +16 -0
  33. data/lib/percheron/commands/start.rb +2 -2
  34. data/lib/percheron/commands/stop.rb +2 -2
  35. data/lib/percheron/commands.rb +3 -0
  36. data/lib/percheron/config.rb +64 -3
  37. data/lib/percheron/config_delegator.rb +0 -1
  38. data/lib/percheron/container.rb +95 -38
  39. data/lib/percheron/core_extensions.rb +1 -4
  40. data/lib/percheron/docker_connection.rb +5 -1
  41. data/lib/percheron/formatters/stack/table.rb +24 -12
  42. data/lib/percheron/logger.rb +21 -0
  43. data/lib/percheron/metastore.rb +1 -0
  44. data/lib/percheron/null_stack.rb +5 -0
  45. data/lib/percheron/oh_dear.rb +15 -7
  46. data/lib/percheron/stack.rb +77 -72
  47. data/lib/percheron/validators/config.rb +1 -1
  48. data/lib/percheron/validators/container.rb +31 -11
  49. data/lib/percheron/validators/stack.rb +3 -5
  50. data/lib/percheron/version.rb +1 -1
  51. data/lib/percheron.rb +2 -0
  52. data/percheron.gemspec +4 -1
  53. metadata +54 -4
  54. data/assets/percheron.png +0 -0
  55. data/lib/percheron/actions/rename.rb +0 -65
@@ -10,7 +10,7 @@ module Percheron
10
10
  message = rules.return { |rule| send(rule) }
11
11
 
12
12
  if message
13
- raise Errors::StackInvalid.new(message)
13
+ fail Errors::StackInvalid, message
14
14
  else
15
15
  true
16
16
  end
@@ -21,13 +21,11 @@ module Percheron
21
21
  attr_reader :stack
22
22
 
23
23
  def rules
24
- [
25
- :validate_name
26
- ]
24
+ [ :validate_name ]
27
25
  end
28
26
 
29
27
  def validate_name
30
- 'Name is invalid' if stack.name.nil? || !stack.name.to_s.match(/[\w\d]{3,}/)
28
+ 'Stack name is invalid' if stack.name.nil? || !stack.name.to_s.match(/[\w\d]{3,}/)
31
29
  end
32
30
 
33
31
  end
@@ -1,3 +1,3 @@
1
1
  module Percheron
2
- VERSION = "0.6.4"
2
+ VERSION = '0.7.0'
3
3
  end
data/lib/percheron.rb CHANGED
@@ -5,6 +5,7 @@ require 'docker'
5
5
  require 'naught'
6
6
  require 'semantic'
7
7
  require 'metastore'
8
+ require 'liquid'
8
9
 
9
10
  require 'percheron/oh_dear'
10
11
  require 'percheron/core_extensions'
@@ -15,6 +16,7 @@ require 'percheron/config_delegator'
15
16
  require 'percheron/formatters'
16
17
  require 'percheron/validators'
17
18
  require 'percheron/stack'
19
+ require 'percheron/null_stack'
18
20
  require 'percheron/container'
19
21
  require 'percheron/null_container'
20
22
  require 'percheron/actions'
data/percheron.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = [ 'Ash McKenzie' ]
10
10
  spec.email = [ 'ash@the-rebellion.net' ]
11
11
 
12
- spec.summary = %q{Organise your Docker containers with muscle and intelligence}
12
+ spec.summary = 'Organise your Docker containers with muscle and intelligence'
13
13
  spec.homepage = 'https://github.com/ashmckenzie/percheron'
14
14
  spec.license = 'MIT'
15
15
 
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'semantic', '~> 1.4'
27
27
  spec.add_runtime_dependency 'metastore', '~> 0.3'
28
28
  spec.add_runtime_dependency 'highline', '~> 1.7.1'
29
+ spec.add_runtime_dependency 'liquid', '~> 3.0'
29
30
 
30
31
  spec.add_development_dependency 'bundler', '~> 1.7'
31
32
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -33,4 +34,6 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency 'guard-rspec', '~> 4.5'
34
35
  spec.add_development_dependency 'simplecov', '~> 0.9'
35
36
  spec.add_development_dependency 'timecop', '~> 0.7'
37
+ spec.add_development_dependency 'rubocop', '~> 0.30.0'
38
+ spec.add_development_dependency 'cane', '~> 2.6.0'
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percheron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash McKenzie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.7.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: liquid
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +220,34 @@ dependencies:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
222
  version: '0.7'
223
+ - !ruby/object:Gem::Dependency
224
+ name: rubocop
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: 0.30.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.30.0
237
+ - !ruby/object:Gem::Dependency
238
+ name: cane
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 2.6.0
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 2.6.0
209
251
  description:
210
252
  email:
211
253
  - ash@the-rebellion.net
@@ -214,8 +256,10 @@ executables:
214
256
  extensions: []
215
257
  extra_rdoc_files: []
216
258
  files:
259
+ - ".cane"
217
260
  - ".gitignore"
218
261
  - ".rspec"
262
+ - ".rubocop.yml"
219
263
  - ".travis.yml"
220
264
  - CODE_OF_CONDUCT.md
221
265
  - Gemfile
@@ -223,7 +267,6 @@ files:
223
267
  - LICENSE.txt
224
268
  - README.md
225
269
  - Rakefile
226
- - assets/percheron.png
227
270
  - bin/percheron
228
271
  - lib/percheron.rb
229
272
  - lib/percheron/actions.rb
@@ -232,21 +275,25 @@ files:
232
275
  - lib/percheron/actions/create.rb
233
276
  - lib/percheron/actions/exec.rb
234
277
  - lib/percheron/actions/exec_local.rb
278
+ - lib/percheron/actions/logs.rb
235
279
  - lib/percheron/actions/purge.rb
236
280
  - lib/percheron/actions/recreate.rb
237
- - lib/percheron/actions/rename.rb
238
281
  - lib/percheron/actions/restart.rb
282
+ - lib/percheron/actions/shell.rb
239
283
  - lib/percheron/actions/start.rb
240
284
  - lib/percheron/actions/stop.rb
241
285
  - lib/percheron/commands.rb
242
286
  - lib/percheron/commands/abstract.rb
287
+ - lib/percheron/commands/build.rb
243
288
  - lib/percheron/commands/console.rb
244
289
  - lib/percheron/commands/create.rb
245
290
  - lib/percheron/commands/list.rb
291
+ - lib/percheron/commands/logs.rb
246
292
  - lib/percheron/commands/main.rb
247
293
  - lib/percheron/commands/purge.rb
248
294
  - lib/percheron/commands/recreate.rb
249
295
  - lib/percheron/commands/restart.rb
296
+ - lib/percheron/commands/shell.rb
250
297
  - lib/percheron/commands/start.rb
251
298
  - lib/percheron/commands/stop.rb
252
299
  - lib/percheron/config.rb
@@ -258,7 +305,10 @@ files:
258
305
  - lib/percheron/formatters.rb
259
306
  - lib/percheron/formatters/stack.rb
260
307
  - lib/percheron/formatters/stack/table.rb
308
+ - lib/percheron/logger.rb
309
+ - lib/percheron/metastore.rb
261
310
  - lib/percheron/null_container.rb
311
+ - lib/percheron/null_stack.rb
262
312
  - lib/percheron/oh_dear.rb
263
313
  - lib/percheron/stack.rb
264
314
  - lib/percheron/validators.rb
data/assets/percheron.png DELETED
Binary file
@@ -1,65 +0,0 @@
1
- module Percheron
2
- module Actions
3
- class Rename
4
-
5
- include Base
6
-
7
- def initialize(container, temporary_name, new_name)
8
- @container = container
9
- @temporary_name = temporary_name
10
- @new_name = new_name
11
- end
12
-
13
- def execute!
14
- results = []
15
- results << rename!
16
- results.compact.empty? ? nil : container
17
- end
18
-
19
- private
20
-
21
- attr_reader :container, :temporary_name, :new_name
22
-
23
- def rename_current_new_name
24
- @rename_current_new_name ||= '%s_%s' % [ container.name, now_timestamp ]
25
- end
26
-
27
- def old_container
28
- Docker::Container.get(rename_current_new_name)
29
- end
30
-
31
- def temporary_container
32
- Docker::Container.get(temporary_name)
33
- end
34
-
35
- def rename!
36
- container_running = container.running?
37
- stop_containers!([ container ]) if container_running
38
- rename_containers!
39
- start_containers!([ container ]) if container_running
40
- remove_old!
41
- end
42
-
43
- def rename_containers!
44
- rename_container_current_to_old! if container.exists?
45
- rename_container_temporary_to_new!
46
- end
47
-
48
- def rename_container_current_to_old!
49
- $logger.info "Renaming '#{container.name}' container to '#{rename_current_new_name}'"
50
- container.docker_container.rename(rename_current_new_name)
51
- end
52
-
53
- def rename_container_temporary_to_new!
54
- $logger.info "Renaming '#{temporary_name}' container to '#{new_name}'"
55
- temporary_container.rename(new_name)
56
- end
57
-
58
- def remove_old!
59
- $logger.info "Removing '#{rename_current_new_name}' container"
60
- old_container.remove
61
- end
62
-
63
- end
64
- end
65
- end