maitre_d 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +12 -0
- data/HISTORY +2 -0
- data/LICENCE +20 -0
- data/README.textile +15 -0
- data/Rakefile +1 -0
- data/config/routes.rb +3 -0
- data/config.ru +7 -0
- data/lib/maitre_d/engine.rb +3 -0
- data/lib/maitre_d/opperator/api.rb +25 -0
- data/lib/maitre_d/opperator/api_helpers.rb +11 -0
- data/lib/maitre_d/opperator.rb +19 -0
- data/lib/maitre_d/version.rb +3 -0
- data/lib/maitre_d.rb +9 -0
- data/maitre_d.gemspec +23 -0
- data/spec/api/opperator/provisioning_spec.rb +55 -0
- data/spec/internal/config/initializers/opperator.rb +1 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/spec/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +13 -0
- metadata +96 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'combustion',
|
4
|
+
:git => 'git://github.com/freelancing-god/combustion',
|
5
|
+
:ref => 'd7a6836269a8fb528bc3721e9b8c06b5a62ef3cc'
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
# Until a new Grape release is out:
|
10
|
+
gem 'grape',
|
11
|
+
:git => 'git://github.com/intridea/grape.git',
|
12
|
+
:ref => '212c96cdfb253a59bc93790808c568e559d04468'
|
data/HISTORY
ADDED
data/LICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Pat Allan
|
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.textile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
h1. Maître d'
|
2
|
+
|
3
|
+
Rack APIs powered by Grape for managing Heroku and Opperator add-ons. If used within a Rails application, it'll automatically be mounted as a Rails engine at the appropriate paths.
|
4
|
+
|
5
|
+
h2. Contributing
|
6
|
+
|
7
|
+
Contributions are very much welcome - but keep in mind the following:
|
8
|
+
|
9
|
+
* Keep patches in a separate branch.
|
10
|
+
* Write tests for your patches.
|
11
|
+
* Don't mess with the version or history file. I'll take care of that when the patch is merged in.
|
12
|
+
|
13
|
+
h2. Credits
|
14
|
+
|
15
|
+
Copyright (c) 2011, Maître d' is developed and maintained by Pat Allan, and is released under the open MIT Licence.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/config/routes.rb
ADDED
data/config.ru
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class MaitreD::Opperator::API < Grape::API
|
2
|
+
helpers MaitreD::Opperator::APIHelpers
|
3
|
+
|
4
|
+
before { authenticate! }
|
5
|
+
|
6
|
+
resources :instances do
|
7
|
+
post do
|
8
|
+
MaitreD::Opperator.subscribe params[:features]
|
9
|
+
end
|
10
|
+
|
11
|
+
delete ':id' do
|
12
|
+
# MaitreD::Opperator.cancel params[:id]
|
13
|
+
end
|
14
|
+
|
15
|
+
put ':id' do
|
16
|
+
# MaitreD::Opperator.update params[:id], params[:features]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
resource :plan_warning do
|
21
|
+
put ':id' do
|
22
|
+
#
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MaitreD::Opperator
|
2
|
+
def self.shared_secret
|
3
|
+
@shared_secret
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.shared_secret=(secret)
|
7
|
+
@shared_secret = secret
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.subscribe(features = {})
|
11
|
+
{
|
12
|
+
'id' => '321',
|
13
|
+
'config' => {}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'maitre_d/opperator/api_helpers'
|
19
|
+
require 'maitre_d/opperator/api'
|
data/lib/maitre_d.rb
ADDED
data/maitre_d.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "maitre_d/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'maitre_d'
|
7
|
+
s.version = MaitreD::VERSION
|
8
|
+
s.authors = ['Pat Allan']
|
9
|
+
s.email = ['pat@freelancing-gods.com']
|
10
|
+
s.homepage = 'http://github.com/flying-sphinx/maitre_d'
|
11
|
+
s.summary = 'Rack API and Rails Engine for Heroku and Opperator add-ons'
|
12
|
+
s.description = 'A Rack API (through Grape) for Heroku and Opperator add-on providers - which can also be attached as a Rails Engine.'
|
13
|
+
|
14
|
+
s.rubyforge_project = "maitre_d"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
s.add_development_dependency 'rails', '3.1.3'
|
22
|
+
s.add_development_dependency 'rspec-rails', '2.7.0'
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Opperator Provisioning API' do
|
4
|
+
let(:json_response) { JSON.parse response.body }
|
5
|
+
|
6
|
+
describe 'Subscription' do
|
7
|
+
it "returns a 401 status if the secret does not match" do
|
8
|
+
post '/opperator/instances', {'features' => {}},
|
9
|
+
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
10
|
+
|
11
|
+
response.status.should == 401
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns the instance id" do
|
15
|
+
post '/opperator/instances', {'features' => {}},
|
16
|
+
{'X-Opperator-Shared-Secret' => 'something-special'}
|
17
|
+
|
18
|
+
json_response['id'].should == '321'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns a hash of options" do
|
22
|
+
post '/opperator/instances', {'features' => {}},
|
23
|
+
{'X-Opperator-Shared-Secret' => 'something-special'}
|
24
|
+
|
25
|
+
json_response['config'].should be_a(Hash)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'Cancellation' do
|
30
|
+
it "returns a 401 status if the secret does not match" do
|
31
|
+
delete '/opperator/instances/323', {},
|
32
|
+
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
33
|
+
|
34
|
+
response.status.should == 401
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'Modification' do
|
39
|
+
it "returns a 401 status if the secret does not match" do
|
40
|
+
put '/opperator/instances/323', {'features' => {}},
|
41
|
+
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
42
|
+
|
43
|
+
response.status.should == 401
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'Warning' do
|
48
|
+
it "returns a 401 status if the secret does not match" do
|
49
|
+
put '/opperator/plan_warning/323', {},
|
50
|
+
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
51
|
+
|
52
|
+
response.status.should == 401
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
MaitreD::Opperator.shared_secret = 'something-special'
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.require :default, :development
|
5
|
+
|
6
|
+
Combustion.initialize! :action_controller
|
7
|
+
|
8
|
+
require 'rspec/rails'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include RSpec::Rails::RequestExampleGroup, :type => :request,
|
12
|
+
:example_group => {:file_path => /spec\/api/}
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maitre_d
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pat Allan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70351599375300 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.3
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70351599375300
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec-rails
|
27
|
+
requirement: &70351599374160 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.7.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70351599374160
|
36
|
+
description: A Rack API (through Grape) for Heroku and Opperator add-on providers
|
37
|
+
- which can also be attached as a Rails Engine.
|
38
|
+
email:
|
39
|
+
- pat@freelancing-gods.com
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- HISTORY
|
47
|
+
- LICENCE
|
48
|
+
- README.textile
|
49
|
+
- Rakefile
|
50
|
+
- config.ru
|
51
|
+
- config/routes.rb
|
52
|
+
- lib/maitre_d.rb
|
53
|
+
- lib/maitre_d/engine.rb
|
54
|
+
- lib/maitre_d/opperator.rb
|
55
|
+
- lib/maitre_d/opperator/api.rb
|
56
|
+
- lib/maitre_d/opperator/api_helpers.rb
|
57
|
+
- lib/maitre_d/version.rb
|
58
|
+
- maitre_d.gemspec
|
59
|
+
- spec/api/opperator/provisioning_spec.rb
|
60
|
+
- spec/internal/config/initializers/opperator.rb
|
61
|
+
- spec/internal/log/.gitignore
|
62
|
+
- spec/internal/public/favicon.ico
|
63
|
+
- spec/spec/internal/log/test.log
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: http://github.com/flying-sphinx/maitre_d
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project: maitre_d
|
85
|
+
rubygems_version: 1.8.10
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Rack API and Rails Engine for Heroku and Opperator add-ons
|
89
|
+
test_files:
|
90
|
+
- spec/api/opperator/provisioning_spec.rb
|
91
|
+
- spec/internal/config/initializers/opperator.rb
|
92
|
+
- spec/internal/log/.gitignore
|
93
|
+
- spec/internal/public/favicon.ico
|
94
|
+
- spec/spec/internal/log/test.log
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
has_rdoc:
|