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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 291b399d4585feb7b99f529e4fba4307163dcd4f
4
- data.tar.gz: d9b8b3a2e0019e6aab3c081b0611d7cd89cae64b
3
+ metadata.gz: c6d15cf53f4841962bd69c008192141a8a4a56a5
4
+ data.tar.gz: 46417c5e177122c096ec74998c59e26608194f16
5
5
  SHA512:
6
- metadata.gz: 1a844b410e255681d6c1e997f11e15878b2ab8b099b674b4bd7f0bf7749a30576393be074e855793327b0ae0bd89e817129dd951a8b85d406e0c41388d02b2f4
7
- data.tar.gz: 9db87befd75cc9a485ae2fb56840bea9cd96f68151c3bd824a438a73b70d2a341b54d00c0ea40cdbcce8d33b74b1328136d9e29adce76f16c1c196779dc44e42
6
+ metadata.gz: 44470efbda4fad071d0d4f1fc913873766cec3cb7c60e1239d0ec8d716b23ddfb1847cfdbfd4108a1d549082c26c674a3cfa2f750eb962d280a16460edf3ecbd
7
+ data.tar.gz: 3a47a8dffdc448defefbe75be37b5143ab5542403e944291df39893606223115c9fdde8489279e0b7a5c267140f87d7d780f88d532ffb9770e39b6e2febe7e66
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tmp (0.0.1.pre)
5
+ empty_object
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ empty_object (1.0.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ tmp!
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 tmp commands / variables accross the forked processes. I'ts not made for shared memory management! it's main
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.pre
1
+ 1.0.0
@@ -0,0 +1,9 @@
1
+ require 'tmp'
2
+
3
+ TMP::Config.folder_path File.expand_path(File.join(File.dirname(__FILE__),'tmp_folder'))
4
+
5
+ # or you can use syntax sugar!
6
+ tmp.hello = { hello: 'world'}
7
+ # defined variable
8
+ puts tmp.hello #> { hello: 'world'}
9
+
@@ -1,2 +1,14 @@
1
- require_relative "../lib/tmp"
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
 
@@ -0,0 +1,3 @@
1
+ {:
2
+ helloI"
3
+ world:ET
data/lib/tmp.rb CHANGED
@@ -1,3 +1,8 @@
1
1
  #encoding: UTF-8
2
- require File.join File.dirname(__FILE__),'tmp','config'
3
- require File.join File.dirname(__FILE__),'tmp','support'
2
+
3
+ require 'tmpdir'
4
+ require 'empty_object'
5
+
6
+ require 'tmp/config'
7
+ require 'tmp/function'
8
+ require 'tmp/dsl'
@@ -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
@@ -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
@@ -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
@@ -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{ Parse string into obj }
13
- spec.summary = %q{ String to Obj, Duck type parser }
14
- spec.homepage = "https://github.com/adamluzsi/str2duck"
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
- #spec.add_dependency 'active_support'
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.1.pre
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
- description: " Parse string into obj "
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/support.rb
74
+ - lib/tmp/dsl.rb
75
+ - lib/tmp/function.rb
30
76
  - tmp.gemspec
31
- homepage: https://github.com/adamluzsi/str2duck
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: 1.3.1
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: String to Obj, Duck type parser
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: []
@@ -1,7 +0,0 @@
1
- #encoding: UTF-8
2
- module TMP
3
- module Support
4
-
5
-
6
- end
7
- end