clone 1.0.0.alpha → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +1 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +22 -1
  6. data/VERSION +1 -1
  7. data/bin/clone +7 -0
  8. data/clone.gemspec +4 -0
  9. data/docs/readme +16 -0
  10. data/docs/readme.txt +5 -0
  11. data/lib/clone.rb +13 -2
  12. data/lib/clone/config/config.rb +19 -0
  13. data/lib/clone/config/config.yml +22 -0
  14. data/lib/clone/config/default_config.yml +20 -0
  15. data/lib/clone/config/require.rb +3 -0
  16. data/lib/clone/config/version.rb +10 -0
  17. data/lib/clone/config/yml.rb +22 -0
  18. data/lib/clone/config/z_defaults.rb +28 -0
  19. data/lib/clone/generator/engine.rb +581 -0
  20. data/lib/clone/generator/terminal.rb +104 -0
  21. data/lib/clone/helpers/helper_methods.rb +251 -0
  22. data/lib/clone/helpers/local_methods.rb +150 -0
  23. data/lib/clone/helpers/require.rb +37 -0
  24. data/module/Marshal.4.8 +0 -0
  25. data/module/Marshal.4.8.Z +0 -0
  26. data/module/gems/commander-4.1.3/.gitignore +6 -0
  27. data/module/gems/commander-4.1.3/.travis.yml +11 -0
  28. data/module/gems/commander-4.1.3/DEVELOPMENT +15 -0
  29. data/module/gems/commander-4.1.3/Gemfile +3 -0
  30. data/module/gems/commander-4.1.3/History.rdoc +345 -0
  31. data/module/gems/commander-4.1.3/Manifest +38 -0
  32. data/module/gems/commander-4.1.3/README.rdoc +375 -0
  33. data/module/gems/commander-4.1.3/Rakefile +10 -0
  34. data/module/gems/commander-4.1.3/bin/commander +55 -0
  35. data/module/gems/commander-4.1.3/commander.gemspec +26 -0
  36. data/module/gems/commander-4.1.3/lib/commander.rb +32 -0
  37. data/module/gems/commander-4.1.3/lib/commander/blank.rb +8 -0
  38. data/module/gems/commander-4.1.3/lib/commander/command.rb +213 -0
  39. data/module/gems/commander-4.1.3/lib/commander/core_ext.rb +3 -0
  40. data/module/gems/commander-4.1.3/lib/commander/core_ext/array.rb +26 -0
  41. data/module/gems/commander-4.1.3/lib/commander/core_ext/object.rb +11 -0
  42. data/module/gems/commander-4.1.3/lib/commander/delegates.rb +13 -0
  43. data/module/gems/commander-4.1.3/lib/commander/help_formatters.rb +8 -0
  44. data/module/gems/commander-4.1.3/lib/commander/help_formatters/base.rb +18 -0
  45. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal.rb +20 -0
  46. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/command_help.erb +35 -0
  47. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/help.erb +36 -0
  48. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact.rb +12 -0
  49. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/command_help.erb +27 -0
  50. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/help.erb +29 -0
  51. data/module/gems/commander-4.1.3/lib/commander/import.rb +10 -0
  52. data/module/gems/commander-4.1.3/lib/commander/platform.rb +8 -0
  53. data/module/gems/commander-4.1.3/lib/commander/runner.rb +411 -0
  54. data/module/gems/commander-4.1.3/lib/commander/user_interaction.rb +521 -0
  55. data/module/gems/commander-4.1.3/lib/commander/version.rb +3 -0
  56. data/module/gems/commander-4.1.3/spec/command_spec.rb +157 -0
  57. data/module/gems/commander-4.1.3/spec/core_ext/array_spec.rb +20 -0
  58. data/module/gems/commander-4.1.3/spec/core_ext/object_spec.rb +21 -0
  59. data/module/gems/commander-4.1.3/spec/help_formatters/terminal_spec.rb +67 -0
  60. data/module/gems/commander-4.1.3/spec/runner_spec.rb +526 -0
  61. data/module/gems/commander-4.1.3/spec/spec_helper.rb +59 -0
  62. data/module/gems/commander-4.1.3/spec/ui_spec.rb +30 -0
  63. data/module/gems/hello.rb +1 -0
  64. data/module/gems/highline-1.6.19/.gitignore +2 -0
  65. data/module/gems/highline-1.6.19/AUTHORS +3 -0
  66. data/module/gems/highline-1.6.19/CHANGELOG +346 -0
  67. data/module/gems/highline-1.6.19/COPYING +340 -0
  68. data/module/gems/highline-1.6.19/INSTALL +55 -0
  69. data/module/gems/highline-1.6.19/LICENSE +7 -0
  70. data/module/gems/highline-1.6.19/README.rdoc +63 -0
  71. data/module/gems/highline-1.6.19/Rakefile +50 -0
  72. data/module/gems/highline-1.6.19/TODO +6 -0
  73. data/module/gems/highline-1.6.19/examples/ansi_colors.rb +38 -0
  74. data/module/gems/highline-1.6.19/examples/asking_for_arrays.rb +18 -0
  75. data/module/gems/highline-1.6.19/examples/basic_usage.rb +75 -0
  76. data/module/gems/highline-1.6.19/examples/color_scheme.rb +32 -0
  77. data/module/gems/highline-1.6.19/examples/get_character.rb +12 -0
  78. data/module/gems/highline-1.6.19/examples/limit.rb +12 -0
  79. data/module/gems/highline-1.6.19/examples/menus.rb +65 -0
  80. data/module/gems/highline-1.6.19/examples/overwrite.rb +19 -0
  81. data/module/gems/highline-1.6.19/examples/page_and_wrap.rb +322 -0
  82. data/module/gems/highline-1.6.19/examples/password.rb +7 -0
  83. data/module/gems/highline-1.6.19/examples/repeat_entry.rb +21 -0
  84. data/module/gems/highline-1.6.19/examples/trapping_eof.rb +22 -0
  85. data/module/gems/highline-1.6.19/examples/using_readline.rb +17 -0
  86. data/module/gems/highline-1.6.19/highline.gemspec +37 -0
  87. data/module/gems/highline-1.6.19/lib/highline.rb +1012 -0
  88. data/module/gems/highline-1.6.19/lib/highline/color_scheme.rb +134 -0
  89. data/module/gems/highline-1.6.19/lib/highline/compatibility.rb +16 -0
  90. data/module/gems/highline-1.6.19/lib/highline/import.rb +41 -0
  91. data/module/gems/highline-1.6.19/lib/highline/menu.rb +398 -0
  92. data/module/gems/highline-1.6.19/lib/highline/question.rb +475 -0
  93. data/module/gems/highline-1.6.19/lib/highline/simulate.rb +48 -0
  94. data/module/gems/highline-1.6.19/lib/highline/string_extensions.rb +131 -0
  95. data/module/gems/highline-1.6.19/lib/highline/style.rb +181 -0
  96. data/module/gems/highline-1.6.19/lib/highline/system_extensions.rb +222 -0
  97. data/module/gems/highline-1.6.19/setup.rb +1360 -0
  98. data/module/gems/highline-1.6.19/site/.cvsignore +1 -0
  99. data/module/gems/highline-1.6.19/site/highline.css +65 -0
  100. data/module/gems/highline-1.6.19/site/images/logo.png +0 -0
  101. data/module/gems/highline-1.6.19/site/index.html +58 -0
  102. data/module/gems/highline-1.6.19/test/string_methods.rb +32 -0
  103. data/module/gems/highline-1.6.19/test/tc_color_scheme.rb +96 -0
  104. data/module/gems/highline-1.6.19/test/tc_highline.rb +1128 -0
  105. data/module/gems/highline-1.6.19/test/tc_import.rb +52 -0
  106. data/module/gems/highline-1.6.19/test/tc_menu.rb +439 -0
  107. data/module/gems/highline-1.6.19/test/tc_string_extension.rb +20 -0
  108. data/module/gems/highline-1.6.19/test/tc_string_highline.rb +38 -0
  109. data/module/gems/highline-1.6.19/test/tc_style.rb +567 -0
  110. data/module/gems/highline-1.6.19/test/ts_all.rb +16 -0
  111. data/module/latest_specs.4.8 +0 -0
  112. data/module/latest_specs.4.8.gz +0 -0
  113. data/module/prerelease_specs.4.8 +0 -0
  114. data/module/prerelease_specs.4.8.gz +0 -0
  115. data/module/specs.4.8 +0 -0
  116. data/module/specs.4.8.gz +0 -0
  117. data/samples/blather/restlike/Gemfile +4 -0
  118. data/samples/blather/restlike/cmd.yml +1 -0
  119. data/samples/blather/restlike/lib/blather.rb +9 -0
  120. data/samples/blather/restlike/lib/blather/dsl/api.rb +78 -0
  121. data/samples/blather/restlike/lib/blather/dsl/call.rb +13 -0
  122. data/samples/blather/restlike/lib/blather/dsl/client.rb +58 -0
  123. data/samples/blather/restlike/lib/blather/dsl/config.rb +11 -0
  124. data/samples/blather/restlike/lib/blather/dsl/extraDSL.rb +163 -0
  125. data/samples/blather/restlike/lib/blather/meta/require.rb +8 -0
  126. data/samples/blather/restlike/lib/blather/meta/xmpp.yml +5 -0
  127. data/samples/blather/restlike/lib/blather/vendors/xmpp_default.rb +27 -0
  128. data/samples/blather/restlike/readme +2 -0
  129. data/samples/grape/init/Gemfile +2 -0
  130. data/samples/grape/init/cmd.yml +3 -0
  131. data/samples/grape/init/config.ru +2 -0
  132. data/samples/grape/init/docs/grape/documentation.txt +939 -0
  133. data/samples/grape/init/docs/grape/generate_rest_routes.rb +37 -0
  134. data/samples/grape/init/docs/grape/ls_routes.rb +31 -0
  135. data/samples/grape/init/lib/grape.rb +4 -0
  136. data/samples/grape/init/lib/grape/meta/subclasses.rb +20 -0
  137. data/samples/grape/init/lib/grape/xpath/app.rb +30 -0
  138. data/samples/grape/init/lib/grape/xpath/ruotes.rb +6 -0
  139. data/samples/grape/init/readme +1 -0
  140. data/samples/grape/readme +29 -0
  141. data/samples/grape/vendor/lib/grape/vendors/v1/rest.rb +57 -0
  142. data/samples/mongoid/cmd.yml +1 -0
  143. data/samples/mongoid/init/Gemfile +3 -0
  144. data/samples/mongoid/init/cmd.yml +2 -0
  145. data/samples/mongoid/init/docs/mongoid/ModelsRelations.rb +11 -0
  146. data/samples/mongoid/init/docs/mongoid/documents.xls +0 -0
  147. data/samples/mongoid/init/docs/mongoid/generate_modelsToDocs.rb +25 -0
  148. data/samples/mongoid/init/docs/mongoid/modelsToDocs.rb +25 -0
  149. data/samples/mongoid/init/docs/mongoid/relations.txt +1354 -0
  150. data/samples/mongoid/init/lib/mongoid.rb +44 -0
  151. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_CRUD.rb +446 -0
  152. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_MP.rb +517 -0
  153. data/samples/mongoid/init/lib/mongoid/dsl/init.rb +37 -0
  154. data/samples/mongoid/init/lib/mongoid/dsl/params.rb +67 -0
  155. data/samples/mongoid/init/lib/mongoid/meta/banned.rb +147 -0
  156. data/samples/mongoid/init/lib/mongoid/meta/control.yml +13 -0
  157. data/samples/mongoid/init/lib/mongoid/meta/mongoid.yml +6 -0
  158. data/samples/mongoid/init/lib/mongoid/meta/mpatch.rb +14 -0
  159. data/samples/mongoid/model/lib/mongoid/models/model.rb +28 -0
  160. data/samples/mongoid/readme +33 -0
  161. data/samples/rack/init/Gemfile +10 -0
  162. data/samples/rack/init/cmd.yml +2 -0
  163. data/samples/rack/init/config.ru +1 -0
  164. data/samples/rack/init/docs/rack/rake introducing.txt +60 -0
  165. data/samples/rack/init/docs/rack/webservers/Thin +43 -0
  166. data/samples/rack/init/docs/rack/webservers/ebb +72 -0
  167. data/samples/rack/init/docs/rack/webservers/fcgi +103 -0
  168. data/samples/rack/init/docs/rack/webservers/mongrel +74 -0
  169. data/samples/rack/init/docs/rack/webservers/passenger +37 -0
  170. data/samples/rack/init/docs/rack/webservers/scgi +188 -0
  171. data/samples/rack/init/lib/rack.rb +1 -0
  172. data/samples/rack/init/lib/rack/meta/webserver/thin.rb +45 -0
  173. data/samples/rack/init/lib/rack/meta/webserver/thin.yml +6 -0
  174. data/samples/rack/init/server.rb +0 -0
  175. data/samples/rack/readme +13 -0
  176. data/samples/rest_client/init/Gemfile +5 -0
  177. data/samples/rest_client/init/boot.rb +2 -0
  178. data/samples/rest_client/init/cmd.yml +1 -0
  179. data/samples/rest_client/init/config/rest_client/defaults.rb +16 -0
  180. data/samples/rest_client/init/docs/rest_client/simple overlook +251 -0
  181. data/samples/rest_client/init/test/rest_client/rest_dsl.rb +5 -0
  182. data/samples/rest_client/readme +7 -0
  183. data/samples/scripts/lines_counter/lines_number.rb +32 -0
  184. data/samples/scripts/lines_counter/readme +5 -0
  185. data/samples/scripts/readme +1 -0
  186. metadata +197 -7
  187. data/lib/clone/cms.rb +0 -56
  188. data/lib/clone/ext.rb +0 -77
  189. data/sample/test.rb +0 -30
