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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 725c9d6e6ea464bbba4bab1091b31f8264452ce0e2564b5243860dea72cc3063
4
- data.tar.gz: 35e7c5a4541001bab8771b2709efadbfbf9c0d6eaeaad91c15790514317a9567
3
+ metadata.gz: ad9895208b14b142735e195bfd2a47d661c1c8aff4b925eea7eb392672a049fd
4
+ data.tar.gz: 46593ca3f8f5e16412fe55284ff3152aa024c8b3672a675e88f412b9f9415883
5
5
  SHA512:
6
- metadata.gz: 1e6483106a879ceea62af861cac2a6af3764fc053dfa58df28dc2635a4d4e080463f51cd893a5299002a63f36f4d4e838e25a7683b5c513d024b8b3d0c519a27
7
- data.tar.gz: 693db9838645ecb58dfb014bb576f717ec2b3216ef1df694ac3af87dff6cf7eb55829926f0272600abfea10a0c31361552e618302809b76141d8b2004192e318
6
+ metadata.gz: 3a012829bd99b78637791f157dcddf56a5afa40482d69f4578107e0bb4156796ff09546677eda29982e6186014abfdfd024bc2e21644e55e5d3ef1c32db3828f
7
+ data.tar.gz: bed6e6939b7d186d7f8d696316eb0608fd0eca5c3a34b88fdac1f9e7452dc6fb3cdc7b1383db531087d34343c8c61ff3f63516cbb23a59a02d5ece0283d89ee8
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
- .idea
12
+ .idea
13
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kono_utils_helpers (0.1.0.pre.rc.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.1)
14
- activesupport (= 6.1.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.5.0)
19
+ active_type (1.6.0)
20
20
  activerecord (>= 3.2)
21
- activemodel (6.1.1)
22
- activesupport (= 6.1.1)
23
- activerecord (6.1.1)
24
- activemodel (= 6.1.1)
25
- activesupport (= 6.1.1)
26
- activesupport (6.1.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.7)
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.7)
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
- mini_portile2 (2.5.0)
43
- minitest (5.14.3)
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)
@@ -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 = Ptmpfile.new('nomefile.ext')
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 < ::Tempfile
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
- super(name, self.tmp_dir)
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
- unless File.exist?(::Rails.root.join(PATH))
63
- Dir.mkdir(::Rails.root.join(PATH))
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(::Rails.root.join(PATH))
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
- if d != '..' and d!='.'
74
- if d.to_i < Time.now.to_i-TIME_LIMIT
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
@@ -1,5 +1,3 @@
1
- require "kono_utils"
2
-
3
1
  require "zeitwerk"
4
2
  loader = Zeitwerk::Loader.for_gem
5
3
  loader.enable_reloading # you need to opt-in before setup
@@ -1,3 +1,3 @@
1
1
  module KonoUtilsHelpers
2
- VERSION = "0.1.0-rc.1"
2
+ VERSION = "0.1.1"
3
3
  end
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.0.pre.rc.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-01-18 00:00:00.000000000 Z
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: 1.3.1
155
+ version: '0'
156
156
  requirements: []
157
157
  rubygems_version: 3.0.8
158
158
  signing_key: