mpatch 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2FjYWNhOTlmZTViNTY1NjI2OTEzMTViYjgyOTgxZTA2YzRmODdkNQ==
4
+ NzRlMTNkM2UxODIxZmY2ZGUxNDBmMWFiZDVlN2I0ZWEyNjVlOGYyYQ==
5
5
  data.tar.gz: !binary |-
6
- OTI2NDg2YzAwNTViZTcyNGFiNGMyNzcyODlhODI2ODZhNTRiZmIxYg==
6
+ M2QwMmE5MjQzYzAzY2NiNTMwYzUyMDE3ZTlkOGNjZTI2MDYxMGMxMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTY2MDU1YThmYzUyMzkyMjhmMzQxZGEzODNmNDJkODkzN2QzOTg1ZmU5NTQ3
10
- N2YwNThkOTBkYzRmY2YyMmQ4YWRhYjI3MTcyN2MzNjI4MTIwMjNhNDU5NjE5
11
- MDFhZjQ3YmVhMzc2YWZiMDc4MWFiNGRhOWQ4ZTViMDkzMGUyMjI=
9
+ MDQ4OGMwOWFhODc5NWIwMmNjM2IzMjcxZjk1MGM5ZmFiMThiNTYzNDU3MTFi
10
+ MzgxYjdhZDY3Y2M0OGNhMjZmZmFkNGIyOTVkMDA3YmY4NGJlNTIwMzM1M2U5
11
+ MzNiMGUzZmUwMDhhOTk2MTBiMzEyYzZhMjBkMGMyYjc3ZGQ5YmE=
12
12
  data.tar.gz: !binary |-
13
- NmY3ZGM1NWIyYmYyZTY3MTkzM2IyOTFhNjRhOWQwMGFhZjU4NTgzMjA4ODg1
14
- OGJmYTY1MjJmMDVkZmFlZjY2ZjJmMmMyMDUwNjE3NzVmMDVjMWQyYjVjZDAw
15
- MjUyYWE2OWY0OTcwYjA3ZTI0YzI2NTc4YWIwMTlkMTEzYWRiYzA=
13
+ MTBiMDRjMDk4ZWM2NWMyNmNmNDczMGZmYzg5MDMzMzBiZGI0NWNiMmI0Mjgy
14
+ ZDFmYTk3ZDhhMWViMDBkMGJkODhlMmNjZjliOGM2YzhmYTM4NWZiYmFjODNj
15
+ OTNiMTNiNmMzN2Q0NGVlMmM1YjQ0NjVjM2I5NDY5ZDAzNDZkYTM=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
data/create_folder.rb ADDED
@@ -0,0 +1,118 @@
1
+ $DEBUG= true
2
+
3
+ require 'fileutils'
4
+ require 'debugger'
5
+
6
+
7
+ Dir.glob(File.join(Dir.pwd,'lib','mpatch',"*.{rb,ru}")).each do |file_path|
8
+
9
+ File.open(file_path,"r") do |file|
10
+
11
+ namespace= nil
12
+ folder_path= file_path.split(File::Separator)
13
+ file_name= folder_path.pop
14
+ folder_path.push file_name.split('.')[0]
15
+ folder_path= folder_path.join(File::Separator)
16
+ #FileUtils.mkpath folder_path unless File.exists?(folder_path)
17
+
18
+ array_of_line = [ ]
19
+ block_open = 0
20
+ comments = [ ]
21
+
22
+ file.read.each_line do |file_line|
23
+ file_line.split(';').each do |line|
24
+
25
+
26
+
27
+ method_name= nil
28
+
29
+ #if line.include? "map_hash_obj.each do |hash|"
30
+ # debugger
31
+ #end
32
+
33
+
34
+ %w[ class module ].each do |block_opener|
35
+
36
+ if line.scan(/^\s*#/).empty?
37
+
38
+ if !line.scan(/^\s*\b#{block_opener}\b\s*\w/).empty?
39
+
40
+ namespace ||= line
41
+
42
+ puts "(#{block_open}) + for #{line}" if $DEBUG
43
+ block_open += 1
44
+ break
45
+ end
46
+
47
+ end
48
+ end
49
+
50
+ tmp_end= false
51
+ %w[ if case while until unless def do begin ].each do |block_opener|
52
+
53
+ if line.scan(/^\s*#/).empty?
54
+
55
+ if line.scan(/\bend\b/).empty?
56
+ if !line.scan(/\s*\w*\b#{block_opener}\b/).empty?
57
+
58
+ unless line.include? "&&"
59
+
60
+ puts "(#{block_open}) + for #{line}" if $DEBUG
61
+ block_open += 1
62
+ break
63
+
64
+
65
+ end
66
+
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+
73
+
74
+ if !line.scan(/^\s*#/).empty?
75
+ comments.push line
76
+ end
77
+
78
+ #if block_open > 1 && line.include?("def")
79
+ # puts line
80
+ #end
81
+
82
+ if block_open >= 2
83
+ array_of_line.push line
84
+ end
85
+
86
+
87
+ if line.scan(/^\s*#/).empty?
88
+ if !line.scan(/\bend\b/).empty?
89
+
90
+ puts "(#{block_open}) - for #{line}" if $DEBUG
91
+ block_open -= 1
92
+
93
+ end
94
+ end
95
+
96
+
97
+ if !array_of_line.empty? && block_open == 0
98
+
99
+ #puts array_of_line,"---"
100
+
101
+ #tmp_array = Array.new
102
+ #tmp_array.push namespace
103
+ #tmp_array += comments
104
+ #tmp_array += array_of_line
105
+ #tmp_array.push "end"
106
+ #
107
+ #File.new(File.join(folder_path,method_name.to_s+".rb"),"w").write(tmp_array.join())
108
+
109
+
110
+ array_of_line.clear
111
+ comments.clear
112
+
113
+ end
114
+
115
+ end
116
+ end
117
+ end
118
+ end
data/lib/mpatch/kernel.rb CHANGED
@@ -1,9 +1,10 @@
1
- def putsf(integer,*args)
2
- command_string=String.new
3
- args.each do |one_element|
4
- command_string+="%-#{integer}s"
1
+ module Kernel
2
+ def putsf(integer,*args)
3
+ command_string=String.new
4
+ args.each do |one_element|
5
+ command_string+="%-#{integer}s"
6
+ end
7
+ command_string+="\n"
8
+ printf command_string,*args
5
9
  end
6
- command_string+="\n"
7
- printf command_string,*args
8
- end
9
-
10
+ end
data/lib/mpatch/object.rb CHANGED
@@ -18,13 +18,6 @@ class Object
18
18
  return self
19
19
  end unless method_defined? :must_be
20
20
 
21
- # return the object Binding
22
- def binding?
23
- return binding
24
- end
25
-
26
- alias :get_binding :binding?
27
-
28
21
  # The hidden singleton lurks behind everyone
29
22
  def metaclass; class << self; self; end; end
30
23
 
data/lib/mpatch/proc.rb CHANGED
@@ -9,19 +9,4 @@ class Proc
9
9
  Proc.new { |*args| self[*other[*args]] }
10
10
  end unless method_defined? :*
11
11
 
12
- def call_with_binding(bind, *args)
13
- Bindless.new([bind]).run_proc(self, *args)
14
- end
15
-
16
- def call_with_obj(obj, *args)
17
- m = nil
18
- p = self
19
- Object.class_eval do
20
- define_method :a_temp_method_name, &p
21
- m = instance_method :a_temp_method_name
22
- remove_method :a_temp_method_name
23
- end
24
- m.bind(obj).call(*args)
25
- end
26
-
27
12
  end
data/lib/mpatch/random.rb CHANGED
@@ -1,35 +1,33 @@
1
1
  class RND
2
- class << self
3
- def string(length= 7,amount=1,hyphen= " ")
4
- amount_container= Array.new
5
- amount.times do
6
- mrg= String.new
7
- mrg= (0...length).map{ ('a'..'z').to_a[rand(26)] }.join
8
- amount_container.push mrg
9
- end
10
- return amount_container.join(hyphen)
11
- end
12
- def integer(length= 3)
13
- Random.rand(length)
14
- end
15
- def boolean
16
- rand(2) == 1
17
- end
18
- def time from = Time.at(1114924812), to = Time.now
19
- rand(from..to)
20
- end
21
- def date from = Time.at(1114924812), to = Time.now
22
- rand(from..to).to_date
23
- end
24
- def datetime from = Time.at(1114924812), to = Time.now
25
- rand(from..to).to_datetime
2
+ def self.string(length= 7,amount=1,hyphen= " ")
3
+ amount_container= Array.new
4
+ amount.times do
5
+ mrg= String.new
6
+ mrg= (0...length).map{ ('a'..'z').to_a[rand(26)] }.join
7
+ amount_container.push mrg
26
8
  end
9
+ return amount_container.join(hyphen)
10
+ end
11
+ def self.integer(length= 3)
12
+ Random.rand(length)
13
+ end
14
+ def self.boolean
15
+ rand(2) == 1
16
+ end
17
+ def self.time from = Time.at(1114924812), to = Time.now
18
+ rand(from..to)
19
+ end
20
+ def self.date from = Time.at(1114924812), to = Time.now
21
+ rand(from..to).to_date
22
+ end
23
+ def self.datetime from = Time.at(1114924812), to = Time.now
24
+ rand(from..to).to_datetime
27
25
  end
28
26
  end
29
27
 
30
28
  # alias in Random from RND
31
29
  begin
32
- (RND.singleton_methods-Object.singleton_methods).each do |one_method_sym|
30
+ (RND.singleton_methods-Object.instance_methods).each do |one_method_sym|
33
31
  Random.class_eval do
34
32
  define_singleton_method one_method_sym do |*args|
35
33
  RND.__send__(one_method_sym,*args)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mpatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.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-02-14 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a collection of my Ruby monkey patches for making easer to use
14
14
  the basic classes
@@ -22,6 +22,7 @@ files:
22
22
  - README.md
23
23
  - Rakefile
24
24
  - VERSION
25
+ - create_folder.rb
25
26
  - files.rb
26
27
  - lib/mpatch.rb
27
28
  - lib/mpatch/active_support/str2duck.rb