tmp 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e10614c8749f3942598c9d559b2480bff634f60
4
- data.tar.gz: 930e5474223903a4e981df6d5adac55794fdbf33
3
+ metadata.gz: d2c4583f9a0ad5d637c86599e899683e32e04064
4
+ data.tar.gz: 78a850e70984c24070774e3f087f3a1b9de3f920
5
5
  SHA512:
6
- metadata.gz: 5dcab98b0ca139c615c3249544032f05ca8ef4416fb8579c81251bd0319c4a251ac8a75af9220ada97e3e6ff0fe18a51c209b6fdfec266dbec5622264931cbb9
7
- data.tar.gz: 8d9a38ec424dc5a282a19bd4a712851901dbf216e005559b61ec574bd0d6a9d0aabc8754172dd9bbf223bad64146c8738f0c67c1943a1cc7b90545a0cf340a32
6
+ metadata.gz: c6dea5f08e6761b1f30844980e004595b743c9983edf7e535a696231163ffc09469d0f73aef6490c696947f03278a7bc45fd3265038decb7b07463b0a6cab4c5
7
+ data.tar.gz: 669aa2f80a54b5c02f62c3291364ecf64e587a2147b2514c4476510c76a780dcc40ed39b203bf9dbf63b8de4d61eeea3a1932cdb0bfc7284270b1b637c727a8c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tmp (2.2.1)
4
+ tmp (2.2.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -80,15 +80,14 @@ you can remove tmp objects by purge them
80
80
 
81
81
  require 'tmp'
82
82
 
83
- tmp.hello = { hello: 'world'}
83
+ __tmp__.hello = { hello: 'world'}
84
84
 
85
- # now it's set
86
- tmp.hello #> { hello: 'world'} -> hash obj
85
+ __tmp__.hello #> { hello: 'world'} -> hash obj
87
86
 
88
87
  TMP.purge!
89
88
 
90
89
  # now it's nil
91
- tmp.hello #> nil
90
+ __tmp__.hello #> nil
92
91
 
93
92
  ```
94
93
 
@@ -100,7 +99,6 @@ if you want use as an instance for example for your very own module, than you ca
100
99
 
101
100
  require 'tmp'
102
101
 
103
-
104
102
  tmp_instance= TMP.new( File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder')) )
105
103
 
106
104
  # use the same as the TMP::DSL aka tmp method
@@ -118,7 +116,7 @@ if you want use as an instance for example for your very own module, than you ca
118
116
  tmp_instance.tmp_class_instance_object.folder_path
119
117
 
120
118
  # Remember this instance use different folder thant the main TMP::DSL
121
- tmp.test.inspect #> nil, because it was never used before
119
+ __tmp__.test.inspect #> nil, because it was never used before
122
120
  #> the tmp method is same like invoke the TMP::DSL module
123
121
 
124
122
 
@@ -134,12 +132,12 @@ using blocks is nothing like cupcake in Ruby, and just alike in this dsl
134
132
  require 'tmp'
135
133
 
136
134
  # using blocks is simply as this
137
- tmp.some_file_name do |file|
135
+ __tmp__.some_file_name do |file|
138
136
  file.write Random.rand(100...1000)
139
137
  end
140
138
 
141
139
  # reopen the new file is also simple
142
- tmp.some_file_name do |file|
140
+ __tmp__.some_file_name do |file|
143
141
 
144
142
  while line = file.gets
145
143
  puts line
@@ -150,7 +148,7 @@ using blocks is nothing like cupcake in Ruby, and just alike in this dsl
150
148
  end
151
149
 
152
150
  # you can set the file mod if you like, by default it's based on file e
153
- tmp.some_file_name "w+" do |file|
151
+ __tmp__.some_file_name "w+" do |file|
154
152
 
155
153
  while line = file.gets
156
154
  puts line
@@ -161,7 +159,24 @@ using blocks is nothing like cupcake in Ruby, and just alike in this dsl
161
159
 
162
160
  end
163
161
 
164
- puts tmp.some_file_name #> it's a string from the file we made
162
+ puts __tmp__.some_file_name #> it's a string from the file we made
163
+
164
+ ```
165
+
166
+ ### Miscs
167
+
168
+ ```ruby
169
+
170
+ __tmp__.tmpdir #> system temp folder
171
+
172
+ __tmp__.project_folder #> folder name where the project is
173
+ #> alias: project_name
174
+
175
+ __tmp__.default_folder_path #> path to the default tmp folder
176
+
177
+ __tmp__.tmp_folder_path #> path to the now used tmp folder
178
+ #> it is resettable by passing a string to the method
179
+ #> alias: folder_path
165
180
 
166
181
  ```
167
182
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 2.2.2
@@ -1,3 +1,6 @@
1
1
  require 'tmp'
2
+ require 'securerandom'
2
3
 
3
-
4
+ tmp= TMP.new File.join TMP.tmpdir,SecureRandom.uuid
5
+ $stdout.reopen tmp.test__path__
6
+ puts "hello world"
@@ -19,12 +19,18 @@ module TMP
19
19
 
20
20
  end
21
21
 
22
+ alias :project_folder :project_name
23
+
24
+ def tmpdir
25
+ ::Dir.tmpdir
26
+ end
27
+
22
28
  def default_folder_path
23
- File.join( Dir.tmpdir , project_name )
29
+ File.join( tmpdir , project_name )
24
30
  end
25
31
 
26
32
  @folder_path= nil
27
- def folder_path path_string= nil
33
+ def tmp_folder_path path_string= nil
28
34
 
29
35
  unless path_string.nil?
30
36
 
@@ -40,7 +46,7 @@ module TMP
40
46
 
41
47
  end
42
48
 
43
- alias :tmp_folder_path :folder_path
49
+ alias :folder_path :tmp_folder_path
44
50
 
45
51
  def tmp_folder_init
46
52
 
@@ -103,7 +109,7 @@ module TMP
103
109
  tmp_folder_init
104
110
  path_to_file= File.join(tmp_folder_path,variable_name.to_s)
105
111
  unless File.exist?(path_to_file)
106
- File.open( path_to_file ,"w")
112
+ File.open( path_to_file ,"w") {|f| f.write(""); f.close }
107
113
  end
108
114
  return path_to_file
109
115
 
@@ -49,12 +49,13 @@ module TMP
49
49
 
50
50
  module SyntaxSugar
51
51
 
52
- def tmp
52
+ def __tmp__
53
53
  ::TMP::DSL
54
54
  end
55
55
 
56
- alias :__TMP__ :tmp
57
- alias :__tmp__ :tmp
56
+ alias :__TMP__ :__tmp__
57
+
58
+ alias :tmp :__tmp__
58
59
 
59
60
  end
60
61
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi