procemon 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjZiMzE0OGY4ZWYzZGU5NmRlYTQxNWM0YTk5NjhiZGNjYjhlZjAzNQ==
4
+ ZWQ5YTU2MGNhNzg5MTRlMTUzNzJjMmM0ZjQzYzhlZjBkMjMzOGI0NA==
5
5
  data.tar.gz: !binary |-
6
- MzQ0YWRkMDhkN2YzZmRiYzk0MTdiNDdlMWMwZTlkYzU5OTBkZTI1OQ==
6
+ MzEwYjk4NjZiZGJjN2YwMmNmOGQ5YmM3ZGNjMjlmMjE4ZDg2Y2IxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjBmMGZkOTQ1NWNkMWU2MjgyMjM4NTJjNjA0MmNlOTVmZjFjMDQ3NDNiNjc3
10
- YWY1Njc4Nzc4YjY1N2M4OTcyOGZjNTZiYTg4ODc5ZTk4M2E1MmU2ZWJkZWVj
11
- MzQxNTQ1M2RhNThhNzg3YjI3ZmMxMmQwN2MxODdlY2MzYjllN2U=
9
+ MmEzMGE5NjcyMWE3YTNlOWM2ZWIwYTNiYTIyYzdiNGU1YjA3NWNhYTI0YjJm
10
+ YzdhMjI0MTMzMTBkMWVjYTI5OGMwZDQyZjNkNTUyMDAzOWE5NWE0NzM2Mjc4
11
+ M2FkYTYwNDRmNDlkODdjOGQ2OGFlNTk5MGI0NTU2NjI4NjBmYzQ=
12
12
  data.tar.gz: !binary |-
13
- ODlhNzY0ZDc2MzJkN2FkYTg1YzAxMDg5ZDYwMDAyMjJlNDZlMzBlNzJlZjAz
14
- OWRhNDJiZjMzZGEyYzg4M2Q3N2U5ZGVlYjdkYTllOWFhMWYyZThjODgzZjEw
15
- ZWJmNDA0MDM4ODA0ZDc0YzUyY2JhNjFjOTNmMTczMmJmYzE5ZWY=
13
+ M2M4ZjJlOThmNjE3ZWJkNzk3NDM5MTAxMzZjN2ZmYmQ4YTEzY2Y0ZTc5ZDMx
14
+ MDIwZjI2NjE5MTY3ZjY5Mzk3NGJkYTk0YTZiOGNkYWUzMGQ2NjZhNjY0NGZi
15
+ ZDQ1MjhjMmRhMDczMGVkMzI5OTNmYWIyZmY0YmI2Zjc3YTYwZTg=
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
+ gemspec
5
6
 
6
7
  # Add dependencies to develop your gem here.
7
8
  # Include everything needed to run rake, tests, features, etc.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.7.0
@@ -2,6 +2,8 @@
2
2
  module Procemon
3
3
 
4
4
  require 'asynchronous'
5
+ require 'sourcerer'
6
+
5
7
  require File.join(File.dirname(__FILE__),"procemon","function","require")
6
8
  require_relative_directory File.join("procemon","mpatch")
7
9
  require_relative_directory File.join("procemon","function")
@@ -61,7 +61,7 @@ class File
61
61
  text.gsub!(/\r\n?/, "\n")
62
62
  text.each_line do |*line|
63
63
  if line_num >= start_at
64
- block.call *line
64
+ block.call #*line
65
65
  end
66
66
  line_num += 1
67
67
  end
@@ -19,10 +19,7 @@ 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
- ##=======Runtime-ENV================##
23
- spec.add_runtime_dependency "asynchronous"#, ['~>4.1.3']
24
-
25
- ##=======Development-ENV============##
26
- #spec.add_development_dependency "asynchronous"#,['~>4.1.3']
22
+ spec.add_dependency "asynchronous"
23
+ spec.add_dependency "sourcerer"
27
24
 