@@ -0,0 +1,104 @@
1
+ #encoding: UTF-8
2
+ module Clone
3
+
4
+ ##require File.join "rubygems"
5
+ require File.join "commander", "import"
6
+
7
+ begin
8
+ ### Program runtime parameters
9
+ program :name, "#{self.to_s.split('::')[0].downcase}"
10
+ program :version, VERSION.show
11
+ program :description, "#{self.to_s.split('::')[0].downcase} commandline control"
12
+
13
+ #command :set do |c|
14
+ # c.syntax = "#{self.to_s.split("::")[0].downcase} set --option value"
15
+ # c.description = "help configure the generator params"
16
+ # c.option "--structured true/false" , String , "set, that does generating follow the samples folder structure or not"
17
+ # c.action do |args, options|
18
+ #
19
+ # if !options.structured.nil?
20
+ # if options.structured == "true"
21
+ # SampleConfig.yml_data['structured']= true
22
+ # Yaml.set SampleConfig.yml_data
23
+ # elsif options.structured == "false"
24
+ # SampleConfig.yml_data['structured']= false
25
+ # Yaml.set SampleConfig.yml_data
26
+ # else
27
+ # puts "undefined value for structured option:\n\tuse 'true' or 'false'"
28
+ # end
29
+ # end
30
+ #
31
+ # end
32
+ #end
33
+
34
+ [:build,:generate].each do |one_sym|
35
+
36
+ command one_sym.to_sym do |c|
37
+
38
+ if one_sym == :build
39
+ c.syntax = "gen generate cat cmd name str or --cat name --cmd name --name file_name --str true/false"
40
+ c.description= "help Generate samples from the sample collection\n\t"+
41
+ "categories:\n\t\t#{show_categories.gsub(':','')}"+
42
+ "\n\tcommands:\n\t\t#{show_commands.gsub(':','')}"+
43
+ "\n\tDescriptions:\n\n\t\t#{show_readmes}"
44
+ else
45
+ c.syntax= "same for build command"
46
+ c.description= "alias for build command"
47
+ end
48
+
49
+ c.option "--name file_name" , String , "choose file name, this is optionable, not required"
50
+ c.option "--cat category_name" , String , "choose the category"
51
+ c.option "--cmd command_name" , String , "choose the command"
52
+ c.option "--str true/false" , String , "choose to either you want or not keep sample "+
53
+ "structure or generate everything in place"
54
+
55
+ c.option "--debug"
56
+ c.action do |args, options|
57
+
58
+ if options.debug
59
+ $DEBUG = true
60
+ end
61
+
62
+ ### Get options or else args
63
+ begin
64
+ if (options.cat).nil?
65
+ category = args[0]
66
+ else
67
+ category = options.cat
68
+ end
69
+ if (options.cmd).nil?
70
+ command = args[1]
71
+ else
72
+ command = options.cmd
73
+ end
74
+ if (options.name).nil?
75
+ file_name = args[2]
76
+ else
77
+ file_name = options.name
78
+ end
79
+ if (options.str).nil?
80
+ structured = args[3]
81
+ else
82
+ structured = options.str
83
+ end
84
+ end
85
+
86
+ ### Do the job
87
+ begin
88
+ command_for_sample_generate :category => category,
89
+ :command => command,
90
+ :structured => structured,
91
+ :file_name => file_name
92
+ end
93
+
94
+
95
+
96
+ end
97
+ end
98
+
99
+
100
+ end
101
+
102
+ end
103
+
104
+ end
@@ -0,0 +1,251 @@
1
+ ### Helper methods
2
+ module Clone
3
+
4
+ ### ClassMethods
5
+ begin
6
+ class << self
7
+
8
+ #Based on the rb location
9
+ def load_directory(directory,*args)
10
+ arg = Hash[*args]
11
+
12
+ #directory = File.expand_path(directory)
13
+ delayed_loads = Array.new
14
+
15
+ if !arg[:delayed].nil?
16
+ raise ArgumentError, "Delayed items must be in an "+\
17
+ "Array! Example:\n:delayed => ['abc']" if arg[:delayed].class != Array
18
+ end
19
+
20
+ if !arg[:excluded].nil?
21
+ raise ArgumentError, "Exclude items must be in an "+\
22
+ "Array! Example:\n:exclude => ['abc']" if arg[:excluded].class != Array
23
+ end
24
+
25
+ arg[:type] ||= "rb"
26
+ arg[:monkey_patch] ||= 0
27
+ #=============================================================================================================
28
+
29
+ ### GET Pre path + validation
30
+ begin
31
+ #get method callers path
32
+
33
+ pre_path = caller[arg[:monkey_patch].to_i].split('.rb:').first+('.rb')
34
+
35
+ if !pre_path.include?('/') && !pre_path.include?('\\')
36
+ pre_path = File.expand_path(pre_path)
37
+ end
38
+
39
+ separator_symbol= String.new
40
+ pre_path.include?('/') ? separator_symbol = '/' : separator_symbol = '\\'
41
+
42
+ pre_path= ((pre_path.split(separator_symbol))-([pre_path.split(separator_symbol).pop])).join(separator_symbol)
43
+
44
+ end
45
+
46
+ puts "prepath: "+pre_path.inspect if $DEBUG
47
+
48
+ puts "LOADING_FILES_FROM_"+directory.to_s.split(separator_symbol).last.split('.').first.capitalize if $DEBUG
49
+
50
+ puts "Elements found in #{directory}" if $DEBUG
51
+ puts File.join("#{pre_path}","#{directory}","**","*.#{arg[:type]}") if $DEBUG
52
+ puts Dir[File.join("#{pre_path}","#{directory}","**","*.#{arg[:type]}")].sort.inspect if $DEBUG
53
+
54
+ Dir[File.join("#{pre_path}","#{directory}","**","*.#{arg[:type]}")].sort.each do |file|
55
+
56
+ arg[:delayed]= [nil] if arg[:delayed].nil?
57
+ arg[:excluded]= [nil] if arg[:excluded].nil?
58
+
59
+ arg[:excluded].each do |except|
60
+ if file.split(separator_symbol).last.split('.').first == except.to_s.split('.').first
61
+
62
+ puts file.to_s + " cant be loaded because it's an exception" if $DEBUG
63
+
64
+ else
65
+
66
+ arg[:delayed].each do |delay|
67
+
68
+ if file.split(separator_symbol).last.split('.').first == delay.to_s.split('.').first
69
+ delayed_loads.push(file)
70
+ else
71
+ load(file)
72
+ puts file.to_s if $DEBUG
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+ end
79
+ end
80
+ delayed_loads.each do |delayed_load_element|
81
+ load(delayed_load_element)
82
+ puts delayed_load_element.to_s if $DEBUG
83
+ end
84
+ puts "DONE_LOAD_FILES_FROM_"+directory.to_s.split(separator_symbol).last.split('.').first.capitalize if $DEBUG
85
+
86
+ end
87
+
88
+ def error_logger(error_msg,prefix="",log_file=App.log_path)
89
+
90
+ ###convert error msg to more human friendly one
91
+ begin
92
+ error_msg= error_msg.to_s.gsub('", "','",'+"\n\"")
93
+ rescue Exception
94
+ error_msg= error_msg.inspect.gsub('", "','",'+"\n\"")
95
+ end
96
+
97
+ if File.exists?(File.expand_path(log_file))
98
+ error_log = File.open( File.expand_path(log_file), "a+")
99
+ error_log << "\n#{Time.now} | #{prefix}#{":" if prefix != ""} #{error_msg}"
100
+ error_log.close
101
+ else
102
+ File.new(File.expand_path(log_file), "w").write(
103
+ "#{Time.now} | #{prefix}#{":" if prefix != ""} #{error_msg}"
104
+ )
105
+ end
106
+
107
+ return {:error => error_msg}
108
+ end
109
+
110
+ def load_ymls(directory,*args)
111
+ arg= Hash[*args]
112
+
113
+ require 'yaml'
114
+ #require "hashie"
115
+
116
+ arg[:monkey_patch]= 0 if arg[:monkey_patch].nil?
117
+
118
+
119
+ ### GET Pre path + validation
120
+ begin
121
+ #get method callers path
122
+ pre_path = caller[arg[:monkey_patch].to_i].split('.rb:').first+('.rb')
123
+ if !pre_path.include?('/') && !pre_path.include?('\\')
124
+ pre_path = File.expand_path(pre_path)
125
+ end
126
+ separator_symbol= String.new
127
+ pre_path.include?('/') ? separator_symbol = '/' : separator_symbol = '\\'
128
+ pre_path= ((pre_path.split(separator_symbol))-([pre_path.split(separator_symbol).pop])).join(separator_symbol)
129
+ end
130
+
131
+ puts "Elements found in #{directory}" if $DEBUG
132
+ puts File.join("#{pre_path}","#{directory}","**","*.yml") if $DEBUG
133
+ puts Dir[File.join("#{pre_path}","#{directory}","**","*.yml")].sort.inspect if $DEBUG
134
+
135
+ yaml_files = Dir[File.join("#{pre_path}","#{directory}","**","*.yml")].sort
136
+
137
+ puts "\nyaml file found: "+yaml_files.inspect if $DEBUG
138
+
139
+ @result_hash = {}
140
+ yaml_files.each_with_index do |full_path_file_name|
141
+
142
+
143
+ file_name = full_path_file_name.split(separator_symbol).last.split(separator_symbol).first
144
+
145
+ hash_key = file_name
146
+ @result_hash[hash_key] = YAML.load(File.read("#{full_path_file_name}"))
147
+
148
+ #@result_hash = @result_hash.merge!(tmp_hash)
149
+
150
+
151
+ puts "==========================================================" if $DEBUG
152
+ puts "Loading "+file_name.to_s.capitalize+"\n" if $DEBUG
153
+ puts YAML.load(File.read("#{full_path_file_name}")) if $DEBUG
154
+ puts "__________________________________________________________" if $DEBUG
155
+
156
+ end
157
+
158
+ puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" if $DEBUG
159
+ puts "The Main Hash: \n"+@result_hash.inspect.to_s if $DEBUG
160
+ puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" if $DEBUG
161
+
162
+ return @result_hash
163
+ end
164
+
165
+ def create_on_filesystem(route_name,optionable_file_mod="w",optionable_data=nil)
166
+ begin
167
+
168
+ #file_name generate
169
+ if !route_name.to_s.split(File::SEPARATOR).last.nil? || route_name.to_s.split(File::SEPARATOR).last != ''
170
+ file_name = route_name.to_s.split(File::SEPARATOR).last
171
+ else
172
+ file_name = nil?
173
+ end
174
+
175
+ #path_way
176
+ begin
177
+ raise ArgumentError, "missing route_name: #{route_name}" if route_name.nil?
178
+ path = File.expand_path(route_name).to_s.split(File::SEPARATOR)
179
+ path = path - [File.expand_path(route_name).to_s.split(File::SEPARATOR).last]
180
+ path.shift
181
+ end
182
+
183
+ #job
184
+ begin
185
+ if !Dir.exists?(File::SEPARATOR+path.join(File::SEPARATOR))
186
+
187
+ at_now = File::SEPARATOR
188
+ path.each do |dir_to_be_checked|
189
+
190
+ at_now += "#{dir_to_be_checked+File::SEPARATOR}"
191
+ Dir.mkdir(at_now) if !Dir.exists?(at_now)
192
+
193
+ end
194
+ end
195
+ end
196
+
197
+ #file_create
198
+ File.new("#{File::SEPARATOR+path.join(File::SEPARATOR)+File::SEPARATOR}#{file_name}", optionable_file_mod ).write optionable_data
199
+
200
+ rescue Exception => ex
201
+ puts ex
202
+ end
203
+ end
204
+
205
+ def clone_mpath(original_path,new_name)
206
+ log_path = File.expand_path(original_path)
207
+ log_path = log_path.split(File::SEPARATOR)
208
+ log_path.pop
209
+ log_path.push(new_name)
210
+ log_path = log_path.join(File::SEPARATOR)
211
+ return log_path
212
+ end
213
+
214
+ end
215
+ end
216
+
217
+ ### Config
218
+ begin
219
+ class App
220
+ class << self
221
+ attr_accessor :log_path,
222
+ :pid_path,
223
+ :daemon_stderr,
224
+ :exceptions,
225
+ :exlogger,
226
+ :app_name,
227
+ :port,
228
+ :terminate
229
+ end
230
+ end
231
+ end
232
+
233
+ ### Default
234
+ begin
235
+ App.log_path = "./var/log/logfile.log"
236
+ App.pid_path = "./var/pid/pidfile.pid"
237
+ #App.terminate = false
238
+ #App.port = 80
239
+ App.app_name = $0
240
+
241
+ begin
242
+ ['daemon_stderr','exceptions','exlogger'].each do |one_log|
243
+
244
+ App.__send__(one_log+"=",clone_mpath(App.log_path,one_log+".log"))
245
+
246
+ end
247
+ end
248
+
249
+ end
250
+
251
+ end
@@ -0,0 +1,150 @@
1
+ #monkey patch
2
+ begin
3
+ ### find and replace given targets
4
+ def process_running?(input)
5
+ Clone.process_running?(input)
6
+ end
7
+ def require_directory(directory,*args)
8
+ Clone.load_directory(directory,{:monkey_patch => 1},*args)
9
+ end
10
+ def require_ymls(directory)
11
+ Clone.load_ymls(
12
+ directory,
13
+ {:monkey_patch => 1}
14
+ )
15
+ end
16
+ def get_port(port,max_port=65535 ,host="0.0.0.0")
17
+ Clone.get_port(port,max_port,host)
18
+ end
19
+ def exlogger(error_msg,*args)
20
+ arg=Hash[*args]
21
+ arg[:prefix] = String.new if arg[:prefix].nil?
22
+ arg[:path] = Clone::App.exlogger if arg[:path].nil?
23
+ Clone.create_on_filesystem arg[:path],
24
+ 'a+'
25
+ Clone.error_logger(error_msg,arg[:prefix],arg[:path])
26
+ end
27
+ class Exception
28
+ def logger
29
+ Clone.create_on_filesystem Clone::App.exceptions,
30
+ 'a+'
31
+ Clone.error_logger(self.backtrace,self,Clone::App.exceptions)
32
+ end
33
+ end
34
+ class File
35
+ def self.new!(file,optionable_data=nil,optionable_file_mod="w")
36
+ Clone.create_on_filesystem file,
37
+ optionable_file_mod,
38
+ optionable_data
39
+ end
40
+ def self.create(*args)
41
+ arg = Hash[*args]
42
+
43
+ begin
44
+
45
+ ### Validation
46
+ raise ArgumentError, "invalid or missing path!" if arg[:path].nil? || arg[:path].to_s.length <= 0
47
+ route_name = arg[:path]
48
+
49
+ if arg[:file_mod].nil?
50
+ optionable_file_mod="w"
51
+ else
52
+ optionable_file_mod=arg[:file_mod]
53
+ end
54
+
55
+ if arg[:data].nil?
56
+ optionable_data=nil
57
+ else
58
+ optionable_data=arg[:data]
59
+ end
60
+
61
+ end
62
+
63
+ Clone.create_on_filesystem route_name,
64
+ optionable_file_mod,
65
+ optionable_data
66
+ end
67
+ end
68
+ class Class
69
+ def class_methods
70
+ self.methods - Object.methods
71
+ end
72
+ def self.class_methods
73
+ self.methods - Object.methods
74
+ end
75
+ end
76
+ class Rnd
77
+ class << self
78
+ def string(length,amount=1)
79
+ mrg = String.new
80
+ first_string = true
81
+ amount.times do
82
+ a_string = Random.rand(length)
83
+ a_string == 0 ? a_string += 1 : a_string
84
+ mrg_prt = (0...a_string).map{ ('a'..'z').to_a[rand(26)] }.join
85
+ first_string ? mrg += mrg_prt : mrg+= " #{mrg_prt}"
86
+ first_string = false
87
+ end
88
+ return mrg
89
+ end
90
+ def integer(length)
91
+ Random.rand(length)
92
+ end
93
+ def boolean
94
+ rand(2) == 1
95
+ end
96
+ def date from = Time.at(1114924812), to = Time.now
97
+ rand(from..to)
98
+ end
99
+ end
100
+ end
101
+ class Array
102
+ def index_of(target_element)
103
+ array = self
104
+ hash = Hash[array.map.with_index.to_a]
105
+ return hash[target_element]
106
+ end
107
+ def pinch n=1
108
+ return self[0..(self.count-2)]
109
+ end
110
+ end
111
+ class Hash
112
+ #pass single or array of keys, which will be removed, returning the remaining hash
113
+ def remove!(*keys)
114
+ keys.each{|key| self.delete(key) }
115
+ self
116
+ end
117
+ #non-destructive version
118
+ def remove(*keys)
119
+ self.dup.remove!(*keys)
120
+ end
121
+ end
122
+ class String
123
+ def positions(oth_string)
124
+
125
+ special_chrs=%w[# _ & < > @ $ . , -]+[*(0..9)]+[*("A".."Z")]+[*("a".."z")]
126
+ loop do
127
+ if oth_string.include? special_chrs[0]
128
+ special_chrs.shift
129
+ else
130
+ break
131
+ end
132
+ end
133
+
134
+ string=self
135
+ return_array = Array.new
136
+ loop do
137
+ break if string.index(oth_string).nil?
138
+ range_value= ((string.index(oth_string))..(string.index(oth_string)+oth_string.length-1))
139
+ return_array.push range_value
140
+ [*range_value].each do |one_index|
141
+ string[one_index]= special_chrs[0]
142
+ end
143
+ end
144
+
145
+ ### return value
146
+ return return_array
147
+ end
148
+ end
149
+
150
+ end