tmp 0.0.1.pre → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -0
- data/README.md +46 -1
- data/VERSION +1 -1
- data/examples/config_exmpl.rb +9 -0
- data/examples/test.rb +13 -1
- data/examples/tmp_folder/hello +3 -0
- data/lib/tmp.rb +7 -2
- data/lib/tmp/config.rb +24 -0
- data/lib/tmp/dsl.rb +28 -0
- data/lib/tmp/function.rb +63 -0
- data/tmp.gemspec +6 -4
- metadata +55 -8
- data/lib/tmp/support.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d15cf53f4841962bd69c008192141a8a4a56a5
|
4
|
+
data.tar.gz: 46417c5e177122c096ec74998c59e26608194f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44470efbda4fad071d0d4f1fc913873766cec3cb7c60e1239d0ec8d716b23ddfb1847cfdbfd4108a1d549082c26c674a3cfa2f750eb962d280a16460edf3ecbd
|
7
|
+
data.tar.gz: 3a47a8dffdc448defefbe75be37b5143ab5542403e944291df39893606223115c9fdde8489279e0b7a5c267140f87d7d780f88d532ffb9770e39b6e2febe7e66
|
data/Gemfile.lock
ADDED
data/README.md
CHANGED
@@ -1,4 +1,49 @@
|
|
1
1
|
tmp
|
2
2
|
===
|
3
3
|
|
4
|
-
Ruby DSL for manage tmp files and make easy
|
4
|
+
Ruby DSL for manage tmp files and make easy
|
5
|
+
tmp commands / variables to file system
|
6
|
+
Sometimes usefull for forked processes.
|
7
|
+
|
8
|
+
I'ts not made for shared memory management!
|
9
|
+
The main goal is to provide dsl for easy tmp files making on the filesystem
|
10
|
+
|
11
|
+
|
12
|
+
### Example
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
require 'tmp'
|
16
|
+
|
17
|
+
TMP.write :test, {hello: 'world'}
|
18
|
+
puts TMP.read(:test)
|
19
|
+
|
20
|
+
# or you can use syntax sugar!
|
21
|
+
tmp.hello = { hello: 'world'}
|
22
|
+
|
23
|
+
# defined variable
|
24
|
+
puts tmp.hello #> { hello: 'world'}
|
25
|
+
|
26
|
+
# undefined variable
|
27
|
+
puts tmp.sup #> nil
|
28
|
+
```
|
29
|
+
|
30
|
+
### Config
|
31
|
+
|
32
|
+
you can config the folder path for custom tmp folder use case if you dont want to use the systems default tmp folder/ your app space
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'tmp'
|
36
|
+
|
37
|
+
TMP::Config.folder_path File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder'))
|
38
|
+
|
39
|
+
# or you can use syntax sugar!
|
40
|
+
tmp.hello = { hello: 'world'}
|
41
|
+
# defined variable
|
42
|
+
puts tmp.hello #> { hello: 'world'}
|
43
|
+
```
|
44
|
+
|
45
|
+
### TODO
|
46
|
+
|
47
|
+
* make ssl encryption for the tmp files opt able
|
48
|
+
* implement more awesome trick
|
49
|
+
* find contributors
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
1.0.0
|
data/examples/test.rb
CHANGED
@@ -1,2 +1,14 @@
|
|
1
|
-
|
1
|
+
require 'tmp'
|
2
|
+
|
3
|
+
TMP.write :test, {hello: 'world'}
|
4
|
+
puts TMP.read(:test)
|
5
|
+
|
6
|
+
# or you can use syntax sugar!
|
7
|
+
tmp.hello = { hello: 'world'}
|
8
|
+
|
9
|
+
# defined variable
|
10
|
+
puts tmp.hello #> { hello: 'world'}
|
11
|
+
|
12
|
+
# undefined variable
|
13
|
+
puts tmp.sup #> nil
|
2
14
|
|
data/lib/tmp.rb
CHANGED
data/lib/tmp/config.rb
CHANGED
@@ -1,7 +1,31 @@
|
|
1
1
|
#encoding: UTF-8
|
2
2
|
module TMP
|
3
3
|
module Config
|
4
|
+
class << self
|
4
5
|
|
5
6
|
|
7
|
+
def default_folder_path
|
8
|
+
File.join( Dir.tmpdir, ( Dir.pwd.split(File::Separator).last.to_s ) )
|
9
|
+
end
|
10
|
+
|
11
|
+
@@config_path= nil
|
12
|
+
def folder_path path= nil
|
13
|
+
|
14
|
+
unless path.nil?
|
15
|
+
|
16
|
+
unless path.class <= String
|
17
|
+
raise ArgumentError,"invalid path class"
|
18
|
+
end
|
19
|
+
|
20
|
+
@@config_path = File.absolute_path(path)
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
@@config_path || default_folder_path
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
6
30
|
end
|
7
31
|
end
|
data/lib/tmp/dsl.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
module TMP
|
3
|
+
|
4
|
+
class DSL < ::EmptyObject
|
5
|
+
class << self
|
6
|
+
def method_missing(method, *args)
|
7
|
+
|
8
|
+
if method.to_s.include?('=')
|
9
|
+
::TMP.write method.to_s.gsub('=',''), args.first
|
10
|
+
else
|
11
|
+
::TMP.read(method)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module SyntaxSugar
|
19
|
+
|
20
|
+
def tmp
|
21
|
+
::TMP::DSL
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
Object.__send__ :include, ::TMP::SyntaxSugar
|
data/lib/tmp/function.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
module TMP
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def tmp_folder_path
|
6
|
+
|
7
|
+
modifier= ""
|
8
|
+
::TMP::Config.folder_path
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
alias :folder_path :tmp_folder_path
|
13
|
+
|
14
|
+
def tmp_folder_init
|
15
|
+
|
16
|
+
begin
|
17
|
+
|
18
|
+
Dir.mkdir tmp_folder_path
|
19
|
+
return true
|
20
|
+
|
21
|
+
rescue Errno::EEXIST
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_buffer path
|
28
|
+
|
29
|
+
comm_line= File.open(path,"r")
|
30
|
+
|
31
|
+
read_buffer = ::Thread.new do
|
32
|
+
while !comm_line.eof?
|
33
|
+
@value = ::Marshal.load( comm_line )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def write variable_name, data_object
|
40
|
+
|
41
|
+
tmp_folder_init
|
42
|
+
|
43
|
+
File.open( File.join(tmp_folder_path,variable_name.to_s) ,"w") do |file|
|
44
|
+
return file.write ::Marshal.dump(data_object)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def read variable_name
|
50
|
+
|
51
|
+
unless File.exist?(File.join(tmp_folder_path,variable_name.to_s))
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
File.open( File.join(tmp_folder_path,variable_name.to_s) ,"r") do |file|
|
56
|
+
return ::Marshal.load file.read
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/tmp.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.split("\n")[0].chomp.gsub(' ','')
|
10
10
|
spec.authors = ["Adam Luzsi"]
|
11
11
|
spec.email = ["adamluzsi@gmail.com"]
|
12
|
-
spec.description = %q{
|
13
|
-
spec.summary = %q{
|
14
|
-
spec.homepage = "https://github.com/adamluzsi/
|
12
|
+
spec.description = %q{ DSL for system tmp folders }
|
13
|
+
spec.summary = %q{Ruby DSL for manage tmp files and make easy tmp commands / variables accross the forked processes. I'ts not made for shared memory management! it's main }
|
14
|
+
spec.homepage = "https://github.com/adamluzsi/tmp"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = TMP.class_variable_get("@@spec_files")
|
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
|
22
|
+
spec.add_dependency 'empty_object'
|
23
|
+
|
24
|
+
%W[ rake bundler ].each{ |gem_name| spec.add_development_dependency(gem_name) }
|
23
25
|
|
24
26
|
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: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -9,8 +9,50 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-04-08 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: empty_object
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: " DSL for system tmp folders "
|
14
56
|
email:
|
15
57
|
- adamluzsi@gmail.com
|
16
58
|
executables: []
|
@@ -18,17 +60,21 @@ extensions: []
|
|
18
60
|
extra_rdoc_files: []
|
19
61
|
files:
|
20
62
|
- Gemfile
|
63
|
+
- Gemfile.lock
|
21
64
|
- LICENSE
|
22
65
|
- README.md
|
23
66
|
- Rakefile
|
24
67
|
- VERSION
|
68
|
+
- examples/config_exmpl.rb
|
25
69
|
- examples/test.rb
|
70
|
+
- examples/tmp_folder/hello
|
26
71
|
- files.rb
|
27
72
|
- lib/tmp.rb
|
28
73
|
- lib/tmp/config.rb
|
29
|
-
- lib/tmp/
|
74
|
+
- lib/tmp/dsl.rb
|
75
|
+
- lib/tmp/function.rb
|
30
76
|
- tmp.gemspec
|
31
|
-
homepage: https://github.com/adamluzsi/
|
77
|
+
homepage: https://github.com/adamluzsi/tmp
|
32
78
|
licenses:
|
33
79
|
- MIT
|
34
80
|
metadata: {}
|
@@ -43,13 +89,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
89
|
version: '0'
|
44
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
91
|
requirements:
|
46
|
-
- - "
|
92
|
+
- - ">="
|
47
93
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
94
|
+
version: '0'
|
49
95
|
requirements: []
|
50
96
|
rubyforge_project:
|
51
97
|
rubygems_version: 2.2.2
|
52
98
|
signing_key:
|
53
99
|
specification_version: 4
|
54
|
-
summary:
|
100
|
+
summary: Ruby DSL for manage tmp files and make easy tmp commands / variables accross
|
101
|
+
the forked processes. I'ts not made for shared memory management! it's main
|
55
102
|
test_files: []
|