beanstalkapp 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == 1.2.0
4
+
5
+ * Added support for reworked Beanstalk Deployments. New model added: ServerEnvironment.
6
+
3
7
  == 1.1.3
4
8
 
5
9
  * Added ReleaseServer#toggle_state! method for enabling/disabling Releases servers.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{beanstalkapp}
8
- s.version = "1.1.3"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ilya Sabanin"]
12
- s.date = %q{2010-03-25}
12
+ s.date = %q{2010-08-16}
13
13
  s.email = %q{ilya.sabanin@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
@@ -30,13 +30,18 @@ Gem::Specification.new do |s|
30
30
  "lib/beanstalkapp/release.rb",
31
31
  "lib/beanstalkapp/release_server.rb",
32
32
  "lib/beanstalkapp/repository.rb",
33
- "lib/beanstalkapp/user.rb"
33
+ "lib/beanstalkapp/server_environment.rb",
34
+ "lib/beanstalkapp/user.rb",
35
+ "test/integration.rb"
34
36
  ]
35
37
  s.homepage = %q{http://api.beanstalkapp.com}
36
38
  s.rdoc_options = ["--charset=UTF-8"]
37
39
  s.require_paths = ["lib"]
38
40
  s.rubygems_version = %q{1.3.5}
39
41
  s.summary = %q{Official wrapper for Beanstalk API.}
42
+ s.test_files = [
43
+ "test/integration.rb"
44
+ ]
40
45
 
41
46
  if s.respond_to? :specification_version then
42
47
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -10,6 +10,7 @@ require 'beanstalkapp/account'
10
10
  require 'beanstalkapp/changeset'
11
11
  require 'beanstalkapp/repository'
12
12
  require 'beanstalkapp/comment'
13
+ require 'beanstalkapp/server_environment'
13
14
  require 'beanstalkapp/release'
14
15
  require 'beanstalkapp/release_server'
15
16
  require 'beanstalkapp/user'
@@ -2,7 +2,8 @@ module Beanstalk
2
2
  module API
3
3
  class Base < ActiveResource::Base
4
4
  def self.setup(options)
5
- self.site = "http://#{options[:domain]}.beanstalkapp.com/api"
5
+ options[:host] ||= "beanstalkapp.com"
6
+ self.site = "http://#{options[:domain]}.#{options[:host]}/api"
6
7
  self.user = options[:login]
7
8
  self.password = options[:password]
8
9
  end
@@ -11,7 +12,7 @@ module Beanstalk
11
12
  str.gsub!(/^\//, '')
12
13
  class_eval(<<-CODE)
13
14
  def self.site
14
- URI.parse(Beanstalk::API::Base.site.to_s + "/#{str}")
15
+ URI.parse(File.join(Beanstalk::API::Base.site.to_s, #{str.inspect}))
15
16
  end
16
17
  CODE
17
18
  end
@@ -3,7 +3,11 @@ module Beanstalk::API
3
3
  add_prefix ':repository_id'
4
4
 
5
5
  def self.find_all_for_repository(repo_id)
6
- find :all, :params => { :repository_id => repo_id }
6
+ raise "This method was removed. To lookup Releases use Release#find_all_for_environment method. Sorry."
7
+ end
8
+
9
+ def self.find_all_for_environment(environment_id, repo_id)
10
+ find :all, :params => { :repository_id => repo_id, :environment_id => environment_id }
7
11
  end
8
12
 
9
13
  def self.find_for_repository(id, repo_id)
@@ -3,21 +3,19 @@ module Beanstalk::API
3
3
  add_prefix ':repository_id'
4
4
 
5
5
  def self.find_all_for_repository(repo_id)
6
- find :all, :params => { :repository_id => repo_id }
6
+ raise "This method was removed. To lookup ReleaseServers use ReleaseServer#find_all_for_environment method. Sorry."
7
7
  end
8
8
 
9
- def self.find_for_repository(name, repo_id)
10
- find name, :params => { :repository_id => repo_id }
9
+ def self.find_for_repository(id, repository_id)
10
+ find id, :params => { :repository_id => repository_id }
11
11
  end
12
-
13
- def to_param
14
- name
12
+
13
+ def self.find_all_for_environment(environment_id, repository_id)
14
+ find :all, :params => { :repository_id => repository_id, :environment_id => environment_id }
15
15
  end
16
-
16
+
17
17
  def toggle_state!
18
- repo_id = prefix_options[:repository_id]
19
- path = element_path(:repository_id => repo_id, :id => to_param).gsub(".xml", '/toggle_state.xml')
20
- connection.put(path)
18
+ raise "ReleaseServer#toggle_state! method was removed due to changes in how Beanstalk Deployments work. Sorry"
21
19
  end
22
20
 
23
21
  end
@@ -0,0 +1,14 @@
1
+ module Beanstalk::API
2
+ class ServerEnvironment < Base
3
+ add_prefix ':repository_id'
4
+
5
+ def self.find_all_for_repository(repo_id)
6
+ find :all, :params => { :repository_id => repo_id }
7
+ end
8
+
9
+ def self.find_for_repository(id, repo_id)
10
+ find id, :params => { :repository_id => repo_id }
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,88 @@
1
+ require 'rubygems'
2
+ $: << "lib/"
3
+ require 'lib/beanstalkapp'
4
+
5
+ Beanstalk::API::Base.setup(
6
+ :host => 'beanstalk.local',
7
+ :domain => 'apricode',
8
+ :login => 'railsmonk',
9
+ :password => '123456'
10
+ )
11
+
12
+ def test(code_or_text)
13
+ puts "---- #{code_or_text}"
14
+ if block_given?
15
+ p yield
16
+ else
17
+ p eval(code_or_text)
18
+ end
19
+ puts
20
+ end
21
+
22
+ $repository_id = 15
23
+ $environment_id = 6
24
+ $release_server_id = 7
25
+ $release_id = 57
26
+ $existing_revision = "f99193ed1f3dcdfa7f30632049a944ca4a53c139"
27
+
28
+ test "Beanstalk::API::Account.find"
29
+ test "Beanstalk::API::Repository.find($repository_id)"
30
+ test "Beanstalk::API::Repository.find(:all)"
31
+ test "Beanstalk::API::Release.find_all_for_environment($environment_id, $repository_id)"
32
+ test "Beanstalk::API::Release.find_for_repository($release_id, $repository_id)"
33
+ test "Beanstalk::API::ReleaseServer.find_all_for_environment($environment_id, $repository_id)"
34
+ test "Beanstalk::API::ReleaseServer.find_for_repository($release_server_id, $repository_id)"
35
+ test "Beanstalk::API::ServerEnvironment.find_all_for_repository($repository_id)"
36
+ test "Beanstalk::API::ServerEnvironment.find_for_repository($environment_id, $repository_id)"
37
+
38
+ test "Create ReleaseServer" do
39
+ server = Beanstalk::API::ReleaseServer.new(
40
+ :name => "development",
41
+ :local_path => "/trunk",
42
+ :remote_path => "/var/www/my_site",
43
+ :remote_addr => "myftpserver.com",
44
+ :protocol => "ftp",
45
+ :port => 21,
46
+ :login => "username",
47
+ :password => "topsecret"
48
+ )
49
+ server.prefix_options = { :repository_id => $repository_id, :environment_id => $environment_id}
50
+ server.save
51
+ server
52
+ end
53
+
54
+ test "Update ReleaseServer" do
55
+ server = Beanstalk::API::ReleaseServer.find_for_repository($release_server_id, $repository_id)
56
+ server.prefix_options = { :repository_id => $repository_id }
57
+ server.local_path = "/"
58
+ server.save
59
+ server
60
+ end
61
+
62
+ test "Create ServerEnvironment" do
63
+ env = Beanstalk::API::ServerEnvironment.new(
64
+ :name => "Macaroni",
65
+ :automatic => true,
66
+ :branch_name => "master"
67
+ )
68
+ env.prefix_options = { :repository_id => $repository_id }
69
+ env.save
70
+ env
71
+ end
72
+
73
+ test "Update ServerEnvironment" do
74
+ env = Beanstalk::API::ServerEnvironment.find_for_repository($environment_id, $repository_id)
75
+ env.name = "Mascarpone"
76
+ env.prefix_options = { :repository_id => $repository_id }
77
+ env.save
78
+ env
79
+ end
80
+
81
+ test "Create new Release" do
82
+ r = Beanstalk::API::Release.new
83
+ r.prefix_options = { :repository_id => $repository_id, :environment_id => $environment_id }
84
+ r.release_server_id = $release_server_id
85
+ r.revision = ""
86
+ r.save
87
+ r
88
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beanstalkapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Sabanin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-25 00:00:00 +07:00
12
+ date: 2010-08-16 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,9 @@ files:
46
46
  - lib/beanstalkapp/release.rb
47
47
  - lib/beanstalkapp/release_server.rb
48
48
  - lib/beanstalkapp/repository.rb
49
+ - lib/beanstalkapp/server_environment.rb
49
50
  - lib/beanstalkapp/user.rb
51
+ - test/integration.rb
50
52
  has_rdoc: true
51
53
  homepage: http://api.beanstalkapp.com
52
54
  licenses: []
@@ -75,5 +77,5 @@ rubygems_version: 1.3.5
75
77
  signing_key:
76
78
  specification_version: 3
77
79
  summary: Official wrapper for Beanstalk API.
78
- test_files: []
79
-
80
+ test_files:
81
+ - test/integration.rb