28
25
  end
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: 0.6.3
4
+ version: 0.7.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-01-25 00:00:00.000000000 Z
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asynchronous
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sourcerer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: ! 'This is a collection of my Ruby Procs in the adventure of becoming
28
42
  the best! In short this provides extra tools in Application configs, argumens processing,daemonise,eval,
29
43
  getting source of a block,method,process and work with it, or even fuse them into
@@ -44,7 +58,6 @@ files:
44
58
  - README.md
45
59
  - Rakefile
46
60
  - VERSION
47
- - examples/fun_with_procs_and_methods.rb
48
61
  - examples/how_to_inject_with_extra_process_a_method.rb
49
62
  - examples/require_files.rb
50
63
  - examples/simple_async_processing.rb
@@ -63,12 +76,6 @@ files:
63
76
  - lib/procemon/function/meta/inject_methods.rb
64
77
  - lib/procemon/function/name.rb
65
78
  - lib/procemon/function/port.rb
66
- - lib/procemon/function/proc_source/method.rb
67
- - lib/procemon/function/proc_source/proc.rb
68
- - lib/procemon/function/proc_source/proc_source.rb
69
- - lib/procemon/function/proc_source/proc_source_body.rb
70
- - lib/procemon/function/proc_source/proc_source_params.rb
71
- - lib/procemon/function/proc_source/string.rb
72
79
  - lib/procemon/function/require.rb
73
80
  - lib/procemon/function/sender.rb
74
81
  - lib/procemon/function/systemu.rb
