procemon 1.0.4 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/procemon/function/file.rb +67 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc27e90444b1a7a0a316376bfdcb68ba2213d951
|
4
|
+
data.tar.gz: 9d8f083cbca3786f102ad2b30485a57c3052dd85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52cf29b4382b98d59ed5809a97c5b39c4f9fdf07a0cfae5657adc589fa75ee6234a0c9d188359a7002f5d72e020c8f090cdc2c097494c1f2b5ecf62694714b30
|
7
|
+
data.tar.gz: 6f338c2a21ae2268f8a3cfd35552cefc79024d2a95bd70c4b9ca40c07c9836fd262404ffbd793c7d8311e55b8f1fda0bbc825ecee32a4b3cef1765e4ee2e4c34
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class File
|
2
|
+
|
3
|
+
# create a file, if not exsist create file, and dir if needed
|
4
|
+
def self.create(route_name ,filemod="w",string_data= ::String.new )
|
5
|
+
|
6
|
+
#file_name generate
|
7
|
+
if !route_name.to_s.split(File::SEPARATOR).last.nil? || route_name.to_s.split(File::SEPARATOR).last != ''
|
8
|
+
file_name = route_name.to_s.split(File::SEPARATOR).last
|
9
|
+
else
|
10
|
+
file_name = nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
#path_way
|
14
|
+
begin
|
15
|
+
raise ::ArgumentError, "missing route_name: #{route_name}" if route_name.nil?
|
16
|
+
path = File.expand_path(route_name).to_s.split(File::SEPARATOR)
|
17
|
+
path = path - [File.expand_path(route_name).to_s.split(File::SEPARATOR).last]
|
18
|
+
path.shift
|
19
|
+
end
|
20
|
+
|
21
|
+
#job
|
22
|
+
begin
|
23
|
+
if !::Dir.exists?(File::SEPARATOR+path.join(File::SEPARATOR))
|
24
|
+
|
25
|
+
at_now = File::SEPARATOR
|
26
|
+
path.each do |dir_to_be_checked|
|
27
|
+
|
28
|
+
at_now += "#{dir_to_be_checked+File::SEPARATOR}"
|
29
|
+
::Dir.mkdir(at_now) if !::Dir.exists?(at_now)
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# write data
|
36
|
+
begin
|
37
|
+
full_path = "#{File::SEPARATOR+path.join(File::SEPARATOR)+File::SEPARATOR}#{file_name}"
|
38
|
+
if File.exist? full_path
|
39
|
+
File.open(full_path,filemod).write string_data
|
40
|
+
else
|
41
|
+
File.new(full_path,filemod).write string_data
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# start read the file object on each line
|
48
|
+
# optionable an integer value to start read line at
|
49
|
+
# compatible with mac (i am linux user, so not tested)
|
50
|
+
def each_line_from(start_at=1,&block)
|
51
|
+
unless [::Integer,Fixnum,Bignum].include?(start_at.class)
|
52
|
+
raise ::ArgumentError, "invalid line index"
|
53
|
+
end
|
54
|
+
begin
|
55
|
+
line_num= 1
|
56
|
+
text= self.read
|
57
|
+
text.gsub!(/\r\n?/, "\n")
|
58
|
+
text.each_line do |*line|
|
59
|
+
if line_num >= start_at
|
60
|
+
block.call #*line
|
61
|
+
end
|
62
|
+
line_num += 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/procemon/function/argv.rb
|
96
96
|
- lib/procemon/function/daemon.rb
|
97
97
|
- lib/procemon/function/documentation.rb
|
98
|
+
- lib/procemon/function/file.rb
|
98
99
|
- lib/procemon/function/generate.rb
|
99
100
|
- lib/procemon/function/macaddr.rb
|
100
101
|
- lib/procemon/function/meta/eval.rb
|