latest_stock_price 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +96 -11
- data/latest_stock_price.gemspec +2 -4
- data/spec/http_client_spec.rb +0 -1
- data/spec/price_all_spec.rb +0 -1
- data/spec/price_spec.rb +0 -1
- data/spec/prices_spec.rb +0 -1
- metadata +2 -17
- data/sample.env +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac3a6f27080e915c85d5486a20dd7fcc92083d13af3af4c731db4d944ac17d0
|
4
|
+
data.tar.gz: a5b193c3cde9397bc3db7fd381e824b5cff5fcc4d62d5a8207203d76599e7c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8647a2d9f7717a3fd1be5d00c759b0b311341bfbe1f65ff970f551366fc71ad758902b369936d04b8012847501d5d26ebc08d4daa3e5a18be0ddf8e7f3e764c7
|
7
|
+
data.tar.gz: fccd038bcd0c10b8a4f78be09f89522a3cb42d9d3895c8c5e4a9d5369812ba38a04401096bcb80ada5385b3ac3236b8fe53cbacd7b49078c9ff719a6111c5834
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,108 @@
|
|
1
|
-
## Read Me
|
2
1
|
|
2
|
+
### Setup
|
3
3
|
|
4
|
-
|
4
|
+
If you don’t already have bundle, then run this in your project directory (where you’d like to use this gem):
|
5
|
+
|
6
|
+
#### 1. Add The Gem
|
7
|
+
|
8
|
+
```
|
9
|
+
bundle init
|
10
|
+
```
|
11
|
+
|
12
|
+
This will add a **Gemfile** to your project directory.
|
13
|
+
|
14
|
+
Inside the gem file, add the gem and dependencies like so:
|
15
|
+
|
16
|
+
```
|
17
|
+
gem 'latest_stock_price', ‘1.0.1’ # Ensure to use version 1.0.1 or above.
|
18
|
+
gem 'dotenv', '~> 3.0.0' # Dependency required.
|
19
|
+
```
|
20
|
+
|
21
|
+
To install the gems, run:
|
5
22
|
|
6
23
|
```
|
7
24
|
bundle install
|
8
25
|
```
|
9
26
|
|
10
|
-
####
|
11
|
-
|
27
|
+
#### 2. Configure Credentials
|
28
|
+
|
29
|
+
This gem uses APIs from rapidapi.com. Ensure an account is created and gather your secret key after logging in.
|
30
|
+
|
31
|
+
In your project directory, create a `.env` file using the following command:
|
32
|
+
|
33
|
+
```
|
34
|
+
touch .env
|
35
|
+
```
|
36
|
+
|
37
|
+
Open the newly created `.env` file and add:
|
38
|
+
|
39
|
+
```
|
40
|
+
# Rapid API credentials
|
41
|
+
X_RAPIDAPI_KEY=‘Add_your_rapid_api_key_here’
|
42
|
+
X_RAPIDAPI_HOST='latest-stock-price.p.rapidapi.com'
|
43
|
+
```
|
44
|
+
|
45
|
+
### Example Usage
|
46
|
+
|
47
|
+
As an example, create a new file in you project directory:
|
48
|
+
|
49
|
+
```
|
50
|
+
touch example.rb
|
51
|
+
```
|
52
|
+
|
53
|
+
There are 3 ways to interact with the gem:
|
54
|
+
|
55
|
+
#### 1. Get all the latest stock prices:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
# example.rb
|
59
|
+
require 'bundler/setup'
|
60
|
+
require 'latest_stock_price'
|
61
|
+
|
62
|
+
price_all = LatestStockPrice::PriceAll.fetch
|
63
|
+
puts price_all
|
64
|
+
```
|
65
|
+
|
66
|
+
In your project repository, run the following command to get the prices of all the stocks:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
ruby example.rb # should return an object with many stock data
|
70
|
+
```
|
71
|
+
|
72
|
+
#### 2. Get the latest price of a specific stock:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
# example.rb
|
76
|
+
require 'bundler/setup'
|
77
|
+
require 'latest_stock_price'
|
78
|
+
|
79
|
+
price = LatestStockPrice::Price.fetch("AAATECH.NS")
|
80
|
+
puts price
|
81
|
+
```
|
82
|
+
|
83
|
+
In your project repository, run the following command to get the price of a specific stock:
|
84
|
+
|
85
|
+
```
|
86
|
+
ruby example.rb # should return an object with one stock.
|
87
|
+
```
|
88
|
+
|
89
|
+
#### 3. Get the latest prices for a specified list of stocks:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
# example.rb
|
93
|
+
require 'bundler/setup'
|
94
|
+
require 'latest_stock_price'
|
95
|
+
|
96
|
+
prices = LatestStockPrice::Prices.fetch(['AAATECH.NS', 'AADHHOUS.NS'])
|
97
|
+
puts prices
|
98
|
+
```
|
99
|
+
|
100
|
+
In your project repository, run the following command for a list of the stocks and their data.
|
12
101
|
|
13
102
|
```
|
14
|
-
|
103
|
+
ruby example.rb # should return an object with the specified stocks.
|
15
104
|
```
|
16
105
|
|
17
|
-
|
18
|
-
Open the .env file in your preferred text editor and add your API keys:
|
19
|
-
# .env
|
20
|
-
RAPIDAPI_KEY='your_actual_api_key'
|
21
|
-
RAPIDAPI_HOST='latest-stock-price.p.rapidapi.com'
|
106
|
+
### Warnings
|
22
107
|
|
23
|
-
|
108
|
+
The `.env` file contains your secret key. Ensure the file does not get committed to remote repositories by adding it to your `.gitignore` file.
|
data/latest_stock_price.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "latest_stock_price"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.3"
|
4
4
|
s.summary = "Latest stock price"
|
5
5
|
s.authors = ["Ciever Hassan"]
|
6
6
|
s.description = "A gem for displaying the latest stock price."
|
@@ -19,8 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
"spec/price_all_spec.rb",
|
20
20
|
"spec/price_spec.rb",
|
21
21
|
"spec/prices_spec.rb",
|
22
|
-
"spec/spec_helper.rb",
|
23
|
-
"sample.env",
|
22
|
+
"spec/spec_helper.rb",
|
24
23
|
"README.md",
|
25
24
|
"CHANGELOG.md",
|
26
25
|
"Gemfile",
|
@@ -33,5 +32,4 @@ Gem::Specification.new do |s|
|
|
33
32
|
|
34
33
|
s.add_dependency 'net-http', '~> 0.4.1'
|
35
34
|
s.add_dependency 'uri', '~> 0.10.0'
|
36
|
-
s.add_dependency 'debug', '~> 1.8'
|
37
35
|
end
|
data/spec/http_client_spec.rb
CHANGED
data/spec/price_all_spec.rb
CHANGED
data/spec/price_spec.rb
CHANGED
data/spec/prices_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latest_stock_price
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ciever Hassan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.10.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: debug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.8'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.8'
|
97
83
|
description: A gem for displaying the latest stock price.
|
98
84
|
email: ciever.a.h@hotmail.com
|
99
85
|
executables: []
|
@@ -111,7 +97,6 @@ files:
|
|
111
97
|
- lib/price_all.rb
|
112
98
|
- lib/prices.rb
|
113
99
|
- lib/version.rb
|
114
|
-
- sample.env
|
115
100
|
- spec/http_client_spec.rb
|
116
101
|
- spec/price_all_spec.rb
|
117
102
|
- spec/price_spec.rb
|
data/sample.env
DELETED