mortgagerb 0.1.5 → 0.2.0

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: 15d0932e45e8a052fd914fe4deec87393e381d67e8b3cfdd7303b3d96072375c
4
- data.tar.gz: be02a4e36939c96e569540b0a67a9b07e744482fd3493ae330ab6c2dd2b9ee50
3
+ metadata.gz: d8e3fcee7b69255bf0df020d2a1e38600bf355b9c3dc3478df00caec5cbc64aa
4
+ data.tar.gz: ee31b2bbb990b25daec56f30a043d0b62211d72da1480570a67d85b457e5cd4b
5
5
  SHA512:
6
- metadata.gz: bf8847fda2ddf9ddb30b1373dff35ba4845f47902079e321e9993a6b64b92eca62a63832683a51ef6fd83a1a794a08b4536b305ecfacf23de4d6ef35afac5c1a
7
- data.tar.gz: fba108618cbaf0b44d918460ba2c9194586942b6744bef324234d29cac72c6276ffd9e20ba40bd8b7c74acca817131e3744951b0beab6e0da8296b8651fa0489
6
+ metadata.gz: 8c7e1926a18c4dabbd13c1a5b114cf2c440a517204dfcccb13ab2fa20593f4f7bb8db467d1f896fa7f54cef9498bb76901548a78cd1e9e27f29de89a0bf6fab8
7
+ data.tar.gz: 413800dccf465e107ed86dbcc2fa494c3c29fb4d3017f19b1af53d5cb64b9cf284f3de57824a3ec7ec080fa4926c824f876236a966e347466c804eef48dbe2d0
data/README.md CHANGED
@@ -30,6 +30,21 @@ scenario = Mortgagerb::Scenario.new(principal, rate, type)
30
30
  amortization_payment = scenario.calculate # 5677.89
31
31
  ```
32
32
 
33
+ ### Get the 30-Yr FRM and 15-Yr FRM from Freddie Mac
34
+
35
+ The gem will scrape Freddie Mac's website in order to get the rates.
36
+ Use this responsibly. Do not over-scrape the website. Cache the value locally.
37
+ Check for new data seldomly.
38
+
39
+ ```ruby
40
+ require 'mortgagerb'
41
+
42
+ rates_now = Mortgagerb::FreddieMac.now
43
+ frm30 = rates_now[:fmr30] # 7.77
44
+ frm15 = rates_now[:frm15] # 6.66
45
+ ```
46
+
47
+
33
48
  ## Development
34
49
 
35
50
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,27 @@
1
+ require "faraday"
2
+ require "nokogiri"
3
+
4
+ module Mortgagerb
5
+ class FreddieMac
6
+ def self.now
7
+ parsed_data = fetch
8
+ locate_assign(parsed_data)
9
+ end
10
+
11
+ def self.fetch
12
+ response = Faraday.get("https://www.freddiemac.com/pmms/pmmsthick.html")
13
+ html = response.body
14
+ parsed_data = Nokogiri::HTML.parse(html)
15
+ end
16
+
17
+ def self.locate_assign(parsed_data)
18
+ fmr30 = parsed_data.xpath("//div[@class='pmmsContainer']/table[@class='table1']/tr/td[1]")
19
+ fmr15 = parsed_data.xpath("//div[@class='pmmsContainer']/table[@class='table1']/tr/td[2]")
20
+
21
+ {
22
+ fmr30: fmr30.text.strip.to_f,
23
+ fmr15: fmr15.text.strip.to_f
24
+ }
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mortgagerb
4
- VERSION = "0.1.5"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/mortgagerb.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "mortgagerb/version"
4
4
  require_relative "mortgagerb/calculator"
5
+ require_relative "mortgagerb/freddie_mac"
5
6
  require_relative "mortgagerb/scenario"
6
7
 
7
8
  module Mortgagerb
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortgagerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Kim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2024-11-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calculate periodic payment given principal, rate and mortgage type
14
14
  email:
@@ -24,6 +24,7 @@ files:
24
24
  - Rakefile
25
25
  - lib/mortgagerb.rb
26
26
  - lib/mortgagerb/calculator.rb
27
+ - lib/mortgagerb/freddie_mac.rb
27
28
  - lib/mortgagerb/scenario.rb
28
29
  - lib/mortgagerb/version.rb
29
30
  - sig/mortgagerb.rbs