eodhd.rb 0.16.0 → 0.18.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.
@@ -1,10 +1,12 @@
1
- require_relative 'helper'
1
+ # Eodhd/Validations_test.rb
2
+
3
+ require_relative '../helper'
2
4
 
3
5
  class DummyIncludingValidations
4
6
  include Eodhd::Validations
5
7
  end
6
8
 
7
- describe "Eodhd::Validations" do
9
+ describe Eodhd::Validations do
8
10
  let(:v){DummyIncludingValidations.new}
9
11
 
10
12
  describe "#validate_arguments" do
@@ -92,6 +94,21 @@ describe "Eodhd::Validations" do
92
94
  end
93
95
  end
94
96
 
97
+ describe "#validate_interval" do
98
+ it "accepts valid intervals" do
99
+ _{v.validate_interval('1m')}.must_be_silent
100
+ _{v.validate_interval('5m')}.must_be_silent
101
+ _{v.validate_interval('1h')}.must_be_silent
102
+ _{v.validate_interval('1d')}.must_be_silent
103
+ end
104
+
105
+ it "rejects invalid intervals" do
106
+ _{v.validate_interval('2m')}.must_raise(ArgumentError)
107
+ _{v.validate_interval('invalid')}.must_raise(ArgumentError)
108
+ _{v.validate_interval('')}.must_raise(ArgumentError)
109
+ end
110
+ end
111
+
95
112
  describe "#validate_date" do
96
113
  it "accepts valid date formats and Date objects" do
97
114
  _{v.validate_date('2024-09-30')}.must_be_silent
@@ -1,4 +1,6 @@
1
- require_relative 'helper'
1
+ # Eodhd/WebSocketClient_test.rb
2
+
3
+ require_relative '../helper'
2
4
 
3
5
  describe Eodhd::WebSocketClient do
4
6
  let(:api_token){ENV.fetch('EODHD_API_TOKEN', '<API_TOKEN>')}
@@ -53,10 +55,10 @@ describe Eodhd::WebSocketClient do
53
55
  describe "#run" do
54
56
  it "configures Iodine and starts connection" do
55
57
  client = Eodhd::WebSocketClient.new(api_token: api_token, asset_class: 'us', symbols: 'AAPL', consumer: consumer)
56
-
58
+
57
59
  iodine_connect_called = false
58
60
  iodine_start_called = false
59
-
61
+
60
62
  Iodine.stub(:threads=, nil) do
61
63
  Iodine.stub(:connect, ->(opts){iodine_connect_called = true}) do
62
64
  Iodine.stub(:start, ->{iodine_start_called = true}) do
@@ -64,7 +66,7 @@ describe Eodhd::WebSocketClient do
64
66
  end
65
67
  end
66
68
  end
67
-
69
+
68
70
  _(iodine_connect_called).must_equal(true)
69
71
  _(iodine_start_called).must_equal(true)
70
72
  end
@@ -76,10 +78,10 @@ describe Eodhd::WebSocketClient do
76
78
  received_data = nil
77
79
  test_consumer = ->(data){received_data = data}
78
80
  handler = Eodhd::WebSocketClient::Handler.new(symbols: 'AAPL', consumer: test_consumer, logger: nil)
79
-
81
+
80
82
  message = '{"symbol":"AAPL","price":150.0}'
81
83
  handler.on_message(nil, message)
82
-
84
+
83
85
  _(received_data).must_be_kind_of(Hash)
84
86
  _(received_data['symbol']).must_equal('AAPL')
85
87
  _(received_data['price']).must_equal(150.0)
@@ -88,7 +90,7 @@ describe Eodhd::WebSocketClient do
88
90
  it "raises Eodhd::Error on invalid JSON" do
89
91
  test_consumer = ->(data){}
90
92
  handler = Eodhd::WebSocketClient::Handler.new(symbols: 'AAPL', consumer: test_consumer, logger: nil)
91
-
93
+
92
94
  invalid_message = '{invalid json'
93
95
  _{handler.on_message(nil, invalid_message)}.must_raise(Eodhd::Error)
94
96
  end
@@ -1,3 +1,5 @@
1
+ # Eodhd_test.rb
2
+
1
3
  require_relative "helper"
2
4
 
3
5
  describe Eodhd do
@@ -47,4 +49,25 @@ describe Eodhd do
47
49
  end
48
50
  end
49
51
  end
52
+
53
+ describe "#intraday" do
54
+ it "delegates to Eodhd::Intraday.all" do
55
+ VCR.use_cassette('eodhd_intraday') do
56
+ intraday_data = eodhd.intraday(exchange_code: 'US', symbol: 'AAPL', interval: '5m')
57
+ _(intraday_data).must_be_kind_of(Array)
58
+ _(intraday_data).wont_be_empty
59
+ _(intraday_data.first).must_be_kind_of(Eodhd::Intraday)
60
+ end
61
+ end
62
+ end
63
+
64
+ describe "#fundamentals" do
65
+ it "delegates to Eodhd::Fundamentals.all" do
66
+ VCR.use_cassette('eodhd_fundamentals') do
67
+ fundamental_data = eodhd.fundamentals(exchange_code: 'US', symbol: 'AAPL')
68
+ _(fundamental_data).must_be_kind_of(Eodhd::Fundamentals)
69
+ _(fundamental_data.general).must_be_kind_of(Eodhd::Fundamentals::General)
70
+ end
71
+ end
72
+ end
50
73
  end