@@ -1,78 +0,0 @@
1
- require_relative "../lib/procemon.rb"
2
-
3
- test= Proc.new do |*params|
4
-
5
- puts "some awsome code here"
6
-
7
- end
8
-
9
- def hello_this sup,yo,lazy=nil
10
-
11
- puts "this is the Body!"
12
-
13
- end
14
-
15
-
16
- method_source= method(:hello_this).source
17
- #Proc.new{ |sup,yo,lazy=nil,*params|
18
- #
19
- # puts "this is the Body!"
20
- #
21
- #}
22
-
23
- proc_source= test.source
24
- #Proc.new{ |*params|
25
- #
26
- # puts "some awsome code here"
27
- #
28
- #}
29
-
30
- puts Proc.new{|e| puts e }.source.body
31
-
32
- Process.exit
33
-
34
- # example for terminal run
35
- puts method_source
36
- puts method_source.body,"---------"
37
- puts method_source.params,"---------"
38
- puts method_source.parameters.inspect,"---------"
39
- puts method_source.params.inspect,"---------"
40
-
41
- puts "\n"
42
-
43
- merged_proc= ( method_source.body +
44
- proc_source.body
45
- ).build(*(method_source.params+proc_source.params))
46
- puts merged_proc
47
- puts merged_proc.to_proc
48
- puts merged_proc.to_proc.source
49
-
50
-
51
- #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
52
-
53
- class A
54
-
55
- class << self
56
-
57
- def hello test=nil
58
- puts "world!"
59
- end
60
-
61
- end
62
-
63
- def self.singleton test=nil
64
- puts "singleton"
65
- end
66
-
67
- def instance hello= "wolrd"
68
- puts "instance"
69
- end
70
-
71
- end
72
-
73
- puts A.instance_method(:instance).source
74
-
75
- puts A.method(:singleton).source
76
-
77
-
78
- #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -1,71 +0,0 @@
1
- module MethodToProcSource
2
-
3
- # creatue a raw eval-able process source, so you can set
4
- # the right bindings using the .to_proc call from String methods
5
- def source
6
-
7
- # defaults
8
- begin
9
- return_string= ProcSource.new
10
- block= 0
11
- end
12
-
13
- unless ProcSource.source_cache[self.inspect].nil?
14
- return ProcSource.source_cache[self.inspect]
15
- else
16
-
17
- if self.source_location.nil?
18
- return nil
19
- end
20
-
21
- File.open(File.expand_path(self.source_location[0])
22
- ).each_line_from self.source_location[1] do |line|
23
- block += line.source_formater_for_line_sub
24
- return_string.concat(line)
25
- break if block == 0
26
- end
27
-
28
- begin
29
-
30
- if return_string.split("\n")[0].include? '('
31
- return_string.sub!('(',' ')
32
- return_string.sub!(')',' ')
33
- end
34
-
35
- args_to_replace = return_string.split("\n")[0].match(/\s*def\s*\S*\s*(.*)/).captures[0]
36
-
37
- if args_to_replace != String.new
38
- return_string.sub!(args_to_replace,"|#{args_to_replace}|")
39
- end
40
-
41
- rescue TypeError,NoMethodError
42
- return nil
43
- end
44
-
45
- return_string.sub!(/\s*\bdef\s*[\w\S]*/,'Proc.new{')
46
- return_string.sub!(/}[^}]*$/,"}")
47
-
48
- if !return_string.include?('Proc.new')
49
- return_string.sub!(/^[^{]*(?!={)/,'Proc.new')
50
- end
51
-
52
- if !self.source_location.nil?
53
- ProcSource.source_cache[self.inspect]= return_string
54
- end
55
-
56
- return return_string
57
- end
58
- end
59
-
60
- alias :source_string :source
61
- alias :proc_source :source
62
-
63
- end
64
-
65
- class Method
66
- include MethodToProcSource
67
- end
68
-
69
- class UnboundMethod
70
- include MethodToProcSource
71
- end
@@ -1,44 +0,0 @@
1
- class Proc
2
-
3
- # create a raw eval-able process source, so you can set
4
- # the right bindings using the .to_proc call from String methods
5
- def source
6
-
7
- # defaults
8
- begin
9
- return_string= ProcSource.new
10
- block= 0
11
- end
12
-
13
- unless ProcSource.source_cache[self.inspect].nil?
14
- return ProcSource.source_cache[self.inspect]
15
- else
16
-
17
- if self.source_location.nil?
18
- return "Proc.new { }"
19
- end
20
-
21
- File.open(File.expand_path(self.source_location[0])
22
- ).each_line_from self.source_location[1] do |line|
23
- block += line.source_formater_for_line_sub
24
- return_string.concat(line)
25
- break if block == 0
26
- end
27
-
28
- return_string.sub!(/^[\w\W]*Proc.new\s*{/,'Proc.new{')
29
- return_string.sub!(/}[^}]*$/,"}")
30
-
31
- if !return_string.include?('Proc.new')
32
- return_string.sub!(/^[^{]*(?!={)/,'Proc.new')
33
- end
34
-
35
- if !self.source_location.nil?
36
- ProcSource.source_cache[self.inspect]= return_string
37
- end
38
-
39
- return return_string
40
- end
41
- end
42
- alias :source_string :source
43
-
44
- end
@@ -1,101 +0,0 @@
1
- class ProcSource < String
2
-
3
- class << self
4
- attr_accessor :source_cache
5
- attr_accessor :eval_keys
6
- end
7
- self.source_cache= Hash.new
8
- self.eval_keys= Array.new
9
-
10
-
11
- def self.build(source_code_to_be_wrappered,*params_obj_array)
12
- self.new(source_code_to_be_wrappered).wrapper_around!(*params_obj_array)
13
- end
14
-
15
- def wrapper_around!(*params)
16
- if !params.nil?
17
- params= params.join(',')
18
- params.prepend(' |')
19
- params.concat('|')
20
- end
21
- self.prepend("Proc.new{#{params}\n")
22
- self.concat("\n}")
23
- end
24
-
25
- # create process object from valid process string
26
- def to_proc(binding=nil)
27
- begin
28
-
29
- unless self.split("\n")[0].include?('Proc.new')
30
- raise ArgumentError, "string obj is not a valid process source"
31
- end
32
-
33
- return_proc= nil
34
- if binding.nil?
35
- return_proc= eval(self)
36
- else
37
- return_proc= eval(self,binding)
38
- end
39
-
40
- if ProcSource.eval_keys.count > 1000
41
- ProcSource.eval_keys.each {|e| ProcSource.source_cache.delete(e) }
42
- ProcSource.eval_keys.clear
43
- end
44
- ProcSource.source_cache[return_proc.inspect]= self
45
- ProcSource.eval_keys.push return_proc.inspect
46
-
47
- return return_proc
48
- end
49
- end
50
-
51
- def body
52
-
53
- body= ProcSourceBody.new(self.dup.to_s)
54
- body.sub!(/.*Proc\.new *{ *(\|.*\|)?/,String.new)
55
- body.gsub!(/^$\n/, String.new)
56
- body.sub!(/\s*}\s*$/,String.new)
57
-
58
- return body
59
- end
60
-
61
- def params
62
- #SystemStackError
63
- params= self.dup
64
- params.sub!(params.split("\n")[0].scan(/\s*Proc.new\s*{/)[0],String.new)
65
- params.sub!(' ','')
66
- params= params.split("\n")[0].scan(/^\s*{?\s*(.*)/)[0][0].gsub!('|','')
67
- if params.nil?
68
- return nil
69
- end
70
- return ProcSourceParams[*params.split(',')]
71
- end
72
-
73
- def parameters
74
-
75
- return_array= Array.new
76
- params= self.params
77
- params.each do |one_raw_parameter|
78
- case true
79
- when one_raw_parameter.include?('=')
80
- begin
81
- return_array.push Array.new.push(:opt).push(
82
- one_raw_parameter.split('=')[0].to_sym)
83
- end
84
- when one_raw_parameter[0] == '*'
85
- begin
86
- one_raw_parameter[0]= ''
87
- return_array.push Array.new.push(:rest).push(
88
- one_raw_parameter.to_sym)
89
- end
90
- else
91
- begin
92
- return_array.push Array.new.push(:req).push(
93
- one_raw_parameter.to_sym)
94
- end
95
- end
96
- end
97
-
98
- return return_array
99
- end
100
-
101
- end
@@ -1,12 +0,0 @@
1
- class ProcSourceBody < String
2
-
3
- def +(oth_str)
4
- ProcSourceBody.new(self.dup.concat("\n").concat(oth_str.to_s))
5
- end
6
-
7
- # build proc source
8
- def build(*params)
9
- ProcSource.build(self.to_s,*params)
10
- end
11
-
12
- end
@@ -1,35 +0,0 @@
1
- class ProcSourceParams < Array
2
-
3
- # merge two proc params obj
4
- # if multiple rest obj found
5
- # it will remove and make an *args obj as last element
6
- # if they are not equal ,
7
- # else it makes it the last element only
8
- def +(oth_ary)
9
-
10
- merged_array= (Array[*self]+Array[*oth_ary])
11
-
12
- rest_state= nil
13
- rest_elements= Array.new
14
- merged_array.dup.each do |element|
15
- if element.include? '*'
16
- merged_array.delete(element)
17
- rest_state ||= true
18
- rest_elements.push(element)
19
- end
20
- end
21
-
22
- rest_elements.uniq!
23
- if rest_elements.count == 1 && !rest_elements.empty?
24
- merged_array.push(rest_elements[0])
25
- rest_state= nil
26
- end
27
-
28
- unless rest_state.nil?
29
- merged_array.push('*args')
30
- end
31
-
32
- return ProcSourceParams[*merged_array]
33
- end
34
-
35
- end
@@ -1,14 +0,0 @@
1
- class String
2
-
3
- # this is a helper to create source strings from procs
4
- def source_formater_for_line_sub
5
- self.gsub!(';',"\n")
6
- self.gsub!(/\bdo\b/,'{')
7
- self.gsub!(/\bend\b/,'}')
8
-
9
- self.frequency(/{/)+
10
- self.frequency(/def/)-
11
- self.frequency(/}/)
12
- end
13
-
14
- end