beanstalkify 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beanstalkify (0.0.2)
4
+ beanstalkify (0.0.3)
5
5
  aws-sdk
6
6
 
7
7
  GEM
data/bin/beanstalkify CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'optparse'
3
3
  require 'yaml'
4
- require 'beanstalkify/beanstalk'
5
- require 'beanstalkify/application'
4
+ Dir.glob(File.join(File.dirname(__FILE__), "../lib/beanstalkify", "*.rb")).each { |f| require f }
6
5
 
7
6
  options = {}
8
7
  OptionParser.new do |opts|
@@ -18,18 +17,27 @@ OptionParser.new do |opts|
18
17
  opts.on("-s", "--stack [stack]", "Stack to provision (e.g. '64bit Amazon Linux running Node.js')") do |v|
19
18
  options[:stack] = v
20
19
  end
21
- opts.on("-c", "--config [file]", "Configuration overrides for the environment") do |v|
20
+ opts.on("-c", "--config [file]", "Configuration overrides for the environment (optional)") do |v|
22
21
  options[:config] = YAML.load_file(v)
23
22
  end
23
+ opts.on("-o", "--outfile [file]", "File to write YAML environment details for future scripting (optional)") do |v|
24
+ options[:outfile] = v
25
+ end
24
26
  end.parse!
25
27
 
26
28
  required_params = [:credentials, :archive, :environment, :stack]
27
29
  unless (required_params - options.keys).empty?
28
- puts "Example usage: beanstalkify -k credentials.yml -a AppName-version.zip -e AppName-test -s '64bit Amazon Linux running Node.js' -c config.yml"
30
+ puts "Example usage: beanstalkify -k credentials.yml -a AppName-version.zip -e AppName-test -s '64bit Amazon Linux running Node.js' [-c config.yml] [-o info.yml]"
29
31
  exit
30
32
  end
31
33
 
32
34
  Beanstalkify::Beanstalk.configure! options[:credentials]
35
+
33
36
  app = Beanstalkify::Application.new(options[:stack], options[:config] || [])
34
- app.deploy!(options[:archive], options[:environment])
37
+ deployment = Beanstalkify::Deploy.new(options[:archive])
38
+ environment = Beanstalkify::Environment.new(options[:environment])
39
+
40
+ deployment_info = app.deploy! deployment, environment
41
+
42
+ File.open(options[:outfile], 'w') { |f| f.puts deployment_info.to_yaml } if options[:outfile]
35
43
 
@@ -1,6 +1,3 @@
1
- require 'beanstalkify/environment'
2
- require 'beanstalkify/deploy'
3
-
4
1
  module Beanstalkify
5
2
  class Application
6
3
  attr_accessor :stack, :config
@@ -14,25 +11,24 @@ module Beanstalkify
14
11
 
15
12
  # Deploy an archive to an environment.
16
13
  # If the environment doesn't exist, it will be created.
17
- def deploy!(archive, environment_name)
18
- deployment = Deploy.new(archive)
19
- env = Environment.new(environment_name)
14
+ def deploy!(deployment, env)
20
15
  if deployment.deployed?
21
- puts "#{deployment.application.version} is already uploaded."
16
+ puts "#{deployment.archive.version} is already uploaded."
22
17
  else
23
18
  deployment.upload!
24
19
  deployment.wait!
25
20
  end
26
21
  if env.status.empty?
27
- puts "Creating stack '#{@stack}' for #{deployment.application.name}-#{deployment.application.version}..."
28
- env.create!(deployment.application, @stack, @config)
22
+ puts "Creating stack '#{@stack}' for #{deployment.archive.name}-#{deployment.archive.version}..."
23
+ env.create!(deployment.archive, @stack, @config)
29
24
  env.wait!("Launching")
30
25
  else
31
- puts "Deploying #{deployment.application.version} to #{environment_name}..."
32
- env.deploy!(deployment.application, @config)
26
+ puts "Deploying #{deployment.archive.version} to #{env.name}..."
27
+ env.deploy!(deployment.archive, @config)
33
28
  env.wait!("Updating")
34
29
  end
35
30
  puts "Done. Visit http://#{env.url} in your browser."
31
+ DeploymentInfo.new env, deployment.archive
36
32
  end
37
33
  end
38
34
  end
@@ -4,10 +4,10 @@ require 'aws-sdk'
4
4
 
5
5
  module Beanstalkify
6
6
  class Deploy
7
- attr_accessor :beanstalk, :application
7
+ attr_accessor :beanstalk, :archive
8
8
 
9
9
  def initialize(path)
10
- @application = Archive.new(path)
10
+ @archive = Archive.new(path)
11
11
  @beanstalk = Beanstalk.api
12
12
  end
13
13
 
@@ -18,15 +18,15 @@ module Beanstalkify
18
18
  def upload!
19
19
  client = AWS::S3.new.client
20
20
  bucket = self.bucket
