schwab_rb 0.3.11 → 0.3.12

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
2
  SHA256:
3
- metadata.gz: 53cef23634d68e9c9650190e7ad67d58e6c4b3dda00cb7ec2a5e43cc9495bf1f
4
- data.tar.gz: 9e60a403d25f003c38cc657db9683e74b8deae7324757a88337da4b36761a5e7
3
+ metadata.gz: b051569d86c70eaf117260fdc77f1926eb7c0bdf1141614903ac02f4bd834e6f
4
+ data.tar.gz: 3d7f8e02b966002399f23faba75559561827e080d13257da36f219cef2019464
5
5
  SHA512:
6
- metadata.gz: f6e2e35615e1b5fca5f6a8dce012c660da6ecf0f88f752aee02594188af66136cae36aa263aa6578c5af18242c9154f51a12f46f4fc396f897265b26cdab9e3b
7
- data.tar.gz: 4c369dfaa8fcec91d819849680c7bb7409b051da5a3b0dacdb8c15b9d516e042b751450d2863fd86fbac4b5a776d2f4205c86dfe223b672345372015b6890321
6
+ metadata.gz: 7076466bc502788b935e4fa239f44624a27c0a066c6b78be76af798efaa1181720710cd0b796b67a5a1003aac1d5b070739942a7cbed4b8daa0fe87b0c45bf01
7
+ data.tar.gz: 272af18823441bc12f778213d9c2589e7f35b0001f349b72b8df47ac0ae2d9f65aa8c30e3088aadc78c774b479ceed72a474ccdd762c6486f4db99c447dfb746
@@ -17,6 +17,37 @@ module SchwabRb
17
17
 
18
18
  class RedirectServerExitedError < StandardError; end
19
19
 
20
+ class OS
21
+ def self.windows?
22
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
23
+ end
24
+
25
+ def self.mac?
26
+ (/darwin/ =~ RUBY_PLATFORM) != nil
27
+ end
28
+
29
+ def self.unix?
30
+ !windows?
31
+ end
32
+
33
+ def self.linux?
34
+ unix? && !mac?
35
+ end
36
+
37
+ def self.open_cmd
38
+ return "open" if mac?
39
+ return %w[start msedge] if windows?
40
+
41
+ "xdg-open"
42
+ end
43
+ end
44
+
45
+ class BrowserLauncher
46
+ def self.open(command)
47
+ `#{command.join(" ")}`
48
+ end
49
+ end
50
+
20
51
  # class TokenExchangeError < StandardError
21
52
  # def initialize(msg)
22
53
  # super(msg)
@@ -100,7 +131,7 @@ module SchwabRb
100
131
  gets
101
132
  end
102
133
 
103
- `open "#{auth_context.authorization_url}}"`
134
+ open_browser(requested_browser, auth_context.authorization_url)
104
135
 
105
136
  timeout_time = Time.now + callback_timeout
106
137
  received_url = nil
@@ -127,6 +158,17 @@ module SchwabRb
127
158
  end
128
159
  end
129
160
 
161
+ def self.open_browser(browser, url, browser_launcher: BrowserLauncher)
162
+ open_args = Array(OS.open_cmd)
163
+ if !browser.nil? && !browser.strip.empty? && OS.mac?
164
+ open_args << "-a"
165
+ open_args << browser.gsub(" ", "\\ ")
166
+ end
167
+ open_args << %("#{url}")
168
+
169
+ browser_launcher.open open_args
170
+ end
171
+
130
172
  def self.create_ssl_certificate
131
173
  key = OpenSSL::PKey::RSA.new(2048)
132
174
  cert = OpenSSL::X509::Certificate.new
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SchwabRb
4
- VERSION = "0.3.11"
4
+ VERSION = "0.3.12"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schwab_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Platta
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-09-08 00:00:00.000000000 Z
10
+ date: 2025-09-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async