latest_stock_price 1.0.1 → 1.0.2
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 +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +96 -11
- data/latest_stock_price.gemspec +2 -3
- metadata +2 -3
- 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: d377217932b62d05641a3a36e5296a20a9d7d086f2f8f4ea583f1f9f94455b86
|
4
|
+
data.tar.gz: 7793e6dc8cacecb53e95c3aa8bb222d2f99784287f90c88292c668f2dddaa216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd7fe94714ae4a00a1a149e73cccd031eda5c78345fb45a050e7239c60618db20f62bde7e7f2dc206711e34dd8cea6ebae108a5539d14b49d2aa8a166ae013b2
|
7
|
+
data.tar.gz: 3ac1fe455437935ee115c3ec2d3daf204d67a1c965fb6d82c5f36f0f8d7415a1c27f446ac97bebef86b4ddd1b25fabcd209d4dc9766a4622bdde838194d8cdc7
|
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.2"
|
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",
|
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.2
|
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
|
@@ -111,7 +111,6 @@ files:
|
|
111
111
|
- lib/price_all.rb
|
112
112
|
- lib/prices.rb
|
113
113
|
- lib/version.rb
|
114
|
-
- sample.env
|
115
114
|
- spec/http_client_spec.rb
|
116
115
|
- spec/price_all_spec.rb
|
117
116
|
- spec/price_spec.rb
|
data/sample.env
DELETED