kono_utils_helpers 0.1.0.pre.rc.1 → 0.1.1
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 +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +14 -16
- data/lib/kono_utils/tmp_file.rb +24 -13
- data/lib/kono_utils_helpers.rb +0 -2
- data/lib/kono_utils_helpers/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad9895208b14b142735e195bfd2a47d661c1c8aff4b925eea7eb392672a049fd
|
4
|
+
data.tar.gz: 46593ca3f8f5e16412fe55284ff3152aa024c8b3672a675e88f412b9f9415883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a012829bd99b78637791f157dcddf56a5afa40482d69f4578107e0bb4156796ff09546677eda29982e6186014abfdfd024bc2e21644e55e5d3ef1c32db3828f
|
7
|
+
data.tar.gz: bed6e6939b7d186d7f8d696316eb0608fd0eca5c3a34b88fdac1f9e7452dc6fb3cdc7b1383db531087d34343c8c61ff3f63516cbb23a59a02d5ece0283d89ee8
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kono_utils_helpers (0.1.
|
4
|
+
kono_utils_helpers (0.1.1)
|
5
5
|
actionview
|
6
6
|
active_type
|
7
7
|
activesupport (>= 4.2)
|
@@ -10,39 +10,37 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionview (6.1.
|
14
|
-
activesupport (= 6.1.
|
13
|
+
actionview (6.1.3)
|
14
|
+
activesupport (= 6.1.3)
|
15
15
|
builder (~> 3.1)
|
16
16
|
erubi (~> 1.4)
|
17
17
|
rails-dom-testing (~> 2.0)
|
18
18
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
19
|
-
active_type (1.
|
19
|
+
active_type (1.6.0)
|
20
20
|
activerecord (>= 3.2)
|
21
|
-
activemodel (6.1.
|
22
|
-
activesupport (= 6.1.
|
23
|
-
activerecord (6.1.
|
24
|
-
activemodel (= 6.1.
|
25
|
-
activesupport (= 6.1.
|
26
|
-
activesupport (6.1.
|
21
|
+
activemodel (6.1.3)
|
22
|
+
activesupport (= 6.1.3)
|
23
|
+
activerecord (6.1.3)
|
24
|
+
activemodel (= 6.1.3)
|
25
|
+
activesupport (= 6.1.3)
|
26
|
+
activesupport (6.1.3)
|
27
27
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
28
|
i18n (>= 1.6, < 2)
|
29
29
|
minitest (>= 5.1)
|
30
30
|
tzinfo (~> 2.0)
|
31
31
|
zeitwerk (~> 2.3)
|
32
32
|
builder (3.2.4)
|
33
|
-
concurrent-ruby (1.1.
|
33
|
+
concurrent-ruby (1.1.8)
|
34
34
|
crass (1.0.6)
|
35
35
|
diff-lcs (1.3)
|
36
36
|
erubi (1.10.0)
|
37
|
-
i18n (1.8.
|
37
|
+
i18n (1.8.9)
|
38
38
|
concurrent-ruby (~> 1.0)
|
39
39
|
loofah (2.9.0)
|
40
40
|
crass (~> 1.0.2)
|
41
41
|
nokogiri (>= 1.5.9)
|
42
|
-
|
43
|
-
|
44
|
-
nokogiri (1.11.1)
|
45
|
-
mini_portile2 (~> 2.5.0)
|
42
|
+
minitest (5.14.4)
|
43
|
+
nokogiri (1.11.1-x86_64-linux)
|
46
44
|
racc (~> 1.4)
|
47
45
|
racc (1.5.2)
|
48
46
|
rails-dom-testing (2.0.3)
|
data/lib/kono_utils/tmp_file.rb
CHANGED
@@ -12,21 +12,21 @@ module KonoUtils
|
|
12
12
|
# la prossima volta che viene chiamata cancellando tutti i files con un TTL
|
13
13
|
# maggiore di 1.day di default
|
14
14
|
## Utilizzo:
|
15
|
-
# tmp =
|
15
|
+
# tmp = TmpFile.new('nomefile.ext')
|
16
16
|
# tmp.path -> path completa
|
17
17
|
# tmp.write.....
|
18
18
|
# tmp.original_filename.......
|
19
19
|
# tmp.unique_filename.......
|
20
20
|
#
|
21
21
|
#
|
22
|
-
class TmpFile
|
22
|
+
class TmpFile
|
23
23
|
|
24
24
|
PATH = 'tmp/ptmpfile'
|
25
|
-
TIME_LIMIT = 1*60*60*24 # 1day
|
25
|
+
TIME_LIMIT = 1 * 60 * 60 * 24 # 1day
|
26
26
|
attr_accessor :root_dir
|
27
27
|
attr_accessor :tmp_dir
|
28
28
|
attr_accessor :original_filename, :unique_filename
|
29
|
-
|
29
|
+
attr_accessor :tmp_file
|
30
30
|
|
31
31
|
##
|
32
32
|
# Generate a new file with a given name
|
@@ -37,18 +37,21 @@ module KonoUtils
|
|
37
37
|
# - Tempfile
|
38
38
|
#
|
39
39
|
def initialize(name)
|
40
|
-
self.original_filename=name
|
40
|
+
self.original_filename = name
|
41
41
|
self.root_dir = controll_root
|
42
42
|
clean_tmpdir
|
43
43
|
#creo una nuova cartella per il file attuale
|
44
|
-
self.tmp_dir= "#{self.root_dir.path}/#{Time.now.to_f}"
|
44
|
+
self.tmp_dir = "#{self.root_dir.path}/#{Time.now.to_f}"
|
45
45
|
Dir.mkdir(self.tmp_dir)
|
46
|
-
ext =File.extname(name)
|
46
|
+
ext = File.extname(name)
|
47
47
|
name = [File.basename(name), ext] unless ext.blank?
|
48
|
-
|
48
|
+
|
49
|
+
@tmp_file = Tempfile.create(name, self.tmp_dir)
|
50
|
+
|
49
51
|
self.unique_filename= File.basename(self.path)
|
50
52
|
end
|
51
53
|
|
54
|
+
delegate_missing_to :@tmp_file
|
52
55
|
|
53
56
|
private
|
54
57
|
|
@@ -59,10 +62,17 @@ module KonoUtils
|
|
59
62
|
# - Dir
|
60
63
|
#
|
61
64
|
def controll_root
|
62
|
-
|
63
|
-
|
65
|
+
root = '/'
|
66
|
+
if defined?("::Rails")
|
67
|
+
if Rails.respond_to?(:root)
|
68
|
+
root = ::Rails.root
|
69
|
+
end
|
70
|
+
end
|
71
|
+
root = File.join(root, PATH)
|
72
|
+
unless File.exist?(root)
|
73
|
+
Dir.mkdir(root)
|
64
74
|
end
|
65
|
-
Dir.open(
|
75
|
+
Dir.open(root)
|
66
76
|
end
|
67
77
|
|
68
78
|
##
|
@@ -70,8 +80,9 @@ module KonoUtils
|
|
70
80
|
#
|
71
81
|
def clean_tmpdir
|
72
82
|
self.root_dir.each do |d|
|
73
|
-
|
74
|
-
|
83
|
+
# controlliamo il nome del file. in quanto il nome del file coincide al Time.now
|
84
|
+
if d != '..' and d != '.'
|
85
|
+
if d.to_i < Time.now.to_i - TIME_LIMIT
|
75
86
|
FileUtils.rm_rf(File.join(self.root_dir.path, d))
|
76
87
|
end
|
77
88
|
end
|
data/lib/kono_utils_helpers.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kono_utils_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marino Bonetti
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_type
|
@@ -150,9 +150,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- - "
|
153
|
+
- - ">="
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
155
|
+
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubygems_version: 3.0.8
|
158
158
|
signing_key:
|