Skip to content

Commit

Permalink
Merge pull request #33 from tbeason/nohttp
Browse files Browse the repository at this point in the history
use Downloads, rm HTTP
  • Loading branch information
tbeason authored Sep 5, 2021
2 parents 2641661 + bbb0e41 commit 04705d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name = "FamaFrenchData"
uuid = "bd2a388e-9788-4ef7-9fc3-f4c919ffde82"
authors = ["Tyler Beason <tbeas12@gmail.com>"]
version = "0.3.1"
version = "0.4.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[compat]
CSV = "^0.7.6, 0.8"
DataFrames = "0.19.4, 0.20, 0.21, 0.22, 1"
HTTP = "^0.8.11, 0.9"
ZipFile = "0.8.4, 0.9"
julia = "^1.3"

Expand Down
13 changes: 9 additions & 4 deletions src/FamaFrenchData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Julia package for easy access to the Ken French Data Library files. See `readFam
"""
module FamaFrenchData

using HTTP
using Downloads
using CSV
using ZipFile
using DataFrames
Expand Down Expand Up @@ -31,7 +31,8 @@ Returns three pieces:
"""
function readFamaFrench(ffn;kwargs...)
if !isfile(ffn)
io = IOBuffer(HTTP.get(pathtoFamaFrench(ffn)).body)
io = IOBuffer()
Downloads.download(pathtoFamaFrench(ffn),io)
z = ZipFile.Reader(io)
ff = first(z.files)
else
Expand All @@ -52,7 +53,8 @@ Saves the extracted CSV file from `ffn` to local file `savename`.
"""
function downloadFamaFrench(savename,ffn)
open(savename,"w") do f
io = IOBuffer(HTTP.get(pathtoFamaFrench(ffn)).body)
io = IOBuffer()
Downloads.download(pathtoFamaFrench(ffn),io)
z = ZipFile.Reader(io)
ff = first(z.files)
for s in readlines(ff)
Expand All @@ -77,7 +79,10 @@ function listFamaFrench(;refresh::Bool = false)
if refresh
# grabs filenames from website
wname = "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html"
hs=String(HTTP.request("GET",wname).body)
io = IOBuffer()
Downloads.download(wname,io)
hs = String(take!(io))
close(io)
regx = r"(?<=ftp\/)(.*)(?=_CSV)"
res=collect(eachmatch(regx,hs))
nms = getfield.(res,:match)
Expand Down

2 comments on commit 04705d9

@tbeason
Copy link
Owner Author

@tbeason tbeason commented on 04705d9 Sep 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Now using Downloads.jl standard library instead of the larger HTTP.jl package.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/44251

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" 04705d9da17e8e39b2d12dbff32f8415282807f1
git push origin v0.4.0

Please sign in to comment.