procemon 1.2.1 → 2.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: 5502375f85b893c50ddcf96ef59216844060e2ca
4
- data.tar.gz: 961d1d7c0e415d79590af07551bd15dc9a0454ac
3
+ metadata.gz: a7cede2e26f925171f888572ac79231e40799edb
4
+ data.tar.gz: 8f9327b6d135e44d53f1232abf883e49f65d3330
5
5
  SHA512:
6
- metadata.gz: 04fa0cdf2d16e7f5ad64f60e8841ec81374a38a7339722a45e05cefab988eb544472105ad7b88cf08e621442df71e55118db55ef188e8ccdf24e8640afc34f3a
7
- data.tar.gz: d1c1abdfc13b15020024c6c99636395a4159187b34200beeae6d8fea1892f4cf7b576da235e45177417746c21be0abb232f23353db0b12e1bd49feae8763e096
6
+ metadata.gz: 4505fdc97d65df2e5355be3007ced5b71bdd6b8747d9b0e62b2bcffa22f1ea5520c170d2050d686dceae30f6c5fec573f391bca77fb92e5770ec88fba399b619
7
+ data.tar.gz: 309c26663a1d4a4a096af13373d2ff1235b34c9e693ab953061dab646a0f5ec00a5cf40c5078f61ae7002d877ca7e68f7d7be94c23255d9496534aa17ef3cdf9
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ pkg/
7
+ .idea/
8
+ dump/
9
+ Gemfile.lock
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- procemon (1.1.1)
4
+ procemon (2.0.0.alpha)
5
5
  bindless
6
- loader
6
+ loader (>= 1.2.3)
7
7
  mpatch
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- bindless (1.0.0)
13
- loader (1.0.6)
14
- mpatch (2.3.0)
12
+ bindless (1.0.1)
13
+ loader (1.2.3)
14
+ mpatch (2.8.1)
15
15
 
16
16
  PLATFORMS
17
17
  ruby
data/README.md CHANGED
@@ -1,63 +1,80 @@
1
- procemon
1
+ Procemon
2
2
  ========
3
3
 
4
- Gotta catch em all!
5
- This is a collection of my Ruby Procs in the adventure of becoming the best!
4
+ ## Gotta catch em all!
6
5
 
6
+ With this tool you can hook singleton and instance methods alike in modules and classes
7
7
 
8
- This is including Tons of monkey_patch for new features to classes,
9
- meta-programing tricks, terminal argument controls, daemonise trick,
10
- tmp folder helpers, Application centralized datas, folder structure logic ,
11
- meta data control, dynamic lib read etc
12
8
 
13
- There is really lot of helper method, i mean i even lose my life love if i want to start describe all of them
14
- you can generate rdoc if you want, i more like examples, so from now on,
15
- i will make examples!
9
+ ### Examples
16
10
 
17
- # Examples
11
+ Check the "test.rb" in the examples
12
+ You need to add plus functionality like logger in the deepness of rack, ease than, and enjoy ruby awesomeness.
18
13
 
19
- The "how_to_inject_with_extra_process_a_method"
20
- tells you how to NOT monkey patch methods in modules.
21
- You want use a module? sure awsome !
22
- You need to add plus functionality but dont want to follow the module updates
23
- (in case of conflight with the monkey patch)
24
- Than this is your tool. Tell the method to inject what method and it will , but remember
14
+ The hook code block will act like it's run in the target model/class
25
15
  params are always have to obey to the original method!
16
+ I recommend use "*args" like arguments input, when you need it.
17
+ If you dont care about the arguments, dont request it at the code-block
26
18
 
27
- The "fun_with_procs_and_methods"
28
- tells you how to play with proc and method objects source code,
29
- combine them, manipulate them, and convert back into live code
30
- with the right bindings
31
19
 
32
- the "simple async processing" will let you use os threads (1.9.n+)
33
- for multiprocessing so you can give multiple task to do and
34
- until you ask for the value, the process will be in the background
35
- You can also use OS threads instead of VM Threads for real Parallelism
20
+ ```ruby
36
21
 
37
- the "require_files" shows you how can you get files from directory
38
- in a recursive way and stuffs like that so you can be lay
22
+ require "procemon"
39
23
 
40
- ## LICENSE
24
+ class TestT
41
25
 
42
- (The MIT License)
26
+ def self.test
27
+ puts self
28
+ end
43
29
 
44
- Copyright (c) 2009-2013 Adam Luzsi <adamluzsi@gmail.com>
30
+ def test string
31
+ puts self,string
32
+ end
45
33
 
46
- Permission is hereby granted, free of charge, to any person obtaining
47
- a copy of this software and associated documentation files (the
48
- 'Software'), to deal in the Software without restriction, including
49
- without limitation the rights to use, copy, modify, merge, publish,
50
- distribute, sublicense, and/or sell copies of the Software, and to
51
- permit persons to whom the Software is furnished to do so, subject to
52
- the following conditions:
34
+ end
53
35
 
54
- The above copyright notice and this permission notice shall be
55
- included in all copies or substantial portions of the Software.
36
+ TestT.hook_instance_method :test do |*args|
37
+ puts "before hook and str: " + args[0].to_s.inspect
38
+ end
56
39
 
57
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
58
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
59
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
60
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
61
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
62
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
63
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40
+ TestT.hook_singleton_method :test, add: "after" do
41
+ puts "after hook for singleton"
42
+ end
43
+
44
+ TestT.test
45
+ TestT.new.test "boogie man"
46
+
47
+ # after,singleton case:
48
+ # ---------------------
49
+ # TestT
50
+ # after hook for singleton
51
+ #
52
+ #
53
+ # before,instance case:
54
+ # ---------------------
55
+ # before hook and str: "boogie man"
56
+ # #<TestT:0x000000027bebc8>
57
+ # boogie man
58
+
59
+ ```
60
+
61
+
62
+ ### After words
63
+
64
+ With 2.0.0, the project had been cleaned out,
65
+ anything else than method hooks moved out.
66
+
67
+ mpatch: meta-programing tricks, base class extensions, dsl making helpers
68
+
69
+ argv: terminal argument controls,
70
+
71
+ daemon-ogre: daemonise trick,
72
+
73
+ tmp: tmp folder helpers,
74
+
75
+ configer: Applications yaml and json datas in centralized object, based on folder structure logic,
76
+
77
+ loader: meta data mounting (best used with configer), dynamic lib reading etc caller based paths
78
+ (require relative directory methods for modules in gems)
79
+
80
+ Happy Coding! :)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 2.0.0
@@ -0,0 +1,48 @@
1
+ require "procemon"
2
+
3
+ class TestT
4
+
5
+ def self.test
6
+ puts self
7
+ end
8
+
9
+ def test string
10
+ puts self,string
11
+ end
12
+
13
+ end
14
+
15
+ TestT.hook_instance_method :test do |*args|
16
+ puts "before hook and str: " + args[0].to_s.inspect
17
+ end
18
+
19
+ TestT.hook_singleton_method :test, add: "after" do
20
+
21
+ puts "after hook for singleton"
22
+
23
+ end
24
+
25
+ puts "\n\n",
26
+ "after,singleton case:",
27
+ "---------------------"
28
+ TestT.test
29
+
30
+ puts "\n\n",
31
+ "before,instance case:",
32
+ "---------------------"
33
+ TestT.new.test "boogie man"
34
+
35
+ puts "\n"
36
+
37
+
38
+ # after,singleton case:
39
+ # ---------------------
40
+ # TestT
41
+ # after hook for singleton
42
+ #
43
+ #
44
+ # before,instance case:
45
+ # ---------------------
46
+ # before hook and str: "boogie man"
47
+ # #<TestT:0x000000027bebc8>
48
+ # boogie man
@@ -1,46 +1,12 @@
1
1
  #encoding: UTF-8
2
2
  module Procemon
3
3
 
4
- #require 'sourcerer'
5
-
6
- require 'loader'
7
- require 'mpatch'
8
4
  require 'bindless'
5
+ require 'loader'
9
6
 
7
+ require 'mpatch/object'
8
+ MPatch.patch!
10
9
 
11
- require_relative_directory File.join("procemon","function"),:r
12
-
13
- def self.init_all
14
-
15
- # process the ARGV parameters
16
- process_parameters
17
-
18
- # project name
19
- set_app_name_by_root_folder
20
-
21
- # init temporarily directory
22
- tmpdir_init
23
-
24
- # Daemonize
25
- Daemon.init
26
-
27
- # create config singleton
28
- Loader.metaloader_framework root: Loader.caller_root_folder,
29
- config_obj: Application.config
30
-
31
- Dir.glob(File.join(Loader.caller_root_folder,"{lib,libs}","*")).each do |path|
32
- if !File.directory? path
33
- require path
34
- end
35
- end
36
-
37
- # garbage collect
38
- ObjectSpace.garbage_collect
39
-
40
- # documentation generate
41
- generate_documentation
42
-
43
- end
44
-
10
+ require_relative_directory "procemon"
45
11
 
46
12
  end
