tmp 2.1.0 → 2.2.0

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: fc1456cbbe0bb30447c73afdca9f8af01405b477
4
- data.tar.gz: 3835bb393ee46825c863deafea76cc3414d3b1ee
3
+ metadata.gz: e66a42b973054f5d571c6e8732470f943fe5f005
4
+ data.tar.gz: 9dc2be715eec51546ddbb6d4cdfe4720c61a3580
5
5
  SHA512:
6
- metadata.gz: 670b014328b82c5d13d189dfe8c59294acfc6d858b65fc2980882841e67c5b012aeb239db82e2468efd91d7f6440ed2ff78ab0210ab662157d7932359263c416
7
- data.tar.gz: 3e63d13b47ad3782ea776b26ab7d916a83d8a1d41f59c99c0975aa4bd815d70a814960a50b68ef4dbd65ccf2a8e8460a9935c73e6b5a5aa323abc07ed5e40fd5
6
+ metadata.gz: f8ac7b605356c620670439776686854ab917c80223270619efaa88dc40bf642627e67a33ca6dba923f012b526c52350715711b623af3a9af31a31026b0105b8e
7
+ data.tar.gz: c54e7a1ed989f95dce5aa018323c0286ac394c892d3485b6e83b295f61953b8069e9119e4141d6c20e1bdd0a94ce61e8f1b3689b23d37bb097a4475b43d2c79f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tmp (2.1.0)
4
+ tmp (2.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -58,6 +58,14 @@ you can config the folder path for custom tmp folder use case if you dont want t
58
58
  # to check the current path use this
59
59
  TMP.folder_path #> return the current path
60
60
 
61
+ ```
62
+
63
+ ### Get file path for the tmp object
64
+
65
+ ```ruby
66
+
67
+
68
+
61
69
  ```
62
70
 
63
71
  ### Remove tmp objects
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
data/examples/path.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'tmp'
2
+
3
+ puts __TMP__.random #> nil or empty string because never used or just fresh inited file
4
+ puts __TMP__.random__path__ #> path to random named file,
5
+ # if not exist, make an empty one
@@ -6,10 +6,6 @@ puts TMP.read(:test2)
6
6
  #or you can use syntax sugar!
7
7
  tmp.hello= { hello: 'world'}
8
8
 
9
- tmp.hello do |hello|
10
- puts 'world'
11
- end
12
-
13
9
  # defined variable
14
10
  puts tmp.hello #> { hello: 'world'}
15
11
 
data/examples/test.rb CHANGED
@@ -1,7 +1,3 @@
1
1
  require 'tmp'
2
2
 
3
- __TMP__.test= {hello: "world"}
4
3
 
5
- puts __TMP__.test
6
- __TMP__.test= nil
7
- puts __TMP__.test.inspect
@@ -0,0 +1,3 @@
1
+ {:
2
+ helloI"
3
+ world:ET
data/lib/tmp/core.rb CHANGED
@@ -74,8 +74,23 @@ module TMP
74
74
  end
75
75
 
76
76
  File.open( File.join(tmp_folder_path,variable_name.to_s) ,"r") do |file|
77
- return ::Marshal.load file.read
77
+ begin
78
+ return ::Marshal.load file.read
79
+ rescue
80
+ return file.read
81
+ end
82
+ end
83
+
84
+ end
85
+
86
+ def path variable_name
87
+
88
+ tmp_folder_init
89
+ path_to_file= File.join(tmp_folder_path,variable_name.to_s)
90
+ unless File.exist?(path_to_file)
91
+ File.open( path_to_file ,"w")
78
92
  end
93
+ return path_to_file
79
94
 
80
95
  end
81
96
 
data/lib/tmp/dsl.rb CHANGED
@@ -12,10 +12,8 @@ module TMP
12
12
 
13
13
  def method_missing( method, *args, &block )
14
14
 
15
- @target_methods = [:write,:read,:file]
16
-
17
15
  if method.to_s.reverse[0] == '='
18
- target_obj.__send__ @target_methods[0], method.to_s.reverse.sub('=','').reverse, args.first
16
+ target_obj.__send__ :write, method.to_s.reverse.sub('=','').reverse, args.first
19
17
  return args.first
20
18
  else
21
19
 
@@ -31,12 +29,13 @@ module TMP
31
29
 
32
30
  else
33
31
 
34
- begin
35
- target_obj.__send__ @target_methods[1], method
36
- rescue TypeError
37
- File.open(File.join( target_obj.folder_path, method.to_s ),"r").read
32
+ if method =~ /^\w+__path__$/
33
+ return target_obj.__send__ :path, method.to_s.sub!( /__path__$/,"" )
34
+ else
35
+ return target_obj.__send__ :read, method
38
36
  end
39
37
 
38
+
40
39
  end
41
40
 
42
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -61,8 +61,10 @@ files:
61
61
  - examples/blocks.rb
62
62
  - examples/config_exmpl.rb
63
63
  - examples/instance.rb
64
+ - examples/path.rb
64
65
  - examples/sugar_use.rb
65
66
  - examples/test.rb
67
+ - examples/tmp_folder/hello
66
68
  - examples/tmp_folder/test
67
69
  - files.rb
68
70
  - lib/tmp.rb