tmp 1.2.0 → 1.3.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: 7f2a68461818e0e518c1c70d060bc98c72882b45
4
- data.tar.gz: e603aa012691e5b0bf991b9f4409ddd96e8c1ee6
3
+ metadata.gz: 055f0f73e75681b686ca70e9f0f1d14a5a5e538e
4
+ data.tar.gz: 59134acb4673a4e3db9cab1ef9e62774dbf6f350
5
5
  SHA512:
6
- metadata.gz: dd9ca18c8d93f99268bb5b48be214b517c70860ce181275d15a95045313acd27115f2c87a32d75a4f5c6803dad99cad05805d13c2db8853cc05eb7fec82642ff
7
- data.tar.gz: 84376beb47f7190032e41982e22312a106cef4854618b8d3ca2fc1b26dc72f19dc731494a4eaf1d9e34d8f778b0dcbeb1c99612719b46b05a7c7fdf4475ef10d
6
+ metadata.gz: 4723c10dd21a5c3fb86d7a08cd6eeafa7d0d4508114642b0e2fd98c9b7d3d20c4d5a9194d6d9640c5f78cbddeb0adb984bec4d7c3d91470c3fb2dea3da9e9cb1
7
+ data.tar.gz: e76e9e3553c2103edaed60a65741a14e5a7a6e7864fc67a649a6490890bfa792bf96ad10a74f642cb34bfa31538223dd27d137942e2a524c234739f26089eefe
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tmp (1.2.0)
4
+ tmp (1.3.0)
5
5
  empty_object
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -68,13 +68,16 @@ if you want use as an instance for example for your very own module, than you ca
68
68
 
69
69
  require 'tmp'
70
70
 
71
- # set the folder path at initialize
72
- tmp_instance= TMP::Instance.new( File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder')) )
71
+ tmp_instance= TMP.new( File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder')) )
73
72
 
74
- tmp_instance.write :test, {hello: 'world'}
73
+ tmp_instance.test= "hello"
75
74
 
76
- puts tmp_instance.read :test
77
- puts TMP.read(:test) #> must be nil
75
+ # get the instance test variable
76
+ puts tmp_instance.test.inspect #> this must be "hello"
77
+
78
+ # get the main TMP test variable
79
+ puts tmp.test.inspect #> must be nil because it was never used before
80
+ #> same as TMP::DSL.test.inspect
78
81
 
79
82
  ```
80
83
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -1,8 +1,12 @@
1
1
  require 'tmp'
2
2
 
3
- tmp_instance= TMP::Instance.new( File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder')) )
3
+ tmp_instance= TMP.new( File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder')) )
4
4
 
5
- tmp_instance.write :test, {hello: 'world'}
5
+ tmp_instance.test= "hello"
6
6
 
7
- puts tmp_instance.read :test
8
- puts TMP.read(:test) #> must be nil
7
+ # get the instance test variable
8
+ puts tmp_instance.test.inspect #> this must be "hello"
9
+
10
+ # get the main TMP test variable
11
+ puts tmp.test.inspect #> must be nil because it was never used before
12
+ #> same as TMP::DSL.test.inspect
@@ -1,3 +1,2 @@
1
- {:
2
- helloI"
3
- world:ET
1
+ I"
2
+ hello:ET
data/lib/tmp.rb CHANGED
@@ -3,8 +3,6 @@
3
3
  require 'tmpdir'
4
4
  require 'empty_object'
5
5
 
6
- require 'tmp/config'
7
- require 'tmp/function'
6
+ require 'tmp/core'
8
7
  require 'tmp/dsl'
9
-
10
- require 'tmp/instance'
8
+ require 'tmp/init'
@@ -1,36 +1,40 @@
1
1
  #encoding: UTF-8
2
2
  module TMP
3
3
 
4
- module SupportCore
4
+ module CORE
5
5
 
6
- def tmp_folder_path obj=nil
7
- @tmp_folder_path ||= obj
8
- @tmp_folder_path || ::TMP::Config.folder_path
6
+ def default_folder_path
7
+ File.join( Dir.tmpdir, ( Dir.pwd.split(File::Separator).last.to_s ) )
9
8
  end
10
9
 
11
- alias :folder_path :tmp_folder_path
10
+ @folder_path= nil
11
+ def folder_path path_string= nil
12
12
 
13
- def tmp_folder_init
13
+ unless path_string.nil?
14
14
 
15
- begin
15
+ unless path_string.class <= String
16
+ raise ArgumentError,"invalid path class, must be string like"
17
+ end
16
18
 
17
- Dir.mkdir tmp_folder_path
18
- return true
19
+ @folder_path = File.absolute_path(path_string)
19
20
 
20
- rescue Errno::EEXIST
21
- return false
22
21
  end
23
22
 
23
+ @folder_path || default_folder_path
24
+
24
25
  end
25
26
 
26
- def read_buffer path
27
+ alias :tmp_folder_path :folder_path
27
28
 
28
- comm_line= File.open(path,"r")
29
+ def tmp_folder_init
29
30
 
30
- read_buffer = ::Thread.new do
31
- while !comm_line.eof?
32
- @value = ::Marshal.load( comm_line )
33
- end
31
+ begin
32
+
33
+ Dir.mkdir tmp_folder_path
34
+ return true
35
+
36
+ rescue Errno::EEXIST
37
+ return false
34
38
  end
35
39
 
36
40
  end
@@ -70,29 +74,11 @@ module TMP
70
74
 
71
75
  end
72
76
 
73
- end
74
-
75
- module Support
76
- extend SupportCore
77
- end
78
-
79
- class << self
80
-
81
- def write(*args)
82
- self::Support.write(*args)
83
- end
84
-
85
- def read(*args)
86
- self::Support.read(*args)
87
- end
88
-
89
- def purge!
90
- self::Support.purge_files
91
- end
92
-
93
- alias :purge :purge!
77
+ alias :purge! :purge_files
78
+ alias :purge :purge_files
94
79
 
95
80
  end
96
81
 
82
+ extend CORE
97
83
 
98
84
  end
@@ -1,18 +1,23 @@
1
1
  #encoding: UTF-8
2
2
  module TMP
3
3
 
4
- class DSL < ::EmptyObject
5
- class << self
6
- def method_missing(method, *args)
4
+ module DSLCore
7
5
 
8
- if method.to_s.include?('=')
9
- ::TMP.write method.to_s.gsub('=',''), args.first
10
- else
11
- ::TMP.read(method)
12
- end
6
+ def method_missing( method, *args )
7
+ @class_name ||= ::TMP
13
8
 
9
+ if method.to_s.include?('=')
10
+ @class_name.write( method.to_s.gsub('=',''), args.first )
11
+ else
12
+ @class_name.read( method )
14
13
  end
14
+
15
15
  end
16
+
17
+ end
18
+
19
+ class DSL < ::EmptyObject
20
+ extend DSLCore
16
21
  end
17
22
 
18
23
  module SyntaxSugar
@@ -0,0 +1,39 @@
1
+ #encoding: UTF-8
2
+ module TMP
3
+
4
+ class InstanceCore
5
+
6
+ include CORE
7
+
8
+ def initialize path_string
9
+
10
+ unless path_string.class <= String
11
+ raise ArgumentError, "path must be a string like type"
12
+ end
13
+
14
+ tmp_folder_path path_string
15
+
16
+ end
17
+
18
+ end
19
+
20
+ class InstanceDSL < ::EmptyObject
21
+ include DSLCore
22
+
23
+ def initialize path_string
24
+ @class_name = InstanceCore.new path_string
25
+ end
26
+
27
+ end
28
+
29
+ class << self
30
+
31
+ def new *args
32
+ InstanceDSL.new *args
33
+ end
34
+
35
+ alias :init :new
36
+
37
+ end
38
+
39
+ end
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: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
@@ -74,10 +74,9 @@ files:
74
74
  - examples/tmp_folder/test
75
75
  - files.rb
76
76
  - lib/tmp.rb
77
- - lib/tmp/config.rb
77
+ - lib/tmp/core.rb
78
78
  - lib/tmp/dsl.rb
79
- - lib/tmp/function.rb
80
- - lib/tmp/instance.rb
79
+ - lib/tmp/init.rb
81
80
  - tmp.gemspec
82
81
  homepage: https://github.com/adamluzsi/tmp
83
82
  licenses:
@@ -1,37 +0,0 @@
1
- #encoding: UTF-8
2
- module TMP
3
-
4
- module ConfigCore
5
-
6
- def default_folder_path
7
- File.join( Dir.tmpdir, ( Dir.pwd.split(File::Separator).last.to_s ) )
8
- end
9
-
10
- @config_path= nil
11
- def folder_path path= nil
12
-
13
- unless path.nil?
14
-
15
- unless path.class <= String
16
- raise ArgumentError,"invalid path class"
17
- end
18
-
19
- @config_path = File.absolute_path(path)
20
-
21
- end
22
-
23
- @config_path || default_folder_path
24
-
25
- end
26
-
27
- end
28
-
29
- module Config
30
- extend ConfigCore
31
- end
32
-
33
- def self.folder_path obj
34
- self::Config.folder_path(obj)
35
- end
36
-
37
- end
@@ -1,21 +0,0 @@
1
- #encoding: UTF-8
2
- module TMP
3
-
4
- class Instance
5
-
6
- include ConfigCore
7
- include SupportCore
8
-
9
- def initialize path_string
10
-
11
- unless path_string.class <= String
12
- raise ArgumentError, "path must be a string like type"
13
- end
14
-
15
- tmp_folder_path path_string
16
-
17
- end
18
-
19
- end
20
-
21
- end