easy_io 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/easy_io/disk.rb +30 -42
  3. data/lib/easy_io.rb +1 -1
  4. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b4ea31cfbbe102e2b9d4e14097c33da21c70e4de3b1a6b599c872503fd37741
4
- data.tar.gz: d1df2063b2e92d513a37a9c14a0749c30586eb0f3fc7729100ddf7bd8add3b4b
3
+ metadata.gz: d46961a39a7863a0280667c35b02284d8ca3b7bcd735f88e44c3dffb8b2b15c4
4
+ data.tar.gz: b3a4cead726774f3a652e752e82557fc46c495d09d7ba6d61c0edd5e334367f5
5
5
  SHA512:
6
- metadata.gz: 569f125fb4826b3db31d6d8e54e9e19ca8ab3d493a02d937197be114896ebb15314ef5e10a9459b0492dac904be8f2d45679d28eceae0df25482d38f584b5020
7
- data.tar.gz: 8f5b5e0d8e5e28140c32a1f268cc3b8db9364fb51c33d90ed40ef2c54606967f15c55c037c1eb9fb9827c98cebce1ffd83ea0c3c55416bbfd6cce7c040e39ca3
6
+ metadata.gz: 748cf34c8bb70f806f59d73699002f926038bd3a4329d400969d3c4a90627101ba0c95eb44d6a2269eab22b3b880676eebad782fc72a0ed906284fe91cd0ee47
7
+ data.tar.gz: 9b256811b2114bf57c8001a9d65e9ea4988d9ac242ca49a128017fe3c000bae3026611236d72657b7472a79fee043e0b27051ee55d51aace8595068afab76e8c
data/lib/easy_io/disk.rb CHANGED
@@ -1,9 +1,5 @@
1
1
  module EasyIO
2
2
  module Disk
3
- unless defined? GetDiskFreeSpaceEx
4
- GetDiskFreeSpaceEx = Win32API.new('kernel32', 'GetDiskFreeSpaceEx', 'PPPP', 'I') if OS.windows? # TODO: make this cross platform. sys-filesystem gem maybe?
5
- end
6
-
7
3
  module_function
8
4
 
9
5
  def free_space(path)
@@ -13,11 +9,7 @@ module EasyIO
13
9
  raise "Cannot check free space for #{path} - The path was not found." if root_folder.nil? || root_folder.empty?
14
10
  root_folder = EasyFormat::Directory.ensure_trailing_slash(root_folder)
15
11
 
16
- free = [0].pack('Q')
17
- GetDiskFreeSpaceEx.call(root_folder, 0, 0, free)
18
- free = free.unpack1('Q')
19
-
20
- (free / 1024.0 / 1024.0).round(2)
12
+ (Sys::Filesystem.stat(root_folder).bytes_free / 1024.0 / 1024.0).round(2)
21
13
  end
22
14
 
23
15
  def size(path)
@@ -27,11 +19,7 @@ module EasyIO
27
19
  raise "Cannot check free space for #{path} - The path was not found." if root_folder.nil? || root_folder.empty?
28
20
  root_folder = EasyFormat::Directory.ensure_trailing_slash(root_folder)
29
21
 
30
- total = [0].pack('Q')
31
- GetDiskFreeSpaceEx.call(root_folder, 0, total, 0)
32
- total = total.unpack1('Q')
33
-
34
- (total / 1024.0 / 1024.0).round(2)
22
+ (Sys::Filesystem.stat(root_folder).bytes_total / 1024.0 / 1024.0).round(2)
35
23
  end
36
24
 
37
25
  def move_files(search_string, destination_folder)
@@ -81,33 +69,33 @@ module EasyIO
81
69
  end
82
70
  end
83
71
 
84
- # When credentials are nil, the current user will be used
85
- def cross_domain_copy(source_folder, destination_folder, source_credentials: nil, destination_credentials: nil, file_filter: '*')
86
- # require 'win32/process'
87
- Dir.glob("#{source_folder}/#{file_filter}").each do |source_entry|
88
- destination_entry = source_entry.sub(source_folder, destination_folder)
89
- _cross_domain_entry_copy(source_entry, destination_entry, source_credentials: source_credentials, destination_credentials: destination_credentials)
90
- end
91
- end
92
-
93
- def _cross_domain_entry_copy(source_entry, destination_entry, source_credentials: nil, destination_credentials: nil)
94
- source_credentials ||= :current_user
95
- destination_credentials ||= :current_user
96
-
97
- # TODO: loop and read to async buffer and write as it goes
98
- if source_credentials == :current_user
99
- # TODO: read to memeory
100
- else
101
- Process.create(command_line: ?, domain: source_credentials['domain'], with_logon: source_credentials['user_name'], password: source_credentials['password'])
102
- # TODO: read to memory
103
- end
104
-
105
- if destination_credentials == :current_user
106
- # TODO: write from memory
107
- else
108
- Process.create(etc)
109
- # TODO: write from memory
110
- end
111
- end
72
+ # # When credentials are nil, the current user will be used
73
+ # def cross_domain_copy(source_folder, destination_folder, source_credentials: nil, destination_credentials: nil, file_filter: '*')
74
+ # # require 'win32/process'
75
+ # Dir.glob("#{source_folder}/#{file_filter}").each do |source_entry|
76
+ # destination_entry = source_entry.sub(source_folder, destination_folder)
77
+ # _cross_domain_entry_copy(source_entry, destination_entry, source_credentials: source_credentials, destination_credentials: destination_credentials)
78
+ # end
79
+ # end
80
+
81
+ # def _cross_domain_entry_copy(source_entry, destination_entry, source_credentials: nil, destination_credentials: nil)
82
+ # source_credentials ||= :current_user
83
+ # destination_credentials ||= :current_user
84
+
85
+ # # TODO: loop and read to async buffer and write as it goes
86
+ # if source_credentials == :current_user
87
+ # # TODO: read to memeory
88
+ # else
89
+ # Process.create(command_line: ?, domain: source_credentials['domain'], with_logon: source_credentials['user_name'], password: source_credentials['password'])
90
+ # # TODO: read to memory
91
+ # end
92
+
93
+ # if destination_credentials == :current_user
94
+ # # TODO: write from memory
95
+ # else
96
+ # Process.create(etc)
97
+ # # TODO: write from memory
98
+ # end
99
+ # end
112
100
  end
113
101
  end
data/lib/easy_io.rb CHANGED
@@ -23,9 +23,9 @@ require 'fileutils'
23
23
  require 'tmpdir'
24
24
  require 'os'
25
25
  require 'digest'
26
+ require 'sys/filesystem'
26
27
  if OS.windows?
27
28
  require 'win32/registry'
28
- require 'win32api'
29
29
  end
30
30
 
31
31
  require_relative 'easy_io/config'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Munoz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: easy_format
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sys-filesystem
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1'
69
83
  description:
70
84
  email:
71
85
  - amunoz951@gmail.com
@@ -100,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
114
  - !ruby/object:Gem::Version
101
115
  version: '0'
102
116
  requirements: []
103
- rubygems_version: 3.0.3
117
+ rubygems_version: 3.0.3.1
104
118
  signing_key:
105
119
  specification_version: 4
106
120
  summary: Ruby library for ease of running commands with realtime output and return