thebigdb 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,51 +1,53 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thebigdb (1.0.0)
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.2)
11
- coderay (1.0.8)
12
- crack (0.3.1)
13
- diff-lcs (1.1.3)
14
- ffi (1.2.0)
15
- guard (1.5.4)
16
- listen (>= 0.4.2)
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.3.1)
21
+ guard-rspec (2.5.0)
21
22
  guard (>= 1.1)
22
23
  rspec (~> 2.11)
23
- listen (0.6.0)
24
+ listen (0.7.3)
24
25
  lumberjack (1.0.2)
25
26
  method_source (0.8.1)
26
- pry (0.9.10)
27
+ pry (0.9.12)
27
28
  coderay (~> 1.0.5)
28
29
  method_source (~> 0.8)
29
- slop (~> 3.3.1)
30
- rack (1.4.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.2)
34
- rb-inotify (0.8.8)
34
+ rb-fsevent (0.9.3)
35
+ rb-inotify (0.9.0)
35
36
  ffi (>= 0.5.0)
36
- rspec (2.12.0)
37
- rspec-core (~> 2.12.0)
38
- rspec-expectations (~> 2.12.0)
39
- rspec-mocks (~> 2.12.0)
40
- rspec-core (2.12.1)
41
- rspec-expectations (2.12.0)
42
- diff-lcs (~> 1.1.3)
43
- rspec-mocks (2.12.0)
44
- slop (3.3.3)
45
- thor (0.16.0)
46
- webmock (1.9.0)
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.1.7)
50
+ crack (>= 0.3.2)
49
51
 
50
52
  PLATFORMS
51
53
  ruby
@@ -1,7 +1,7 @@
1
1
  module TheBigDB
2
2
  module VERSION
3
3
  MAJOR = 1
4
- MINOR = 0
4
+ MINOR = 1
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
data/lib/thebigdb.rb CHANGED
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  module TheBigDB
18
18
 
19
- DEFAULT_VALUES = {
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
- mattr_accessor :api_host, :api_port, :api_version, :api_key
30
- mattr_accessor :use_ssl, :verify_ssl_certificates
31
- mattr_accessor :before_request_execution, :after_request_execution
29
+ DEFAULT_CONFIGURATION.each_key do |configuration_key|
30
+ mattr_accessor configuration_key
31
+ end
32
32
 
33
- def self.reset_default_values
34
- DEFAULT_VALUES.each_pair do |key, value|
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
- reset_default_values
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::DEFAULT_VALUES["api_host"] = "fake.test.host"
10
- TheBigDB.reset_default_values
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.reset_default_values
14
+ TheBigDB.reset_default_configuration
15
15
  end
16
16
 
17
17
  config.filter_run focus: true
@@ -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.reset_default_values
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thebigdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: