tmp 1.2.0 → 1.3.0
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 +8 -5
- data/VERSION +1 -1
- data/examples/instance.rb +8 -4
- data/examples/tmp_folder/test +2 -3
- data/lib/tmp.rb +2 -4
- data/lib/tmp/{function.rb → core.rb} +24 -38
- data/lib/tmp/dsl.rb +13 -8
- data/lib/tmp/init.rb +39 -0
- metadata +3 -4
- data/lib/tmp/config.rb +0 -37
- data/lib/tmp/instance.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 055f0f73e75681b686ca70e9f0f1d14a5a5e538e
|
4
|
+
data.tar.gz: 59134acb4673a4e3db9cab1ef9e62774dbf6f350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4723c10dd21a5c3fb86d7a08cd6eeafa7d0d4508114642b0e2fd98c9b7d3d20c4d5a9194d6d9640c5f78cbddeb0adb984bec4d7c3d91470c3fb2dea3da9e9cb1
|
7
|
+
data.tar.gz: e76e9e3553c2103edaed60a65741a14e5a7a6e7864fc67a649a6490890bfa792bf96ad10a74f642cb34bfa31538223dd27d137942e2a524c234739f26089eefe
|
data/Gemfile.lock
CHANGED
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
|
-
|
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.
|
73
|
+
tmp_instance.test= "hello"
|
75
74
|
|
76
|
-
|
77
|
-
puts
|
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.
|
1
|
+
1.3.0
|
data/examples/instance.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'tmp'
|
2
2
|
|
3
|
-
tmp_instance= TMP
|
3
|
+
tmp_instance= TMP.new( File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder')) )
|
4
4
|
|
5
|
-
tmp_instance.
|
5
|
+
tmp_instance.test= "hello"
|
6
6
|
|
7
|
-
|
8
|
-
puts
|
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
|
data/examples/tmp_folder/test
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
world:ET
|
1
|
+
I"
|
2
|
+
hello:ET
|
data/lib/tmp.rb
CHANGED
@@ -1,36 +1,40 @@
|
|
1
1
|
#encoding: UTF-8
|
2
2
|
module TMP
|
3
3
|
|
4
|
-
module
|
4
|
+
module CORE
|
5
5
|
|
6
|
-
def
|
7
|
-
|
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
|
-
|
10
|
+
@folder_path= nil
|
11
|
+
def folder_path path_string= nil
|
12
12
|
|
13
|
-
|
13
|
+
unless path_string.nil?
|
14
14
|
|
15
|
-
|
15
|
+
unless path_string.class <= String
|
16
|
+
raise ArgumentError,"invalid path class, must be string like"
|
17
|
+
end
|
16
18
|
|
17
|
-
|
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
|
-
|
27
|
+
alias :tmp_folder_path :folder_path
|
27
28
|
|
28
|
-
|
29
|
+
def tmp_folder_init
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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
|
data/lib/tmp/dsl.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
#encoding: UTF-8
|
2
2
|
module TMP
|
3
3
|
|
4
|
-
|
5
|
-
class << self
|
6
|
-
def method_missing(method, *args)
|
4
|
+
module DSLCore
|
7
5
|
|
8
|
-
|
9
|
-
|
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
|
data/lib/tmp/init.rb
ADDED
@@ -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.
|
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/
|
77
|
+
- lib/tmp/core.rb
|
78
78
|
- lib/tmp/dsl.rb
|
79
|
-
- lib/tmp/
|
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:
|
data/lib/tmp/config.rb
DELETED
@@ -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
|
data/lib/tmp/instance.rb
DELETED
@@ -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
|