lux 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/lux +3 -4
  4. data/lib/lux.rb +21 -19
  5. data/lib/lux/version.rb +1 -1
  6. data/lux.gemspec +4 -4
  7. metadata +16 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6288ab37dee1e32be74b9ae50a4e90857ee1f175
4
- data.tar.gz: 004c036416714fa00796143a43338b00e307f1dc
3
+ metadata.gz: 3eaee859f2e47a11dd2f1561c33a655478b89b76
4
+ data.tar.gz: 8bfdb4795d60647e9711c3823d6259f14f5ac438
5
5
  SHA512:
6
- metadata.gz: 5f7504d919e5dac6496d00ab30c625858f7d79d0d7c063396fb5b6a9dcc2fc56a5e1905b6f38b0a3fa4e57bfa1a2810458488bcb949fa9c59d5853fb881e378b
7
- data.tar.gz: 8d1ebc2248e1dc3acdb87344a5a8b0308b7d8f55e14f6ca5b802b27c2a59862f2c03021e04a118a787a8e724a94f7d3f6a10b180d1b951e7b826767cafe330dc
6
+ metadata.gz: cdfabbacc607ea2d2a80572d2824f1d95e7ef037b9b3cc8dccecb2a21e6ecbbbd6861e115eb9b1c7f2c2baab9afe39fa4ed0cc9fe3abcf95cbefb120854052be
7
+ data.tar.gz: bb8cb85f41a41a65ab4eb03a827c4b3f61e0d3247dce0da7c87911c4e25afd64ae02a161df4fbd1ee13587ebc437e15b7ffe5ce200d613b5c4a1b2e47733ef18
data/README.md CHANGED
@@ -92,7 +92,7 @@ end
92
92
  # Note how the task name does not include the tag
93
93
  desc "Run Tools"
94
94
  task :runt => 'quay.io/rasputin/tools' do
95
- sh "docker run -it quay.io/turnitin/seu-tools:1.0 /bin/bash"
95
+ sh "docker run -it quay.io/rasputin/tools:1.0 /bin/bash"
96
96
  end
97
97
  ```
98
98
 
data/bin/lux CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ require 'lux'
2
4
 
3
- require "bundler/setup"
4
- require "lux"
5
-
6
- trap("INT") do
5
+ trap('INT') do
7
6
  print "\n"
8
7
  exit(1)
9
8
  end
data/lib/lux.rb CHANGED
@@ -53,12 +53,12 @@ class Lux::App < Thor
53
53
  end
54
54
  end
55
55
 
56
- desc "start", "Run a Docker container with user/home mapping (default is 'base')"
57
- method_option :image, type: :string, aliases: '-i', default: 'base', desc: 'Docker image'
56
+ desc "start IMAGE", "Run a Docker image with user/home mapping"
58
57
  method_option :env, type: :string, aliases: '-e', desc: 'Path to environment file'
59
58
  method_option :name, type: :string, aliases: '-n', default: '<autogenerated>', desc: 'Docker container name'
60
- def start
61
- image = findimage options.image
59
+ def start(image)
60
+ image = findimage image
61
+ raise "no image" if image.empty?
62
62
  puts "Starting #{image} container..."
63
63
  me, setup_cmd = user_setup_cmd()
64
64
  args = ["-v #{ENV['HOME']}:#{ENV['HOME']}"]
@@ -76,11 +76,10 @@ class Lux::App < Thor
76
76
  XPC_SERVICE_NAME XPC_FLAGS __CF_USER_TEXT_ENCODING TERM_PROGRAM TERM_PROGRAM_VERSION TERM_SESSION_ID
77
77
  }
78
78
 
79
- desc "exec COMMAND", "Run a command inside a Docker container"
80
- method_option :image, type: :string, aliases: '-i', default: 'base', desc: 'Docker image'
79
+ desc "exec IMAGE COMMAND", "Run a command inside a Docker container"
81
80
  method_option :env, type: :string, aliases: '-e', desc: 'Path to environment file'
82
- def exec(*command)
83
- image = findimage options.image
81
+ def exec(image, *command)
82
+ image = findimage image
84
83
  me, setup_cmd = user_setup_cmd
85
84
  die "You must be within your home directory!" unless relwd = Pathname.pwd.to_s.gsub!(/^#{ENV['HOME']}/,'~')
86
85
  command.map!{|m| m.start_with?('/') ? Pathname.new(m).relative_path_from(Pathname.pwd) : m }
@@ -192,19 +191,22 @@ class Lux::App < Thor
192
191
  # Get the current list of images and make a guess at which one it is...
193
192
  #
194
193
  def findimage image
195
- if image.count('/') == 0
196
- local_images = `docker images`.strip.split("\n")[1..-1].map{|l| l.gsub!(/^(\S+)\s+(\S+).*/,'\1:\2')}.sort
197
- matching_images = local_images.select{|l| l.include? image }
198
- if matching_images.size > 0
199
- if image.count(':') == 0
200
- matching_image = matching_images.select{|l| l.end_with? ':latest' }.first
201
- end
202
- unless matching_image
203
- matching_image = matching_images.first
194
+ local_images = `docker images`.strip.split("\n")[1..-1].map{|l| l.gsub!(/^(\S+)\s+(\S+).*/,'\1:\2')}.sort
195
+ matching_images = local_images.select{|l| l.include? image }
196
+ if matching_images.size > 0
197
+ if image.count(':') == 0 and image.count('/') > 0
198
+ matching_image = matching_images.select{|l| l.end_with? ':latest' }.first
199
+ end
200
+ unless matching_image
201
+ matching_image = HighLine.choose do |menu|
202
+ menu.header = 'List of matching (local) images'
203
+ menu.choices(*matching_images)
204
+ menu.choice('None of the above') { nil }
204
205
  end
205
- else
206
- die "No image found matching: #{image}"
206
+ exit 2 unless matching_image
207
207
  end
208
+ else
209
+ matching_image = image
208
210
  end
209
211
  return matching_image
210
212
  end
data/lib/lux/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lux
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
data/lux.gemspec CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = ">=2.0.0"
22
22
 
23
- spec.add_runtime_dependency "thor"
24
- spec.add_runtime_dependency "highline"
25
- spec.add_runtime_dependency "bundler", "~> 1.9"
23
+ spec.add_runtime_dependency "thor", "~> 0.19"
24
+ spec.add_runtime_dependency "highline", "~> 1.7"
25
+ spec.add_runtime_dependency "rake", "~> 10.0"
26
26
 
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "bundler", "~> 1.9"
28
28
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lux
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Townsend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: highline
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.7'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.9'
47
+ version: '10.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.9'
54
+ version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '1.9'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '1.9'
69
69
  description:
70
70
  email:
71
71
  - nick.townsend@mac.com