tmp 2.2.1 → 2.2.2
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/Gemfile.lock +1 -1
- data/README.md +25 -10
- data/VERSION +1 -1
- data/examples/test.rb +4 -1
- data/lib/tmp/core.rb +10 -4
- data/lib/tmp/dsl.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2c4583f9a0ad5d637c86599e899683e32e04064
|
4
|
+
data.tar.gz: 78a850e70984c24070774e3f087f3a1b9de3f920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6dea5f08e6761b1f30844980e004595b743c9983edf7e535a696231163ffc09469d0f73aef6490c696947f03278a7bc45fd3265038decb7b07463b0a6cab4c5
|
7
|
+
data.tar.gz: 669aa2f80a54b5c02f62c3291364ecf64e587a2147b2514c4476510c76a780dcc40ed39b203bf9dbf63b8de4d61eeea3a1932cdb0bfc7284270b1b637c727a8c
|
data/Gemfile.lock
CHANGED
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
|
-
|
83
|
+
__tmp__.hello = { hello: 'world'}
|
84
84
|
|
85
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
+
2.2.2
|
data/examples/test.rb
CHANGED
data/lib/tmp/core.rb
CHANGED
@@ -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(
|
29
|
+
File.join( tmpdir , project_name )
|
24
30
|
end
|
25
31
|
|
26
32
|
@folder_path= nil
|
27
|
-
def
|
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 :
|
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
|
|
data/lib/tmp/dsl.rb
CHANGED