@@ -0,0 +1,75 @@
1
+ module Procemon::ObjectEXT
2
+
3
+ # safe_eval(string [, binding [, filename [,lineno]]] *allowed_class/module_names ) -> obj
4
+ #
5
+ # Definition of the safe levels
6
+ #
7
+ # $SAFE >= 1
8
+ #
9
+ # The environment variables RUBYLIB and RUBYOPT are not processed, and the current directory is not added to the path.
10
+ # The command-line options -e, -i, -I, -r, -s, -S, and -x are not allowed.
11
+ # Can't start processes from $PATH if any directory in it is world-writable.
12
+ # Can't manipulate or chroot to a directory whose name is a tainted string.
13
+ # Can't glob tainted strings.
14
+ # Can't eval tainted strings.
15
+ # Can't load or require a file whose name is a tainted string.
16
+ # Can't manipulate or query the status of a file or pipe whose name is a tainted string.
17
+ # Can't execute a system command or exec a program from a tainted string.
18
+ # Can't pass trap a tainted string.
19
+ #
20
+ # $SAFE >= 2
21
+ #
22
+ # Can't change, make, or remove directories, or use chroot.
23
+ # Can't load a file from a world-writable directory.
24
+ # Can't load a file from a tainted filename starting with ~.
25
+ # Can't use File#chmod , File#chown , File#lstat , File.stat , File#truncate , File.umask , File#flock , IO#ioctl , IO#stat , Kernel#fork , Kernel#syscall , Kernel#trap . Process::setpgid , Process::setsid , Process::setpriority , or Process::egid= .
26
+ # Can't handle signals using trap.
27
+ #
28
+ # $SAFE >= 3
29
+ #
30
+ # All objects are created tainted.
31
+ # Can't untaint objects.
32
+ #
33
+ #
34
+ # Evaluates the Ruby expression(s) in <em>string</em>. If
35
+ # <em>binding</em> is given, which must be a <code>Binding</code>
36
+ # object, the evaluation is performed in its context. If the
37
+ # optional <em>filename</em> and <em>lineno</em> parameters are
38
+ # present, they will be used when reporting syntax errors.
39
+ #
40
+ # def get_binding(str)
41
+ # return binding
42
+ # end
43
+ # str = "hello"
44
+ # safe_eval "str + ' Fred'" ,Kernel #=> "hello Fred"
45
+ # safe_eval "str + ' Fred'", get_binding("bye") ,Kernel #=> "bye Fred"
46
+ def safe_eval(*args)
47
+
48
+ # require 'stringio'
49
+ # old_values = [$stderr,$VERBOSE]
50
+ # $stderr = StringIO.new
51
+ # $VERBOSE= false
52
+
53
+ ::Thread.new{
54
+
55
+ safe_ok= false
56
+ begin
57
+ $SAFE= 3
58
+ safe_ok= true
59
+ rescue
60
+ end
61
+ if safe_ok
62
+ eval(*args)
63
+ end
64
+
65
+ }.value
66
+
67
+ # ensure
68
+ # $stderr = old_values[0]
69
+ # $VERBOSE= old_values[1]
70
+
71
+ end
72
+
73
+ end
74
+
75
+ Object.__send__ :include, Procemon::ObjectEXT
@@ -1,4 +1,4 @@
1
- module InjectMethods
1
+ module Procemon::Hooks
2
2
 
3
3
  # this will inject a code block to a target instance method
4
4
  # by default the before or after sym is not required
@@ -80,4 +80,4 @@ module InjectMethods
80
80
 
81
81
  end
82
82
 
83
- Module.__send__ :include, InjectMethods
83
+ Module.__send__ :include, Procemon::Hooks
@@ -1,25 +1,21 @@
1
1
  # coding: utf-8
2
2
 
3
- require File.expand_path(File.join(File.dirname(__FILE__),"files.rb"))
4
-
5
- ### Specification for the new Gem
6
3
  Gem::Specification.new do |spec|
7
4
 
8
5
  spec.name = "procemon"
9
6
  spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.split("\n")[0].chomp.gsub(' ','')
10
7
  spec.authors = ["Adam Luzsi"]
11
8
  spec.email = ["adamluzsi@gmail.com"]
