vagrant-sptsync 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDc3ZWZhMmRkNjdmYWNmZWE1NDc1YzZhNGUzOWY3NGE0YzYxZDIyNg==
4
+ OTA4NjJkODI3NjY1NmJhYzVhOWY2NTk0MTRjYjdmZWUwMGJiZDY1MQ==
5
5
  data.tar.gz: !binary |-
6
- MjRiNjMwOTAyYTQ1NzFkODUxMjcxYWZkYzY2M2U0MDc2OGI3NWUxZA==
6
+ NDI3NDg4YTY3ZWY1MWEyZTJjNGQ2ZmY5ODQwM2M1NzljMjk0MDJhMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmY3YzY3MDMzOTBlYmM1YTIyMjliYzMzMmE2ZTdiNGQ1NjRkNmVkZDdlNTY5
10
- MWJmYmRkYzQ3MTA2ZGMwMGRiY2U5MWE4NmQ1NDU4YjkwNGM4ZjQ1MjM4M2Ew
11
- MTUyZGM4MmJkYmZiMzc1NTI5Y2FjNmM1NzUwN2EyYjNmYzExZWQ=
9
+ OGRlMTNmNDEwM2E3MzIyMTY4OTY0ZjIwYzFkZDMzMTdjMDY1MDg3NTAyNWQ2
10
+ OWRiZjcxOTk4YTQyZTEyYjNiMjQzMWFlMWI3OTBiMzFhODA5YzAxZmE3YWRh
11
+ MThiMzZlZTQ3Zjc1MTYwOTJkNTQ0N2I4OWUzMTA1ZTE0NDE5YzU=
12
12
  data.tar.gz: !binary |-
13
- ZWUzNGY5OWE5MzE4MmE5OTc1ZjJhOTRjZjU5NGFjOThhMGVlYzM1MDRmMjM3
14
- NzYxNTU2NjNkY2YxNjcyODEyMTBkZGZiZDJlMTQxN2NkYjQyMmRmYmEyNDkx
15
- NTJkYjYzNTY5YTY0MjVkOTI1MmM0NGYzNWE2NjM3MzE3NWM3NGQ=
13
+ MDE2NGI0NmY0Y2EzNGRmZDg2YWQxYWI1OThkYzJlYzE2MTVhMmYyMjY2ODY3
14
+ ZjZkNjJhNDY0MGViOGQ5MDRmN2E4NzY0MDc0MDgyZGJhOTYxMTdiZTBiOWM0
15
+ ZTFmNmE0MGJhNjFlNmJiZWJhZWZhNDgwOTNlNjY1ZjFhYTZhNTc=
@@ -1,8 +1,43 @@
1
+ require 'optparse'
2
+
1
3
  module VagrantPlugins
2
4
  module SPTSync
3
5
  module Command
4
6
  class Root < Vagrant.plugin(2, :command)
5
- # def initialize(argv, env)
7
+ def initialize(argv, env)
8
+ @options = {
9
+ :server => "dev",
10
+ :site => "share"
11
+ }
12
+
13
+ @opts = OptionParser.new do |opts|
14
+ opts.banner = "Sync site to your local"
15
+ opts.separator ""
16
+ opts.separator "Usage: vagrant sptsync"
17
+
18
+ opts.on("-e", "--server", "Specifies the server to pulldown from. Defaults to dev") do |server|
19
+ @options[:server] = server
20
+ end
21
+
22
+ opts.on("-s", "--site", "Specifies the site to pulldown. Defaults to share") do |site|
23
+ @options[:site] = site
24
+ end
25
+ end
26
+
27
+ @servers = ['dev', 'qa', 'stage']
28
+
29
+ # options = {}
30
+ # OptionParser.new do |opts|
31
+ # opts.banner = "Usage: example.rb [options]"
32
+
33
+ # opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
34
+ # options[:verbose] = v
35
+ # end
36
+ # end.parse!
37
+
38
+ # p options
39
+ # p argv
40
+
6
41
  # super
7
42
 
8
43
  # @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
@@ -28,9 +63,10 @@ module VagrantPlugins
28
63
  # require_relative('delete')
29
64
  # Delete
30
65
  # end
31
- # end
66
+ end
32
67
 
33
68
  def execute
69
+ validate
34
70
  # if @main_args.include?("-h") || @main_args.include?("--help")
35
71
  # # Print the help for all the box commands.
36
72
  # return help
@@ -47,7 +83,7 @@ module VagrantPlugins
47
83
  with_target_vms(nil, single_target: true) do |vm|
48
84
  vm.config.exec.finalize! # TODO: do we have to call it explicitly?
49
85
 
50
- command = "drush @share status"
86
+ command = "drush @#{options[:site]} status"
51
87
 
52
88
  ssh_opts = { extra_args: ['-v'] } # make it quiet
53
89
 
@@ -59,28 +95,23 @@ module VagrantPlugins
59
95
  end
60
96
  end
61
97
 
62
- # Prints the help out for this command
63
- # def help
64
- # opts = OptionParser.new do |opts|
65
- # opts.banner = "Usage: vagrant snapshot <command> [<args>]"
66
- # opts.separator ""
67
- # opts.separator "Available subcommands:"
68
-
69
- # # Add the available subcommands as separators in order to print them
70
- # # out as well.
71
- # keys = []
72
- # @subcommands.each { |key, value| keys << key.to_s }
73
-
74
- # keys.sort.each do |key|
75
- # opts.separator " #{key}"
76
- # end
77
-
78
- # opts.separator ""
79
- # opts.separator "For help on any individual command run `vagrant snapshot <command> -h`"
80
- # end
98
+ def validate
99
+ if !@servers.include? @options[:server]
100
+ puts "#{@options[:server]} is not valid server. Pulling from dev."
101
+ end
81
102
 
82
- # @env.ui.info(opts.help, :prefix => false)
83
- # end
103
+ command = "drush @#{options[:site]} status"
104
+ ssh_opts = { extra_args: ['-q'] } # make it quiet
105
+ env = vm.action(:ssh_run, ssh_run_command: command, ssh_opts: ssh_opts)
106
+ if env[:ssh_run_exit_status] != "0"
107
+ raise SiteError.new(options[:site])
108
+ end
109
+ end
110
+
111
+ # Prints the help out for this command
112
+ def help
113
+ @env.ui.info(@opts.help, :prefix => false)
114
+ end
84
115
 
85
116
  end
86
117
  end
@@ -15,6 +15,14 @@ module VagrantPlugins
15
15
  Command::Root
16
16
  end
17
17
 
18
+ class SiteError < Vagrant::Errors::VagrantError
19
+ error_key "site_error"
20
+
21
+ def initialize(site)
22
+ "#{site} is not a valid site"
23
+ end
24
+ end
25
+
18
26
  end
19
27
  end
20
28
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module SPTSync
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-sptsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Sehr