engineyard-serverside-adapter 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
- source :gemcutter
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in engineyard-serverside-adapter.gemspec
4
3
  gemspec
4
+
5
+ group :guard do
6
+ gem 'guard', :require => false
7
+ gem 'guard-rspec', :require => false
8
+ gem 'rb-fsevent', '~> 0.9.1', :require => false
9
+ end
data/Guardfile ADDED
@@ -0,0 +1,13 @@
1
+ guard 'rspec', :all_after_pass => true, :all_on_start => true, :cli => '--color' do
2
+
3
+ lib = "lib/engineyard-serverside-adapter"
4
+
5
+ watch(%r{^spec/(.+)_spec\.rb$})
6
+ watch(%r{^#{lib}.rb$}) { "spec" }
7
+ watch(%r{^#{lib}/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
+ watch(%r{^#{lib}/action.rb$}) { "spec" }
9
+ watch(%r{^#{lib}/command.rb$}) { "spec" }
10
+ watch(%r{^#{lib}/option.rb$}) { "spec" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+
13
+ end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "engineyard-serverside-adapter"
16
16
 
17
17
  s.add_dependency "escape", "~> 0.0.4"
18
- s.add_dependency "json_pure"
18
+ s.add_dependency "multi_json", "~> 1.6"
19
19
  s.add_development_dependency "rspec", "~> 2.0"
20
20
  s.add_development_dependency "rake"
21
21
 
@@ -8,12 +8,20 @@ module EY
8
8
  class Adapter
9
9
  class Action
10
10
 
11
+ GEM_NAME = 'engineyard-serverside'
12
+ BIN_NAME = GEM_NAME
13
+
11
14
  def initialize(options = {}, &block)
12
15
  @gem_bin_path = Pathname.new(options[:gem_bin_path] || "")
13
- @arguments = options[:arguments] || Arguments.new
16
+
17
+ @arguments = options[:arguments] || Arguments.new
18
+ @serverside_gem_name = options[:serverside_gem_name] || GEM_NAME
19
+ @serverside_bin_name = options[:serverside_bin_name] || BIN_NAME
20
+
14
21
  block.call @arguments if block
15
- @serverside_version = @arguments[:serverside_version]
16
- @serverside_version ||= Gem::Version.create(ENGINEYARD_SERVERSIDE_VERSION.dup)
22
+
23
+ @serverside_version = Gem::Version.create(@arguments.serverside_version || ENGINEYARD_SERVERSIDE_VERSION.dup)
24
+
17
25
  validate!
18
26
  end
19
27
 
@@ -46,11 +54,11 @@ module EY
46
54
  end
47
55
 
48
56
  def check_command
49
- escaped_serverside_version = @serverside_version.to_s.gsub(/\./, '\.')
57
+ escaped_serverside_version = Regexp.escape(@serverside_version.to_s)
50
58
 
51
59
  [
52
- Escape.shell_command([gem_path, "list", "engineyard-serverside"]),
53
- Escape.shell_command(["grep", "engineyard-serverside "]),
60
+ Escape.shell_command([gem_command_path, "list", @serverside_gem_name]),
61
+ Escape.shell_command(["grep", "#{@serverside_gem_name} "]), # trailing space for better matching
54
62
  Escape.shell_command(["egrep", "-q", "#{escaped_serverside_version}[,)]"]),
55
63
  ].join(" | ")
56
64
  end
@@ -62,20 +70,24 @@ module EY
62
70
  #
63
71
  # rubygems help suggests that --remote will disable this
64
72
  # behavior, but it doesn't.
65
- install_command = "cd `mktemp -d` && #{gem_path} install engineyard-serverside --no-rdoc --no-ri -v #{@serverside_version}"
73
+ install_command = "cd `mktemp -d` && #{gem_command_path} install #{@serverside_gem_name} --no-rdoc --no-ri -v #{@serverside_version}"
66
74
  Escape.shell_command(['sudo', 'sh', '-c', install_command])
67
75
  end
68
76
 
69
- def gem_path
77
+ def gem_command_path
70
78
  @gem_bin_path.join('gem').to_s
71
79
  end
72
80
 
81
+ def serverside_command_path
82
+ @gem_bin_path.join(@serverside_bin_name).to_s
83
+ end
84
+
73
85
  def action_command
74
- cmd = Command.new(@gem_bin_path, @serverside_version, *task)
75
- applicable_options.each do |option|
76
- cmd.send("#{option.type}_argument", option.to_switch, @arguments[option.name])
86
+ Command.new(serverside_command_path, @serverside_version, *task) do |cmd|
87
+ applicable_options.each do |option|
88
+ cmd.send("#{option.type}_argument", option.to_switch, @arguments[option.name])
89
+ end
77
90
  end
78
- cmd
79
91
  end
80
92
 
81
93
  def validate!
@@ -5,6 +5,10 @@ module EY
5
5
 
6
6
  def self.nonempty_writer(*names)
7
7
  names.each do |name|
8
+ define_method(name) do
9
+ self[name]
10
+ end
11
+
8
12
  define_method(:"#{name}=") do |value|
9
13
  if value.nil? || value.to_s.empty?
10
14
  raise ArgumentError, "Value for '#{name}' must be non-empty."
@@ -16,6 +20,10 @@ module EY
16
20
 
17
21
  def self.writer(*names)
18
22
  names.each do |name|
23
+ define_method(name) do
24
+ self[name]
25
+ end
26
+
19
27
  define_method(:"#{name}=") do |value|
20
28
  self[name] = value
21
29
  end
@@ -63,14 +71,11 @@ module EY
63
71
  self[:instances] = instances
64
72
  end
65
73
 
74
+ # Uses Gem::Version.create to validate the version string
66
75
  def serverside_version=(value)
67
76
  self[:serverside_version] = Gem::Version.create(value.dup) # dup b/c Gem::Version sometimes modifies its argument :(
68
77
  end
69
78
 
70
- def method_missing(meth, *)
71
- key?(meth) ? self[meth] : super
72
- end
73
-
74
79
  end
75
80
  end
76
81
  end
@@ -1,19 +1,21 @@
1
1
  require 'escape'
2
- require 'json'
2
+ require 'multi_json'
3
3
 
4
4
  module EY
5
5
  module Serverside
6
6
  class Adapter
7
7
  class Command
8
- def initialize(bin_path, serverside_version, *task)
9
- @binary = bin_path.join('engineyard-serverside').to_s
10
- @serverside_version = serverside_version
11
- @task = task
8
+ def initialize(binary_path, version, *task)
9
+ @binary = binary_path.to_s
10
+ @version = version
11
+ @task = task
12
12
  @arguments = []
13
+
14
+ yield self if block_given?
13
15
  end
14
16
 
15
17
  def to_s
16
- Escape.shell_command [@binary, "_#{@serverside_version}_"] + @task + @arguments.sort_by { |x| x.first }.flatten
18
+ Escape.shell_command [@binary, "_#{@version}_"] + @task + @arguments.sort_by { |x| x.first }.flatten
17
19
  end
18
20
 
19
21
  def array_argument(switch, values)
@@ -51,7 +53,7 @@ module EY
51
53
 
52
54
  def json_argument(switch, value)
53
55
  if value
54
- string_argument(switch, value.to_json)
56
+ string_argument(switch, MultiJson.dump(value))
55
57
  end
56
58
  end
57
59
 
@@ -1,7 +1,7 @@
1
1
  module EY
2
2
  module Serverside
3
3
  class Adapter
4
- VERSION = "2.0.4"
4
+ VERSION = "2.0.5"
5
5
  # For backwards compatibility, the serverside version default will be maintained until 2.1
6
6
  # It is recommended that you supply a serverside_version to engineyard-serverside-adapter
7
7
  # rather than relying on the default version here. This default will go away soon.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-serverside-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-06 00:00:00.000000000 Z
13
+ date: 2013-03-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: escape
@@ -29,21 +29,21 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: 0.0.4
31
31
  - !ruby/object:Gem::Dependency
32
- name: json_pure
32
+ name: multi_json
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
36
- - - ! '>='
36
+ - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: '0'
38
+ version: '1.6'
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - ! '>='
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '1.6'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +87,7 @@ extra_rdoc_files: []
87
87
  files:
88
88
  - .gitignore
89
89
  - Gemfile
90
+ - Guardfile
90
91
  - LICENSE
91
92
  - README.md
92
93
  - Rakefile
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  segments:
128
129
  - 0
129
- hash: -633305540513114072
130
+ hash: 3338596083708066819
130
131
  required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  none: false
132
133
  requirements: