beanstalkapp 1.1.0

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/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,36 @@
1
+ = Beanstalk API Wrapper
2
+
3
+ Official Ruby gem for accessing Beanstalk RESTful API. Basically a set of pre-written ActiveResource classes with a few adjustments.
4
+
5
+ http://api.beanstalkapp.com
6
+
7
+ == Installation
8
+
9
+ gem install beanstalkapp
10
+
11
+ == Requirements
12
+
13
+ ActiveResource 2.3.5
14
+
15
+ == Usage
16
+
17
+ First enable API access in your Beanstalk account by going to Account > Setup. Only the account owner can do that.
18
+
19
+ Then in your code setup the API like that:
20
+
21
+ Beanstalk::API::Base.setup(
22
+ :domain => 'your_beanstalk_subdomain',
23
+ :login => 'login',
24
+ :password => '12345'
25
+ )
26
+
27
+ Then you can start using the API:
28
+
29
+ Beanstalk::API::Account.find
30
+
31
+ For information about all API methods please go to the official documentation site:
32
+
33
+ http://api.beanstalkapp.com
34
+
35
+ Copyright (c) 2010 Ilya Sabanin, Wildbit.
36
+ Released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "beanstalkapp"
8
+ gem.summary = "Official wrapper for Beanstalk API."
9
+ gem.email = "ilya.sabanin@gmail.com"
10
+ gem.homepage = "http://api.beanstalkapp.com"
11
+ gem.authors = ["Ilya Sabanin"]
12
+ gem.add_dependency('activeresource', '= 2.3.5')
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ task :test => :check_dependencies
27
+
28
+ task :default => :test
29
+
30
+ require 'rake/rdoctask'
31
+ Rake::RDocTask.new do |rdoc|
32
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
33
+
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "pretty_diff #{version}"
36
+ rdoc.rdoc_files.include('README*')
37
+ rdoc.rdoc_files.include('lib/**/*.rb')
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{beanstalkapp}
8
+ s.version = "1.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ilya Sabanin"]
12
+ s.date = %q{2010-01-20}
13
+ s.email = %q{ilya.sabanin@gmail.com}
14
+ s.extra_rdoc_files = [
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "MIT-LICENSE",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "beanstalkapp.gemspec",
24
+ "lib/beanstalkapp.rb",
25
+ "lib/beanstalkapp/account.rb",
26
+ "lib/beanstalkapp/base.rb",
27
+ "lib/beanstalkapp/changeset.rb",
28
+ "lib/beanstalkapp/comment.rb",
29
+ "lib/beanstalkapp/release.rb",
30
+ "lib/beanstalkapp/release_server.rb",
31
+ "lib/beanstalkapp/repository.rb",
32
+ "lib/beanstalkapp/user.rb"
33
+ ]
34
+ s.homepage = %q{http://api.beanstalkapp.com}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.5}
38
+ s.summary = %q{Official wrapper for Beanstalk API.}
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<activeresource>, ["= 2.3.5"])
46
+ else
47
+ s.add_dependency(%q<activeresource>, ["= 2.3.5"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<activeresource>, ["= 2.3.5"])
51
+ end
52
+ end
53
+
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'active_resource'
3
+
4
+ module Beanstalk
5
+ module API
6
+ end
7
+ end
8
+
9
+ require 'beanstalkapp/base'
10
+ require 'beanstalkapp/account'
11
+ require 'beanstalkapp/changeset'
12
+ require 'beanstalkapp/repository'
13
+ require 'beanstalkapp/comment'
14
+ require 'beanstalkapp/release'
15
+ require 'beanstalkapp/release_server'
16
+ require 'beanstalkapp/user'
@@ -0,0 +1,12 @@
1
+ module Beanstalk::API
2
+ class Account < Base
3
+
4
+ # ActiveResource 2.3.2 doesn't support singular resources
5
+ # this hack make it work.
6
+ def self.element_path(id=nil, prefix_options={}, query_options=nil)
7
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
8
+ "#{prefix(prefix_options)}account.#{format.extension}#{query_string(query_options)}"
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ module Beanstalk
2
+ module API
3
+ class Base < ActiveResource::Base
4
+ def self.setup(options)
5
+ self.site = "http://#{options[:domain]}.beanstalkapp.com/api"
6
+ self.user = options[:login]
7
+ self.password = options[:password]
8
+ end
9
+
10
+ def self.add_prefix(str)
11
+ str.gsub!(/^\//, '')
12
+ class_eval(<<-CODE)
13
+ def self.site
14
+ URI.parse(Beanstalk::API::Base.site.to_s + "/#{str}")
15
+ end
16
+ CODE
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ module Beanstalk::API
2
+ class Changeset < Base
3
+
4
+ def self.find_all_for_repository(repo_id)
5
+ get :repository, :repository_id => repo_id
6
+ end
7
+
8
+ def self.find_for_repository(id, repo_id)
9
+ find id, :params => { :repository_id => repo_id }
10
+ end
11
+
12
+ # ActiveResource 2.3.2 doesn't support loading of nested arrays and symbols
13
+ # we submitted a patch to the Rails Core but it's not committed yet
14
+ # https://rails.lighthouseapp.com/projects/8994/tickets/2394-support-for-loading-nested-arrays-in-activeresource
15
+
16
+ def load(attributes)
17
+ raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
18
+ @prefix_options, attributes = split_options(attributes)
19
+ attributes.each do |key, value|
20
+ @attributes[key.to_s] = typecast_attribute_value(key, value)
21
+ end
22
+ self
23
+ end
24
+
25
+ private
26
+
27
+ def typecast_attribute_value(attribute, value)
28
+ case value
29
+ when Array
30
+ resource = find_or_create_resource_for_collection(attribute)
31
+ value.map do |attrs|
32
+ if attrs.is_a?(Symbol) || attrs.kind_of?(Numeric)
33
+ attrs
34
+ elsif attrs.is_a?(String)
35
+ attrs.dup
36
+ elsif attrs.is_a?(Array)
37
+ typecast_attribute_value(attribute, attrs)
38
+ else
39
+ resource.new(attrs)
40
+ end
41
+ end
42
+ when Hash
43
+ resource = find_or_create_resource_for(attribute)
44
+ resource.new(value)
45
+ else
46
+ value.dup rescue value
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ module Beanstalk::API
2
+ class Comment < Base
3
+ add_prefix ':repository_id'
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module Beanstalk::API
2
+ class Release < Base
3
+
4
+ def find_all_for_repository(repo_id)
5
+ find :all, :params => { :repository_id => repo_id }
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Beanstalk::API
2
+ class ReleaseServer < Base
3
+ add_prefix ':repository_id'
4
+
5
+ def find_all_for_repository(repo_id)
6
+ find :all, :params => { :repository_id => repo_id }
7
+ end
8
+
9
+ def find_for_repository(name, repo_id)
10
+ find name, :params => { :repository_id => repo_id }
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Beanstalk::API
2
+ class Repository < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Beanstalk::API
2
+ class User < Base
3
+ end
4
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beanstalkapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ilya Sabanin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-20 00:00:00 +07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activeresource
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.5
24
+ version:
25
+ description:
26
+ email: ilya.sabanin@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - .gitignore
35
+ - MIT-LICENSE
36
+ - README.rdoc
37
+ - Rakefile
38
+ - VERSION
39
+ - beanstalkapp.gemspec
40
+ - lib/beanstalkapp.rb
41
+ - lib/beanstalkapp/account.rb
42
+ - lib/beanstalkapp/base.rb
43
+ - lib/beanstalkapp/changeset.rb
44
+ - lib/beanstalkapp/comment.rb
45
+ - lib/beanstalkapp/release.rb
46
+ - lib/beanstalkapp/release_server.rb
47
+ - lib/beanstalkapp/repository.rb
48
+ - lib/beanstalkapp/user.rb
49
+ has_rdoc: true
50
+ homepage: http://api.beanstalkapp.com
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --charset=UTF-8
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.5
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Official wrapper for Beanstalk API.
77
+ test_files: []
78
+