atk_toolbox 0.0.44 → 0.0.45

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 611e37e313ff865ed41b1f515404248c93b6e0ec23689d14d45a573be375a300
4
- data.tar.gz: d4ca3c64baeb148ab735ab9c143647602118979236f2888d2785c15ff12728d1
3
+ metadata.gz: 99c34226e0e1d77b1616de7e5e16cce6a8496eb47fda2020fa76ee2597c62498
4
+ data.tar.gz: b0725578fae82ad3df7139e6a7fc546a664ab423aff7ec561d34e4dcb0628c04
5
5
  SHA512:
6
- metadata.gz: 0656a4f73e1f0e1aba9ee12edd07e0f599b93ece9c936caa08e85be69712096a6228b558f3d7422d05c0a1938f67dc22a0b2c39f8bd232924a1435bc8e08f787
7
- data.tar.gz: f40f8c9d8b9f2f44175888c20007cddb10555ad9435402504293ee543b9e3adb84b2abb9904974713c3925cf99fa238a96a5348bc410a3c4cdc7766c446ce693
6
+ metadata.gz: 1b2096e55bdc352c77064a619ea7ae813bda4d2afd49b022e32c2ebe1cfdcc71e6695ba28504f9f7b7517798f27401b050c2580a6fc8e44c82504cae79d4cb15
7
+ data.tar.gz: bf3a9017e56c9ff1b06698c2254162666a9b12533834e37fce980797eabb63b5906dcbbd7f06e87c076cccfbc01b8a49b2d24b8930370a0498db363ffff2da04
data/lib/atk/download.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'open-uri'
2
2
  require 'fileutils'
3
+ require_relative './extra_file_utils'
3
4
 
4
5
  def download(input_1=nil, from:nil, url:nil, as:nil)
5
6
  # argument checking
@@ -33,8 +34,5 @@ def download(input_1=nil, from:nil, url:nil, as:nil)
33
34
  raise message_
34
35
  end#if
35
36
  #end argument checking
36
- # make sure the containing folder exists
37
- FileUtils.makedirs(File.dirname(file_name))
38
- # actually download the file
39
- IO.write(file_name, open(the_url).read)
37
+ FileSys.write(open(URI.encode(the_url)).read, to: file_name)
40
38
  end
@@ -19,15 +19,40 @@ class String
19
19
  end
20
20
  end
21
21
 
22
-
23
- def in_dir(path_to_somewhere)
24
- # save the current working dir
25
- current_dir = Dir.pwd
26
- # switch dirs
27
- Dir.chdir(path_to_somewhere)
28
- # do the thing
29
- output = yield
30
- # switch back
31
- Dir.chdir(current_dir)
32
- return output
22
+ class FileSys
23
+ def self.in_dir(path_to_somewhere)
24
+ # save the current working dir
25
+ current_dir = Dir.pwd
26
+ # switch dirs
27
+ Dir.chdir(path_to_somewhere)
28
+ # do the thing
29
+ output = yield
30
+ # switch back
31
+ Dir.chdir(current_dir)
32
+ return output
33
+ end
34
+
35
+ def self.write(data, to:nil)
36
+ # make sure the containing folder exists
37
+ FileUtils.makedirs(File.dirname(to))
38
+ # actually download the file
39
+ IO.write(to, data)
40
+ end
41
+
42
+ def self.read(filepath)
43
+ begin
44
+ return IO.read(filepath)
45
+ rescue => exception
46
+ return nil
47
+ end
48
+ end
49
+
50
+ def self.delete(filepath)
51
+ begin
52
+ return File.delete(filepath)
53
+ # if file doesnt exist, thats fine
54
+ rescue Errno::ENOENT => exception
55
+ return nil
56
+ end
57
+ end
33
58
  end
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.44'
2
+ VERSION = '0.0.45'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atk_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.44
4
+ version: 0.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Hykin