thebigdb 1.0.0 → 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/Gemfile.lock +29 -27
- data/lib/thebigdb/version.rb +1 -1
- data/lib/thebigdb.rb +14 -7
- data/spec/spec_helper.rb +3 -3
- data/spec/thebigdb_spec.rb +9 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -1,51 +1,53 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
thebigdb (1.
|
4
|
+
thebigdb (1.1.0)
|
5
5
|
rack (~> 1.4)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.3.
|
11
|
-
coderay (1.0.
|
12
|
-
crack (0.3.
|
13
|
-
diff-lcs (1.1
|
14
|
-
ffi (1.
|
15
|
-
guard (1.
|
16
|
-
listen (>= 0.
|
10
|
+
addressable (2.3.3)
|
11
|
+
coderay (1.0.9)
|
12
|
+
crack (0.3.2)
|
13
|
+
diff-lcs (1.2.1)
|
14
|
+
ffi (1.4.0)
|
15
|
+
guard (1.6.2)
|
16
|
+
listen (>= 0.6.0)
|
17
17
|
lumberjack (>= 1.0.2)
|
18
18
|
pry (>= 0.9.10)
|
19
|
+
terminal-table (>= 1.4.3)
|
19
20
|
thor (>= 0.14.6)
|
20
|
-
guard-rspec (2.
|
21
|
+
guard-rspec (2.5.0)
|
21
22
|
guard (>= 1.1)
|
22
23
|
rspec (~> 2.11)
|
23
|
-
listen (0.
|
24
|
+
listen (0.7.3)
|
24
25
|
lumberjack (1.0.2)
|
25
26
|
method_source (0.8.1)
|
26
|
-
pry (0.9.
|
27
|
+
pry (0.9.12)
|
27
28
|
coderay (~> 1.0.5)
|
28
29
|
method_source (~> 0.8)
|
29
|
-
slop (~> 3.
|
30
|
-
rack (1.
|
30
|
+
slop (~> 3.4)
|
31
|
+
rack (1.5.2)
|
31
32
|
rb-fchange (0.0.6)
|
32
33
|
ffi
|
33
|
-
rb-fsevent (0.9.
|
34
|
-
rb-inotify (0.
|
34
|
+
rb-fsevent (0.9.3)
|
35
|
+
rb-inotify (0.9.0)
|
35
36
|
ffi (>= 0.5.0)
|
36
|
-
rspec (2.
|
37
|
-
rspec-core (~> 2.
|
38
|
-
rspec-expectations (~> 2.
|
39
|
-
rspec-mocks (~> 2.
|
40
|
-
rspec-core (2.
|
41
|
-
rspec-expectations (2.
|
42
|
-
diff-lcs (
|
43
|
-
rspec-mocks (2.
|
44
|
-
slop (3.
|
45
|
-
|
46
|
-
|
37
|
+
rspec (2.13.0)
|
38
|
+
rspec-core (~> 2.13.0)
|
39
|
+
rspec-expectations (~> 2.13.0)
|
40
|
+
rspec-mocks (~> 2.13.0)
|
41
|
+
rspec-core (2.13.1)
|
42
|
+
rspec-expectations (2.13.0)
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
+
rspec-mocks (2.13.0)
|
45
|
+
slop (3.4.4)
|
46
|
+
terminal-table (1.4.5)
|
47
|
+
thor (0.17.0)
|
48
|
+
webmock (1.11.0)
|
47
49
|
addressable (>= 2.2.7)
|
48
|
-
crack (>= 0.
|
50
|
+
crack (>= 0.3.2)
|
49
51
|
|
50
52
|
PLATFORMS
|
51
53
|
ruby
|
data/lib/thebigdb/version.rb
CHANGED
data/lib/thebigdb.rb
CHANGED
@@ -16,7 +16,7 @@ end
|
|
16
16
|
|
17
17
|
module TheBigDB
|
18
18
|
|
19
|
-
|
19
|
+
DEFAULT_CONFIGURATION = {
|
20
20
|
"api_host" => "api.thebigdb.com",
|
21
21
|
"api_port" => 80,
|
22
22
|
"api_version" => "1",
|
@@ -26,16 +26,16 @@ module TheBigDB
|
|
26
26
|
"after_request_execution" => Proc.new{}
|
27
27
|
}
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
DEFAULT_CONFIGURATION.each_key do |configuration_key|
|
30
|
+
mattr_accessor configuration_key
|
31
|
+
end
|
32
32
|
|
33
|
-
def self.
|
34
|
-
|
33
|
+
def self.reset_default_configuration
|
34
|
+
DEFAULT_CONFIGURATION.each_pair do |key, value|
|
35
35
|
send(key + "=", value)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
reset_default_configuration
|
39
39
|
|
40
40
|
def self.use_ssl=(bool)
|
41
41
|
@@api_port = bool ? 443 : 80
|
@@ -63,6 +63,13 @@ module TheBigDB
|
|
63
63
|
@@after_request_execution = object
|
64
64
|
end
|
65
65
|
|
66
|
+
def self.with_configuration(new_configuration, &block)
|
67
|
+
current_configuration = Hash[DEFAULT_CONFIGURATION.keys.map{|k| [k, send(k)] }]
|
68
|
+
new_configuration.each_pair{|k,v| send(k.to_s + "=", v) }
|
69
|
+
yield
|
70
|
+
current_configuration.each_pair{|k,v| send(k.to_s + "=", v) }
|
71
|
+
end
|
72
|
+
|
66
73
|
|
67
74
|
# Shortcut: prepares, executes and returns Hash containing the server's response
|
68
75
|
def self.send_request(*args)
|
data/spec/spec_helper.rb
CHANGED
@@ -6,12 +6,12 @@ RSpec.configure do |config|
|
|
6
6
|
config.order = "random"
|
7
7
|
|
8
8
|
config.before(:each) do
|
9
|
-
TheBigDB::
|
10
|
-
TheBigDB.
|
9
|
+
TheBigDB::DEFAULT_CONFIGURATION["api_host"] = "fake.test.host"
|
10
|
+
TheBigDB.reset_default_configuration
|
11
11
|
end
|
12
12
|
|
13
13
|
config.after(:each) do
|
14
|
-
TheBigDB.
|
14
|
+
TheBigDB.reset_default_configuration
|
15
15
|
end
|
16
16
|
|
17
17
|
config.filter_run focus: true
|
data/spec/thebigdb_spec.rb
CHANGED
@@ -17,7 +17,15 @@ describe "TheBigDB module" do
|
|
17
17
|
it "has resettable default values" do
|
18
18
|
default_host = TheBigDB.api_host.dup
|
19
19
|
TheBigDB.api_host = "foobar"
|
20
|
-
TheBigDB.
|
20
|
+
TheBigDB.reset_default_configuration
|
21
21
|
TheBigDB.api_host.should == default_host
|
22
22
|
end
|
23
|
+
|
24
|
+
it "can set a configuration scope" do
|
25
|
+
TheBigDB.api_host = "thebigdb_host_1"
|
26
|
+
TheBigDB.with_configuration(api_host: "thebigdb_host_2") do
|
27
|
+
TheBigDB.api_host.should == "thebigdb_host_2"
|
28
|
+
end
|
29
|
+
TheBigDB.api_host.should == "thebigdb_host_1"
|
30
|
+
end
|
23
31
|
end
|