dss_reuters 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 8afaa6a54f0b0587790994ada3fdd9c3505ef0955e2c4f0fc4a6ce63f05e0d74
4
- data.tar.gz: '097099ec42cfe40332fa335cbd054b850455922a39fa9dc33da1971627a0a507'
2
+ SHA1:
3
+ metadata.gz: 47ea67d3a2c9a5cd34848988152d6723f3629e17
4
+ data.tar.gz: cdae6f36c34c7c5949db00328412beb8c197e012
5
5
  SHA512:
6
- metadata.gz: 057fb5f6f3ec28dd930138863adf91d2a58929c8a152df9834b2a6674826f93f050f3dd04c360d5ac6864580db6fcd8f4941077842b6ef820935323dafb93732
7
- data.tar.gz: 58a15c63f781fbd7598acfe309b08c8eadb86266b0d8804c48c00d48baa964484a554ba76c444f1b4fd46f02476a49bd73574f6ceb52141639e40d6da5e66c69
6
+ metadata.gz: ba684c9c0ba7b251123de6125240c93f998342b4905ec8d73a3e96e0b7a3d971ec17391f50184888cb4d62616a50bb585ed66c5d9e560eb55e0b008e605a49a5
7
+ data.tar.gz: 827492b204258cb8ffda3b89ffc93494c422431b58989ef3ba51884cc064940959f6418c316dd4f05354fb8f6bc82527fd8eb5c554a3100b7837f1953445b5a0
@@ -1,3 +1,3 @@
1
1
  module DssReuters
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/dss_reuters.rb CHANGED
@@ -6,9 +6,9 @@ require "dss_reuters/version"
6
6
  module DssReuters
7
7
  class Config
8
8
  BASE_URI = "https://hosted.datascopeapi.reuters.com"
9
- DSS_USERNAME = ENV.fetch('DSS_USERNAME')
10
- DSS_PASSWORD = ENV.fetch('DSS_PASSWORD')
11
9
  LOG_LEVEL = ENV['DSS_LOG_LEVEL'] || 'INFO'
10
+ DSS_USERNAME = ENV['DSS_USERNAME']
11
+ DSS_PASSWORD = ENV['DSS_PASSWORD']
12
12
  end
13
13
 
14
14
  class Session
@@ -17,6 +17,14 @@ module DssReuters
17
17
 
18
18
  attr_reader :context, :token, :logger
19
19
 
20
+ def configured?
21
+ !Config::DSS_USERNAME.nil? and !Config::DSS_PASSWORD.nil?
22
+ end
23
+
24
+ def not_configured_error
25
+ @logger.error "dss_reuters gem not configured. you will not be able to fetch data from dss reuters API"
26
+ end
27
+
20
28
  def initialize
21
29
  @logger = ::Logger.new(STDOUT)
22
30
  @logger.level = Config::LOG_LEVEL
@@ -33,10 +41,14 @@ module DssReuters
33
41
  }
34
42
  }.to_json
35
43
  }
36
- resp = self.class.post login_path, options
37
- @token = resp["value"]
38
- @context = resp["@odata.context"]
39
- @logger.debug resp
44
+ if configured?
45
+ resp = self.class.post login_path, options
46
+ @token = resp["value"]
47
+ @context = resp["@odata.context"]
48
+ @logger.debug resp
49
+ else
50
+ not_configured_error
51
+ end
40
52
  end
41
53
  end
42
54
 
@@ -53,8 +65,12 @@ module DssReuters
53
65
  "Authorization" => "Token #{@session.token}"
54
66
  }
55
67
  }
56
- resp = self.class.get path, options
57
- @session.logger.debug resp
68
+ if session.configured?
69
+ resp = self.class.get path, options
70
+ @session.logger.debug resp
71
+ else
72
+ session.not_configured_error
73
+ end
58
74
  end
59
75
  end
60
76
 
@@ -101,11 +117,15 @@ module DssReuters
101
117
  }
102
118
  }.to_json
103
119
  }
104
- resp = self.class.post path, options
105
- if check_status(resp)
106
- @location = resp["location"]
120
+ if session.configured?
121
+ resp = self.class.post path, options
122
+ if check_status(resp)
123
+ @location = resp["location"]
124
+ end
125
+ @session.logger.debug resp
126
+ else
127
+ session.not_configured_error
107
128
  end
108
- @session.logger.debug resp
109
129
  end
110
130
  end
111
131
 
@@ -125,10 +145,14 @@ module DssReuters
125
145
  "Authorization" => "Token #{@session.token}"
126
146
  }
127
147
  }
128
- @result = self.class.get @location, options
129
- check_status @result
130
- @session.logger.debug @result
131
- @status
148
+ if @session.configured?
149
+ @result = self.class.get @location, options
150
+ check_status @result
151
+ @session.logger.debug @result
152
+ @status
153
+ else
154
+ @session.not_configured_error
155
+ end
132
156
  end
133
157
  end
134
158
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dss_reuters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arda Karaduman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-30 00:00:00.000000000 Z
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.7.6
121
+ rubygems_version: 2.6.11
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: This is a simple gem to extract data from DSS Reuters