21
- puts "Uploading #{@application.filename} to bucket #{bucket}..."
22
- client.put_object({ :bucket_name => bucket, :key => @application.filename, :data => File.open(@application.path) })
23
- puts "Creating #{@application.name} - #{@application.version} in beanstalk"
21
+ puts "Uploading #{@archive.filename} to bucket #{bucket}..."
22
+ client.put_object({ :bucket_name => bucket, :key => @archive.filename, :data => File.open(@archive.path) })
23
+ puts "Creating #{@archive.name} - #{@archive.version} in beanstalk"
24
24
  @beanstalk.create_application_version({
25
- :application_name => @application.name,
26
- :version_label => @application.version,
25
+ :application_name => @archive.name,
26
+ :version_label => @archive.version,
27
27
  :source_bundle => {
28
28
  :s3_bucket => bucket,
29
- :s3_key => @application.filename
29
+ :s3_key => @archive.filename
30
30
  },
31
31
  :auto_create_application => true
32
32
  })
@@ -34,14 +34,14 @@ module Beanstalkify
34
34
 
35
35
  def deployed?
36
36
  @beanstalk.describe_application_versions({
37
- :application_name => @application.name,
38
- :version_labels => [@application.version]
37
+ :application_name => @archive.name,
38
+ :version_labels => [@archive.version]
39
39
  }).data[:application_versions].count > 0
40
40
  end
41
41
 
42
42
  def wait!
43
43
  while not self.deployed?
44
- puts "Waiting for #{@application.version} to be available..."
44
+ puts "Waiting for #{@archive.version} to be available..."
45
45
  sleep 10
46
46
  end
47
47
  end
@@ -0,0 +1,16 @@
1
+ module Beanstalkify
2
+ class DeploymentInfo
3
+ def initialize(environment, archive)
4
+ @environment, @archive = environment, archive
5
+ end
6
+
7
+ def to_yaml
8
+ {
9
+ 'app_name' => @archive.name,
10
+ 'app_version' => @archive.version,
11
+ 'env_name' => @environment.name,
12
+ 'env_url' => @environment.url
13
+ }.to_yaml
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Beanstalkify
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require './lib/beanstalkify/deployment_info'
2
+ require './lib/beanstalkify/archive'
3
+
4
+ describe Beanstalkify::DeploymentInfo do
5
+ before(:each) do
6
+ environment = double(name: 'TestEnv', url: 'http://env.url')
7
+ archive = Beanstalkify::Archive.new('test-website-1.0.1.zip')
8
+ @info = Beanstalkify::DeploymentInfo.new(environment, archive)
9
+ end
10
+
11
+ it 'dumps useful info to a YAML string' do
12
+ expected = {
13
+ 'app_name' => 'test-website',
14
+ 'app_version' => '1.0.1',
15
+ 'env_name' => 'TestEnv',
16
+ 'env_url' => 'http://env.url'
17
+ }
18
+ @info.to_yaml.should == expected.to_yaml
19
+ end
20
+ end
21
+
metadata CHANGED
@@ -1,55 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: beanstalkify
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Pranav Raja
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2013-08-05 00:00:00 +10:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :runtime
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- segments:
27
- - 0
28
- version: "0"
12
+ date: 2013-08-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
29
15
  name: aws-sdk
30
- requirement: *id001
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
31
23
  prerelease: false
32
- - !ruby/object:Gem::Dependency
33
- type: :development
34
- version_requirements: &id002 !ruby/object:Gem::Requirement
35
- requirements:
36
- - - ">="
37
- - !ruby/object:Gem::Version
38
- segments:
39
- - 0
40
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
41
31
  name: rspec
42
- requirement: *id002
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
43
39
  prerelease: false
44
- description: Create Amazon Elastic Beanstalk apps and deploy versions from the command line
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Create Amazon Elastic Beanstalk apps and deploy versions from the command
47
+ line
45
48
  email: rickdangerous1@gmail.com
46
- executables:
49
+ executables:
47
50
  - beanstalkify
48
51
  extensions: []
49
-
50
52
  extra_rdoc_files: []
51
-
52
- files:
53
+ files:
53
54
  - .gitignore
54
55
  - Gemfile
55
56
  - Gemfile.lock
@@ -62,38 +63,36 @@ files:
62
63
  - lib/beanstalkify/archive.rb
63
64
  - lib/beanstalkify/beanstalk.rb
64
65
  - lib/beanstalkify/deploy.rb
66
+ - lib/beanstalkify/deployment_info.rb
65
67
  - lib/beanstalkify/environment.rb
66
68
  - lib/beanstalkify/version.rb
67
69
  - test/archive_spec.rb
68
- has_rdoc: true
70
+ - test/deployment_info_spec.rb
69
71
  homepage: https://github.com/pranavraja/beanstalkify
70
- licenses:
72
+ licenses:
71
73
  - MIT
72
74
  post_install_message:
73
75
  rdoc_options: []
74
-
75
- require_paths:
76
+ require_paths:
76
77
  - lib
77
- required_ruby_version: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- segments:
82
- - 0
83
- version: "0"
84
- required_rubygems_version: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- segments:
89
- - 0
90
- version: "0"
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
91
90
  requirements: []
92
-
93
91
  rubyforge_project:
94
- rubygems_version: 1.3.6
92
+ rubygems_version: 1.8.24
95
93
  signing_key:
96
94
  specification_version: 3
97
95
  summary: Beanstalk automation for dummies
98
- test_files:
96
+ test_files:
99
97
  - test/archive_spec.rb
98
+ - test/deployment_info_spec.rb