dev_dock 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 010bb5ac9923609562ed9d55ca2d841832b568916e72779b05610a84842b61f6
4
- data.tar.gz: 11d8dc854c1e714a9d54e062be1f5d128b04560dac34178fd36fc8d3d9be816f
3
+ metadata.gz: 02b863a98070f42c77a16db7816f22bc1cf8a82849c0d29a9feb1f4e29193583
4
+ data.tar.gz: b4814318af70abff9d9c26c3e8ff4851f209e9eec8cbd5ef1b9ad22834bf7f17
5
5
  SHA512:
6
- metadata.gz: e39ca6d9855d58bec50f06c696bb9eb2a738e5d99585b1ddfc92fa78bbcacfd24b26385d6f63f3e85e5702713681ffac543881693c3bdf7f97b09f8faad2a5cb
7
- data.tar.gz: 3467307e94de12974464484fa398f0a57f075bbe06c9cbfdddb804449f01db203c4ec9081b6786fc35ed2ace9bf27371039035946c408c73ab18177a7d37794e
6
+ metadata.gz: 219cafb0f2cf6fb87c8f7e5020e04f4c2ca67e678c7adcd6ea494197957a9d979eff3aee059e12afae5d27fb02d41e35926f28ec05bd986631e18bfa29c096fa
7
+ data.tar.gz: 240af4386462413ba3a062f9e654d1b18ed5609849d1dbf510553a9ca98b0222104018266a3dfeb4fefe6740be7f462a129037d47d70eb35cd2c740bb31c8cb7
data/.versions.conf ADDED
@@ -0,0 +1,2 @@
1
+ ruby=2.4
2
+ ruby-gemset=dev_dock
data/Gemfile CHANGED
@@ -6,3 +6,5 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
6
  gemspec
7
7
 
8
8
  gem "docker-api", "~> 1.34"
9
+
10
+ gem "byebug", "~> 10.0", :groups => [:development, :test]
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dev_dock (0.2.0)
4
+ dev_dock (0.2.1)
5
5
  docker-api (~> 1.34)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ byebug (10.0.2)
10
11
  diff-lcs (1.3)
11
12
  docker-api (1.34.2)
12
13
  excon (>= 0.47.0)
@@ -33,6 +34,7 @@ PLATFORMS
33
34
 
34
35
  DEPENDENCIES
35
36
  bundler (~> 1.16)
37
+ byebug (~> 10.0)
36
38
  dev_dock!
37
39
  docker-api (~> 1.34)
38
40
  rake (~> 10.0)
data/help.txt CHANGED
@@ -2,7 +2,7 @@ dev_dock <subcommand> [options...] <image>
2
2
 
3
3
  subcommands:
4
4
 
5
- start <image>
5
+ start [options..] <image> [command..]
6
6
  Start a development session.
7
7
 
8
8
  options:
@@ -61,7 +61,7 @@ module DevDock
61
61
  end
62
62
  end
63
63
 
