procemon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/Gemfile.lock +72 -0
- data/LICENSE.txt +20 -0
- data/README.md +4 -0
- data/README.rdoc +19 -0
- data/Rakefile +170 -0
- data/VERSION +1 -0
- data/dump/macaddr.rb +95 -0
- data/dump/uuid.rb +324 -0
- data/lib/procemon.rb +55 -0
- data/lib/procemon/function/application.rb +20 -0
- data/lib/procemon/function/argv.rb +84 -0
- data/lib/procemon/function/daemon.rb +188 -0
- data/lib/procemon/function/documentation.rb +10 -0
- data/lib/procemon/function/eval.rb +76 -0
- data/lib/procemon/function/meta/inject_methods.rb +74 -0
- data/lib/procemon/function/name.rb +13 -0
- data/lib/procemon/function/port.rb +35 -0
- data/lib/procemon/function/require.rb +241 -0
- data/lib/procemon/function/str2duck.rb +85 -0
- data/lib/procemon/function/systemu.rb +360 -0
- data/lib/procemon/function/tmp_dir.rb +20 -0
- data/lib/procemon/mpatch/array.rb +59 -0
- data/lib/procemon/mpatch/class.rb +85 -0
- data/lib/procemon/mpatch/exception.rb +0 -0
- data/lib/procemon/mpatch/file.rb +48 -0
- data/lib/procemon/mpatch/hash.rb +82 -0
- data/lib/procemon/mpatch/kernel.rb +9 -0
- data/lib/procemon/mpatch/object.rb +172 -0
- data/lib/procemon/mpatch/process.rb +14 -0
- data/lib/procemon/mpatch/random.rb +43 -0
- data/lib/procemon/mpatch/string.rb +73 -0
- data/lib/procemon/mpatch/yml.rb +11 -0
- data/procemon.gemspec +58 -0
- data/test/test.rb +17 -0
- metadata +86 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module Process
|
2
|
+
def self.daemonize
|
3
|
+
File.create Application.pid,'a+'
|
4
|
+
File.create Application.log,'a+'
|
5
|
+
File.create Application.daemon_stderr,'a+'
|
6
|
+
DaemonOgre::Daemon.start fork,
|
7
|
+
Application.pid,
|
8
|
+
Application.log,
|
9
|
+
Application.daemon_stderr
|
10
|
+
end
|
11
|
+
def self.stop
|
12
|
+
Daemon.stop
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class RND
|
2
|
+
class << self
|
3
|
+
def string(length= 7,amount=1)
|
4
|
+
mrg = String.new
|
5
|
+
first_string = true
|
6
|
+
amount.times do
|
7
|
+
a_string = Random.rand(length)
|
8
|
+
a_string == 0 ? a_string += 1 : a_string
|
9
|
+
mrg_prt = (0...a_string).map{ ('a'..'z').to_a[rand(26)] }.join
|
10
|
+
first_string ? mrg += mrg_prt : mrg+= " #{mrg_prt}"
|
11
|
+
first_string = false
|
12
|
+
end
|
13
|
+
return mrg
|
14
|
+
end
|
15
|
+
def integer(length= 3)
|
16
|
+
Random.rand(length)
|
17
|
+
end
|
18
|
+
def boolean
|
19
|
+
rand(2) == 1
|
20
|
+
end
|
21
|
+
def time from = Time.at(1114924812), to = Time.now
|
22
|
+
rand(from..to)
|
23
|
+
end
|
24
|
+
def date from = Time.at(1114924812), to = Time.now
|
25
|
+
rand(from..to).to_date
|
26
|
+
end
|
27
|
+
def datetime from = Time.at(1114924812), to = Time.now
|
28
|
+
rand(from..to).to_datetime
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# alias in Random from RND
|
35
|
+
begin
|
36
|
+
(RND.singleton_methods-Object.singleton_methods).each do |one_method_sym|
|
37
|
+
Random.class_eval do
|
38
|
+
define_singleton_method one_method_sym do |*args|
|
39
|
+
RND.__send__(one_method_sym,*args)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
# Find string in othere string
|
4
|
+
def positions(oth_string)
|
5
|
+
|
6
|
+
special_chrs=%w[# _ & < > @ $ . , -]+[*(0..9)]+[*("A".."Z")]+[*("a".."z")]
|
7
|
+
loop do
|
8
|
+
if oth_string.include? special_chrs[0]
|
9
|
+
special_chrs.shift
|
10
|
+
else
|
11
|
+
break
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
string=self
|
16
|
+
return_array = Array.new
|
17
|
+
loop do
|
18
|
+
break if string.index(oth_string).nil?
|
19
|
+
range_value= ((string.index(oth_string))..(string.index(oth_string)+oth_string.length-1))
|
20
|
+
return_array.push range_value
|
21
|
+
[*range_value].each do |one_index|
|
22
|
+
string[one_index]= special_chrs[0]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# return value
|
27
|
+
return return_array
|
28
|
+
end
|
29
|
+
|
30
|
+
# Standard in rails. See official documentation
|
31
|
+
# [http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
32
|
+
def camelize(first_letter = :upper)
|
33
|
+
if first_letter == :upper
|
34
|
+
gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
35
|
+
else
|
36
|
+
self[0..0].downcase + camelize[1..-1]
|
37
|
+
end
|
38
|
+
end unless method_defined? :camelize
|
39
|
+
|
40
|
+
# Standard in rails. See official documentation
|
41
|
+
# [http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
42
|
+
def dasherize
|
43
|
+
gsub(/_/, '-')
|
44
|
+
end unless method_defined? :dasherize
|
45
|
+
|
46
|
+
# Standard in rails. See official documentation
|
47
|
+
# [http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
48
|
+
def demodulize
|
49
|
+
gsub(/^.*::/, '')
|
50
|
+
end unless method_defined? :demodulize
|
51
|
+
|
52
|
+
# Standard in rails. See official documentation
|
53
|
+
# [http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
|
54
|
+
def underscore
|
55
|
+
gsub(/::/, '/').
|
56
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
57
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
58
|
+
tr("-", "_").
|
59
|
+
downcase
|
60
|
+
end unless method_defined? :underscore
|
61
|
+
|
62
|
+
# Check that instance of String is start with an upper case or not
|
63
|
+
def capitalized?
|
64
|
+
self.match(/^[[:upper:]]/) ? true : false
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
=begin
|
70
|
+
|
71
|
+
/\b[A-Z]\w*/ #> this is for find capitalized words
|
72
|
+
|
73
|
+
=end
|
data/procemon.gemspec
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
#lib = File.expand_path('../lib', __FILE__)
|
4
|
+
#$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
### Get Files from dir
|
7
|
+
begin
|
8
|
+
|
9
|
+
files_to_be_loaded = %w[version.rb]
|
10
|
+
spec_files = Array.new
|
11
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__),"**","*"))].sort.uniq.each do |one_file_name|
|
12
|
+
one_file_name = File.expand_path one_file_name
|
13
|
+
file_name = one_file_name[(File.expand_path(File.dirname(__FILE__)).to_s.length+1)..(one_file_name.length-1)]
|
14
|
+
|
15
|
+
if !one_file_name.include?("pkg")
|
16
|
+
if !File.directory? file_name
|
17
|
+
spec_files.push file_name
|
18
|
+
STDOUT.puts file_name if $DEBUG
|
19
|
+
if files_to_be_loaded.include? one_file_name.split(File::SEPARATOR).last
|
20
|
+
load one_file_name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
### Specification for the new Gem
|
30
|
+
Gem::Specification.new do |spec|
|
31
|
+
|
32
|
+
spec.name = "procemon"
|
33
|
+
spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.chomp
|
34
|
+
spec.authors = ["Adam Luzsi"]
|
35
|
+
spec.email = ["adamluzsi@gmail.com"]
|
36
|
+
spec.description = %q{This is a collection of my Ruby Procs in the adventure of becoming the best!}
|
37
|
+
spec.summary = %q{Gotta catch em all!}
|
38
|
+
spec.homepage = "https://github.com/adamluzsi/procemon"
|
39
|
+
spec.license = "MIT"
|
40
|
+
|
41
|
+
spec.files = spec_files
|
42
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
43
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
44
|
+
spec.require_paths = ["lib"]
|
45
|
+
|
46
|
+
##=======Runtime-ENV================##
|
47
|
+
### Terminal like commands
|
48
|
+
#spec.add_runtime_dependency "commander", ['~>4.1.3']
|
49
|
+
|
50
|
+
## Node.JS
|
51
|
+
#spec.add_runtime_dependency "execjs"
|
52
|
+
|
53
|
+
##=======Development-ENV============##
|
54
|
+
#spec.add_development_dependency "commander",['~>4.1.3']
|
55
|
+
#spec.add_development_dependency "rake"
|
56
|
+
#spec.add_development_dependency "bundle"
|
57
|
+
|
58
|
+
end
|
data/test/test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: procemon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Luzsi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This is a collection of my Ruby Procs in the adventure of becoming the
|
15
|
+
best!
|
16
|
+
email:
|
17
|
+
- adamluzsi@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- README.rdoc
|
27
|
+
- Rakefile
|
28
|
+
- VERSION
|
29
|
+
- dump/macaddr.rb
|
30
|
+
- dump/uuid.rb
|
31
|
+
- lib/procemon.rb
|
32
|
+
- lib/procemon/function/application.rb
|
33
|
+
- lib/procemon/function/argv.rb
|
34
|
+
- lib/procemon/function/daemon.rb
|
35
|
+
- lib/procemon/function/documentation.rb
|
36
|
+
- lib/procemon/function/eval.rb
|
37
|
+
- lib/procemon/function/meta/inject_methods.rb
|
38
|
+
- lib/procemon/function/name.rb
|
39
|
+
- lib/procemon/function/port.rb
|
40
|
+
- lib/procemon/function/require.rb
|
41
|
+
- lib/procemon/function/str2duck.rb
|
42
|
+
- lib/procemon/function/systemu.rb
|
43
|
+
- lib/procemon/function/tmp_dir.rb
|
44
|
+
- lib/procemon/mpatch/array.rb
|
45
|
+
- lib/procemon/mpatch/class.rb
|
46
|
+
- lib/procemon/mpatch/exception.rb
|
47
|
+
- lib/procemon/mpatch/file.rb
|
48
|
+
- lib/procemon/mpatch/hash.rb
|
49
|
+
- lib/procemon/mpatch/kernel.rb
|
50
|
+
- lib/procemon/mpatch/object.rb
|
51
|
+
- lib/procemon/mpatch/process.rb
|
52
|
+
- lib/procemon/mpatch/random.rb
|
53
|
+
- lib/procemon/mpatch/string.rb
|
54
|
+
- lib/procemon/mpatch/yml.rb
|
55
|
+
- procemon.gemspec
|
56
|
+
- test/test.rb
|
57
|
+
homepage: https://github.com/adamluzsi/procemon
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
hash: 954031994662740921
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.25
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Gotta catch em all!
|
85
|
+
test_files:
|
86
|
+
- test/test.rb
|