12
- spec.description = %q{This is a collection of my Ruby Procs in the adventure of becoming the best! In short this provides extra tools in Application configs, argumens processing,daemonise,eval, getting source of a block,method,process and work with it, or even fuse them into a new proc , require relative files, or directories, string to duck parsing, system tmp_dir using, meta-programing stuffs,(async stuffs went to different project), micro framework that can be used alongside with any framework and a lot of monkey patch for extra functions :) follow me on github if you like my work! }
13
- spec.summary = %q{Gotta catch em all!}
9
+ spec.description = %q{ Lasso for Methods! You can hook up processes before and after to existing method objects, it's like a monkey patch without have to open up the actually method. }
10
+ spec.summary = %q{ Gotta catch em all! }
14
11
  spec.homepage = "https://github.com/adamluzsi/procemon"
15
- spec.license = "MIT"
16
12
 
17
- spec.files = SpecFiles
13
+ spec.files = `git ls-files`.split($/)
18
14
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
15
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
16
  spec.require_paths = ["lib"]
21
17
 
22
- spec.add_dependency "loader",">= 1.1.0"
18
+ spec.add_dependency "loader",">= 1.2.3"
23
19
  spec.add_dependency "mpatch"
24
20
  spec.add_dependency "bindless"
25
21
 
@@ -1,5 +1,31 @@
1
1
  # Require Gemfile gems
2
- require_relative "../lib/procemon"
3
2
 
3
+ def safe_eval(*args)
4
4
 
5
- puts( {:hello=> "world",:world => "hello"}.map_hash{|k,v| [ k , 123] })
5
+ # require 'stringio'
6
+ # old_values = [$stderr,$VERBOSE]
7
+ # $stderr = StringIO.new
8
+ # $VERBOSE= false
9
+
10
+ ::Thread.new{
11
+
12
+ safe_ok= false
13
+ begin
14
+ $SAFE= 3
15
+ safe_ok= true
16
+ rescue
17
+ end
18
+ if safe_ok
19
+ eval(*args)
20
+ end
21
+
22
+ }.value
23
+
24
+ ensure
25
+ # $stderr = old_values[0]
26
+ # $VERBOSE= old_values[1]
27
+
28
+ end
29
+
30
+
31
+ safe_eval " puts('hello world'); Process.exit! "
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: loader
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 1.2.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: 1.2.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mpatch
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,44 +52,26 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: 'This is a collection of my Ruby Procs in the adventure of becoming the
56
- best! In short this provides extra tools in Application configs, argumens processing,daemonise,eval,
57
- getting source of a block,method,process and work with it, or even fuse them into
58
- a new proc , require relative files, or directories, string to duck parsing, system
59
- tmp_dir using, meta-programing stuffs,(async stuffs went to different project),
60
- micro framework that can be used alongside with any framework and a lot of monkey
61
- patch for extra functions :) follow me on github if you like my work! '
55
+ description: " Lasso for Methods! You can hook up processes before and after to existing
56
+ method objects, it's like a monkey patch without have to open up the actually method. "
62
57
  email:
63
58
  - adamluzsi@gmail.com
64
59
  executables: []
65
60
  extensions: []
66
61
  extra_rdoc_files: []
67
62
  files:
63
+ - ".document"
64
+ - ".gitignore"
68
65
  - Gemfile
69
66
  - Gemfile.lock
70
67
  - LICENSE.txt
71
68
  - README.md
72
69
  - Rakefile
73
70
  - VERSION
74
- - examples/how_to_inject_with_extra_process_a_method.rb
75
- - examples/require_files.rb
76
- - files.rb
71
+ - examples/test.rb
77
72
  - lib/procemon.rb
78
- - lib/procemon/extra/sender.rb
79
- - lib/procemon/extra/str2duck.rb
80
- - lib/procemon/function/application.rb
81
- - lib/procemon/function/argv.rb
82
- - lib/procemon/function/daemon.rb
83
- - lib/procemon/function/documentation.rb
84
- - lib/procemon/function/file.rb
85
- - lib/procemon/function/generate.rb
86
- - lib/procemon/function/macaddr.rb
87
- - lib/procemon/function/meta/eval.rb
88
- - lib/procemon/function/meta/inject_methods.rb
89
- - lib/procemon/function/name.rb
90
- - lib/procemon/function/port.rb
91
- - lib/procemon/function/tmp_dir.rb
92
- - lib/procemon/process.rb
73
+ - lib/procemon/eval.rb
74
+ - lib/procemon/hooks.rb
93
75
  - procemon.gemspec
94
76
  - scripts/doc_gen.rb
95
77
  - scripts/test.txt
@@ -98,8 +80,7 @@ files:
98
80
  - test/prototype/class_field.rb
99
81
  - test/test.rb
100
82
  homepage: https://github.com/adamluzsi/procemon
101
- licenses:
102
- - MIT
83
+ licenses: []
103
84
  metadata: {}
104
85
  post_install_message:
105
86
  rdoc_options: []