bbrowning-deltacloud-core 0.0.1.1 → 0.0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +176 -502
- data/Rakefile +21 -14
- data/deltacloud.rb +3 -0
- data/lib/deltacloud/base_driver/base_driver.rb +22 -11
- data/lib/deltacloud/base_driver.rb +12 -11
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +15 -12
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +16 -11
- data/lib/deltacloud/drivers/mock/data/images/img1.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/images/img2.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/images/img3.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +16 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +9 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +9 -0
- data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap1.yml +4 -0
- data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap2.yml +4 -0
- data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap3.yml +4 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +6 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +6 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +6 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +13 -11
- data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +12 -11
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +12 -11
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +12 -11
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +12 -11
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +14 -12
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +12 -11
- data/lib/deltacloud/helpers/application_helper.rb +64 -11
- data/lib/deltacloud/helpers/conversion_helper.rb +12 -11
- data/lib/deltacloud/method_serializer.rb +12 -11
- data/lib/deltacloud/models/base_model.rb +12 -11
- data/lib/deltacloud/models/image.rb +12 -11
- data/lib/deltacloud/models/instance.rb +13 -12
- data/lib/deltacloud/models/instance_profile.rb +12 -11
- data/lib/deltacloud/models/realm.rb +12 -11
- data/lib/deltacloud/models/storage_snapshot.rb +12 -11
- data/lib/deltacloud/models/storage_volume.rb +12 -11
- data/lib/drivers.rb +12 -0
- data/lib/sinatra/rabbit.rb +1 -0
- data/lib/sinatra/respond_to.rb +3 -0
- data/lib/sinatra/url_for.rb +3 -4
- data/server.rb +40 -80
- data/{torquebox-ec2-config.ru → support/torquebox/torquebox-ec2-config.ru} +0 -0
- data/tests/api_test.rb +37 -0
- data/tests/hardware_profiles_test.rb +120 -0
- data/tests/images_test.rb +95 -78
- data/tests/instance_states_test.rb +52 -0
- data/tests/instances_test.rb +193 -110
- data/tests/realms_test.rb +66 -44
- data/views/errors/not_found.html.haml +6 -0
- data/views/errors/not_found.xml.haml +2 -0
- data/views/hardware_profiles/index.xml.haml +1 -1
- data/views/hardware_profiles/show.xml.haml +3 -2
- data/views/images/index.xml.haml +4 -3
- data/views/images/show.xml.haml +2 -2
- data/views/instances/index.xml.haml +6 -8
- data/views/instances/show.xml.haml +9 -10
- data/views/realms/index.xml.haml +1 -3
- data/views/realms/show.xml.haml +4 -5
- data/views/storage_snapshots/index.xml.haml +3 -5
- data/views/storage_snapshots/show.xml.haml +2 -4
- data/views/storage_volumes/index.xml.haml +7 -7
- data/views/storage_volumes/show.xml.haml +2 -4
- metadata +37 -39
- data/tests/deltacloud_test.rb +0 -60
- data/tests/storage_snapshots_test.rb +0 -48
- data/tests/storage_volumes_test.rb +0 -48
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
# Methods added to this helper will be available to all templates in the application.
|
19
20
|
module ApplicationHelper
|
@@ -53,4 +54,56 @@ module ApplicationHelper
|
|
53
54
|
return 'password' if driver_has_feature?(:authentication_password)
|
54
55
|
end
|
55
56
|
|
57
|
+
def filter_all(model)
|
58
|
+
filter = {}
|
59
|
+
filter.merge!(:id => params[:id]) if params[:id]
|
60
|
+
filter.merge!(:architecture => params[:architecture]) if params[:architecture]
|
61
|
+
filter.merge!(:owner_id => params[:owner_id]) if params[:owner_id]
|
62
|
+
filter.merge!(:state => params[:state]) if params[:state]
|
63
|
+
filter = nil if filter.keys.size.eql?(0)
|
64
|
+
singular = model.to_s.singularize.to_sym
|
65
|
+
@elements = driver.send(model.to_sym, credentials, filter)
|
66
|
+
instance_variable_set(:"@#{model}", @elements)
|
67
|
+
respond_to do |format|
|
68
|
+
format.html { haml :"#{model}/index" }
|
69
|
+
format.xml { haml :"#{model}/index" }
|
70
|
+
format.json { convert_to_json(singular, @elements) }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def show(model)
|
75
|
+
@element = driver.send(model, credentials, { :id => params[:id]} )
|
76
|
+
instance_variable_set("@#{model}", @element)
|
77
|
+
if @element
|
78
|
+
respond_to do |format|
|
79
|
+
format.html { haml :"#{model.to_s.pluralize}/show" }
|
80
|
+
format.xml { haml :"#{model.to_s.pluralize}/show" }
|
81
|
+
format.json { convert_to_json(model, @element) }
|
82
|
+
end
|
83
|
+
else
|
84
|
+
report_error(404, 'not_found')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def report_error(status, template)
|
89
|
+
@error = request.env['sinatra.error']
|
90
|
+
response.status = status
|
91
|
+
respond_to do |format|
|
92
|
+
format.xml { haml :"errors/#{template}", :layout => false }
|
93
|
+
format.html { haml :"errors/#{template}" }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def instance_action(name)
|
98
|
+
@instance = driver.send(:"#{name}_instance", credentials, params["id"])
|
99
|
+
|
100
|
+
return redirect(instances_url) if name.eql?(:destroy) or @instance.class!=Instance
|
101
|
+
|
102
|
+
respond_to do |format|
|
103
|
+
format.html { haml :"instances/show" }
|
104
|
+
format.xml { haml :"instances/show" }
|
105
|
+
format.json {convert_to_json(:instance, @instance) }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
56
109
|
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
require 'deltacloud/base_driver'
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
require 'base64'
|
19
20
|
require 'digest'
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
class BaseModel
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
class Image < BaseModel
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
class Instance < BaseModel
|
@@ -27,7 +28,7 @@ class Instance < BaseModel
|
|
27
28
|
attr_accessor :public_addresses
|
28
29
|
attr_accessor :private_addresses
|
29
30
|
attr_accessor :instance_profile
|
30
|
-
|
31
|
+
attr_accessor :launch_time
|
31
32
|
def initialize(init=nil)
|
32
33
|
super(init)
|
33
34
|
self.actions = [] if self.actions.nil?
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
# Model to store the hardware profile applied to an instance together with
|
19
20
|
# any instance-specific overrides
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
class Realm < BaseModel
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (C) 2009 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
8
10
|
#
|
9
|
-
#
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
17
18
|
|
18
19
|
|
19
20
|
class StorageVolume < BaseModel
|
data/lib/drivers.rb
CHANGED
@@ -9,6 +9,18 @@ DRIVERS = {
|
|
9
9
|
:mock => { :name => "Mock" }
|
10
10
|
}
|
11
11
|
|
12
|
+
DEFAULT_COLLECTIONS = [
|
13
|
+
:hardware_profiles,
|
14
|
+
:images,
|
15
|
+
:instances,
|
16
|
+
:instance_states,
|
17
|
+
:realms,
|
18
|
+
:storage_volumes,
|
19
|
+
:storage_snapshots
|
20
|
+
]
|
21
|
+
|
22
|
+
DRIVER=ENV['API_DRIVER'] ? ENV['API_DRIVER'].to_sym : :mock
|
23
|
+
|
12
24
|
def driver_name
|
13
25
|
DRIVERS[DRIVER][:name]
|
14
26
|
end
|
data/lib/sinatra/rabbit.rb
CHANGED
@@ -203,6 +203,7 @@ module Sinatra
|
|
203
203
|
# operation on this collection.
|
204
204
|
def collection(name, &block)
|
205
205
|
raise DuplicateCollectionException if collections[name]
|
206
|
+
return unless driver.has_collection?(name.to_sym)
|
206
207
|
collections[name] = Collection.new(name, &block)
|
207
208
|
collections[name].add_feature_params(driver.features(name))
|
208
209
|
collections[name].generate
|
data/lib/sinatra/respond_to.rb
CHANGED
data/lib/sinatra/url_for.rb
CHANGED
@@ -18,7 +18,7 @@ module Sinatra
|
|
18
18
|
when :path_only
|
19
19
|
base = request.script_name
|
20
20
|
when :full
|
21
|
-
scheme = request.scheme ||
|
21
|
+
scheme = request.scheme || 'http'
|
22
22
|
if (scheme == 'http' && request.port == 80 ||
|
23
23
|
scheme == 'https' && request.port == 443)
|
24
24
|
port = ""
|
@@ -30,9 +30,8 @@ module Sinatra
|
|
30
30
|
else
|
31
31
|
raise TypeError, "Unknown url_for mode #{mode}"
|
32
32
|
end
|
33
|
-
# Don't add the base fragment if url_for
|
34
|
-
#
|
35
|
-
# the url_fragment passed in is an absolute url
|
33
|
+
# Don't add the base fragment if url_for gets called more than once
|
34
|
+
# per url or the url_fragment passed in is an absolute url
|
36
35
|
if url_fragment.match(/^#{base}/) or url_fragment.match(/^http/)
|
37
36
|
url_fragment
|
38
37
|
else
|