64
- def run
64
+ def run_arguments
65
65
  arguments = [
66
66
  'docker',
67
67
  'run',
@@ -101,10 +101,13 @@ module DevDock
101
101
 
102
102
  arguments.push @image.name
103
103
 
104
- arguments.push 'tmux'
105
- arguments.push 'new'
104
+ arguments.push *@options.run_command
105
+
106
+ arguments
107
+ end
106
108
 
107
- exec *arguments
109
+ def run
110
+ exec *run_arguments
108
111
  end
109
112
  end
110
113
  end
@@ -1,5 +1,10 @@
1
+ require 'optparse'
2
+
1
3
  module DevDock
2
4
 
5
+ # Handles parsing options with the following syntax:
6
+ # dev_dock subcommand [options..] image [command..]
7
+
3
8
  class Options
4
9
 
5
10
  def initialize(argv)
@@ -7,76 +12,75 @@ module DevDock
7
12
  @environment = []
8
13
  @subcommand = nil
9
14
  @error = nil
15
+ @image_name = nil
10
16
  @argv = argv
17
+ @run_command = ['tmux', 'new']
11
18
  end
12
19
 
13
20
  def parse
14
- parse_subcommand @argv[0]
21
+ parse_subcommand
22
+
15
23
  if not @error
16
24
  if @subcommand == "start"
17
- parse_options @argv.slice(1, @argv.length)
18
- end
19
- if not @error
20
- @image_name = @argv.last
25
+ parse_start
26
+ else
27
+ parse_end
21
28
  end
22
29
  end
30
+
23
31
  end
24
32
 
25
- def parse_subcommand(arg)
26
- if arg == 'start' or arg == 's'
27
- @subcommand = 'start'
28
- elsif arg == 'purge' or arg == 'p'
29
- @subcommand = 'purge'
33
+ def parse_end
34
+ if @argv.length != 2
35
+ @error = 'Invalid number of arguments'
30
36
  else
31
- @error = "Invalid subcommand #{arg}"
37
+ @image_name = @argv[1]
32
38
  end
33
39
  end
34
40
 
35
- def parse_options(argv)
36
- i = 0
37
- while argv[i + 1]
38
- arg = argv[i]
39
- if arg == '--volume' or arg == '-v'
40
- @volumes.push argv[i + 1]
41
- i += 1
42
- elsif arg == '--env' or arg == '-e'
43
- if not argv[i + 2] or not argv[i + 1]
44
- @error = "Invalid use of option #{arg}"
45
- break
46
- else
47
- @environment.push argv[i + 1]
48
- i += 1
49
- end
41
+ def parse_start
42
+ parser = OptionParser.new 'Usage: dev_dock start [options..] image [command..]'
43
+
44
+ parser.on('-e', '--env ENVIRONMENT') do |env|
45
+ self.environment.push(env)
46
+ end
47
+ parser.on('-v', '--volume VOLUME') do |volume|
48
+ self.volumes.push(volume)
49
+ end
50
+ argv = @argv.slice(1, @argv.length - 1)
51
+ begin
52
+ parser.parse!(argv)
53
+ rescue OptionParser::ParseError => err
54
+ @error = err.reason
55
+ end
56
+
57
+ if not @error
58
+ if argv.length == 0
59
+ @error = 'Missing argument: image'
50
60
  else
51
- @error = "Invalid option: #{arg}"
52
- break
61
+ @image_name = argv.shift()
62
+ if argv.length > 0
63
+ @run_command = argv
64
+ end
53
65
  end
54
- i += 1
55
66
  end
56
67
  end
57
68
 
58
- def subcommand
59
- @subcommand
60
- end
61
-
62
- def error
63
- @error
64
- end
65
-
66
- def volumes
67
- @volumes
68
- end
69
-
70
- def image_name
71
- @image_name
69
+ def parse_subcommand
70
+ arg = @argv[0]
71
+ if arg == 'start' or arg == 's'
72
+ @subcommand = 'start'
73
+ elsif arg == 'purge' or arg == 'p'
74
+ @subcommand = 'purge'
75
+ else
76
+ @error = "Invalid subcommand #{arg}"
77
+ end
72
78
  end
73
79
 
74
- def environment
75
- @environment
76
- end
80
+ attr_reader :run_command, :subcommand, :error, :volumes, :image_name, :environment
77
81
 
78
82
  def inspect
79
- "Subcommand: #{@subcommand}, Image: #{@image_name}, Volumes: #{volumes}, Environment: "
83
+ "Subcommand: #{@subcommand}, Image: #{@image_name}, Volumes: #{@volumes}, Environment: #{@environment}, Run Command: #{@run_command}"
80
84
  end
81
85
 
82
86
  end
@@ -1,3 +1,3 @@
1
1
  module DevDock
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_dock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AGhost-7
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2018-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - ".rspec"
79
79
  - ".ruby-gemset"
80
80
  - ".travis.yml"
81
+ - ".versions.conf"
81
82
  - Gemfile
82
83
  - Gemfile.lock
83
84
  - LICENSE.txt