data/test/helper.rb CHANGED
@@ -1,4 +1,7 @@
1
+ # helper.rb
2
+
1
3
  require 'minitest/autorun'
4
+ require 'minitest/mock'
2
5
  require 'minitest/spec'
3
6
  require 'minitest-spec-context'
4
7
  require 'vcr'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eodhd.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-05 00:00:00.000000000 Z
10
+ date: 2026-03-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: http.rb
@@ -65,6 +65,20 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: minitest-mock
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
68
82
  - !ruby/object:Gem::Dependency
69
83
  name: minitest-spec-context
70
84
  requirement: !ruby/object:Gem::Requirement
@@ -127,10 +141,11 @@ executables: []
127
141
  extensions: []
128
142
  extra_rdoc_files: []
129
143
  files:
144
+ - CHANGELOG
130
145
  - Gemfile
131
146
  - README.md
147
+ - Rakefile
132
148
  - eodhd.rb.gemspec
133
- - lib/Eodhd.rb
134
149
  - lib/Eodhd/Client.rb
135
150
  - lib/Eodhd/DefaultLogger.rb
136
151
  - lib/Eodhd/EodBulkLastDay.rb
@@ -138,21 +153,36 @@ files:
138
153
  - lib/Eodhd/Error.rb
139
154
  - lib/Eodhd/Exchange.rb
140
155
  - lib/Eodhd/ExchangeSymbol.rb
156
+ - lib/Eodhd/Fundamentals.rb
157
+ - lib/Eodhd/Fundamentals/AnalystRatings.rb
158
+ - lib/Eodhd/Fundamentals/ESGScores.rb
159
+ - lib/Eodhd/Fundamentals/Earnings.rb
160
+ - lib/Eodhd/Fundamentals/Financials.rb
161
+ - lib/Eodhd/Fundamentals/Financials/Statement.rb
162
+ - lib/Eodhd/Fundamentals/General.rb
163
+ - lib/Eodhd/Fundamentals/Highlights.rb
164
+ - lib/Eodhd/Fundamentals/Holders.rb
165
+ - lib/Eodhd/Fundamentals/SharesStats.rb
166
+ - lib/Eodhd/Fundamentals/SplitsDividends.rb
167
+ - lib/Eodhd/Fundamentals/Technicals.rb
168
+ - lib/Eodhd/Fundamentals/Valuation.rb
169
+ - lib/Eodhd/Intraday.rb
141
170
  - lib/Eodhd/VERSION.rb
142
171
  - lib/Eodhd/Validations.rb
143
172
  - lib/Eodhd/WebSocketClient.rb
144
173
  - lib/Hash/x_www_form_urlencode.rb
145
174
  - lib/Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb
146
175
  - lib/Thoran/String/UrlEncode/url_encode.rb
147
- - test/client_test.rb
148
- - test/eodhd_test.rb
176
+ - lib/eodhd.rb
177
+ - test/Eodhd/Client_test.rb
178
+ - test/Eodhd/Fundamentals_test.rb
179
+ - test/Eodhd/Validations_test.rb
180
+ - test/Eodhd/WebSocketClient_test.rb
181
+ - test/Eodhd_test.rb
149
182
  - test/helper.rb
150
- - test/test_all.rb
151
- - test/validations_test.rb
152
- - test/web_socket_client_test.rb
153
183
  homepage: http://github.com/thoran/eodhd.rb
154
184
  licenses:
155
- - Ruby
185
+ - MIT
156
186
  metadata: {}
157
187
  rdoc_options: []
158
188
  require_paths:
@@ -161,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
191
  requirements:
162
192
  - - ">="
163
193
  - !ruby/object:Gem::Version
164
- version: '2.5'
194
+ version: '2.7'
165
195
  required_rubygems_version: !ruby/object:Gem::Requirement
166
196
  requirements:
167
197
  - - ">="
168
198
  - !ruby/object:Gem::Version
169
199
  version: '0'
170
200
  requirements: []
171
- rubygems_version: 3.7.2
201
+ rubygems_version: 4.0.8
172
202
  specification_version: 4
173
203
  summary: Access the eodhd.com API with Ruby.
174
204
  test_files: []
data/test/test_all.rb DELETED
@@ -1,5 +0,0 @@
1
- require_relative "helper"
2
-
3
- Dir[File.expand_path("./**/*_test.rb", __dir__)].each do |file|
4
- require file
5
- end