latest_stock_price 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 778aa58d46b698c7ab1c11decce31b6f2689f452f020de2af52ffab4db1f84a4
4
- data.tar.gz: 5db44299e9edc950fb50b47811b1a547245689335e52e2e5c92caa4af9402da8
3
+ metadata.gz: d377217932b62d05641a3a36e5296a20a9d7d086f2f8f4ea583f1f9f94455b86
4
+ data.tar.gz: 7793e6dc8cacecb53e95c3aa8bb222d2f99784287f90c88292c668f2dddaa216
5
5
  SHA512:
6
- metadata.gz: ed3f4a9ff4eb85af61610f104c1cb0b6e03f478fc5617e3b2e3f8be6a04544c322dd11dcfca2c7b16a37e45143e9ad55c5dad3c3638b296d7a085e0c40117fc4
7
- data.tar.gz: 83a87189ae8f73ab38792d3eff836f38842ace39740d596402e47c78a0ce50d8b9c2513144fda955a4f047db3bd94a6306bc86c981db88ebfd4965068ce55f4c
6
+ metadata.gz: bd7fe94714ae4a00a1a149e73cccd031eda5c78345fb45a050e7239c60618db20f62bde7e7f2dc206711e34dd8cea6ebae108a5539d14b49d2aa8a166ae013b2
7
+ data.tar.gz: 3ac1fe455437935ee115c3ec2d3daf204d67a1c965fb6d82c5f36f0f8d7415a1c27f446ac97bebef86b4ddd1b25fabcd209d4dc9766a4622bdde838194d8cdc7
data/CHANGELOG.md CHANGED
@@ -6,4 +6,9 @@
6
6
 
7
7
  ## 1.0.1 (29-Oct-24)
8
8
 
9
- * Fix Folder structure
9
+ * Fix Folder structure
10
+
11
+ ## 1.0.2 (29-Oct-24)
12
+
13
+ * Fix README.md
14
+ * Removed redundant `.env` file.
data/README.md CHANGED
@@ -1,23 +1,108 @@
1
- ## Read Me
2
1
 
2
+ ### Setup
3
3
 
4
- ## Setup
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
- #### Create Your Environment Variables File
11
- Copy the sample.env file to create your local .env file:
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
- cp sample.env .env
103
+ ruby example.rb # should return an object with the specified stocks.
15
104
  ```
16
105
 
17
- #### Set Your API Keys
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
- **Note:** To obtain a Rapid APi key, login to your Rapid Api account and find it in the account settings.
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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "latest_stock_price"
3
- s.version = "1.0.1"
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.1
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-28 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- # Rapid APi credentials
2
- X_RAPIDAPI_KEY='your_rapidapi_key_here'
3
- X_RAPIDAPI_HOST='your_rapidpia_host'