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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -1
- data/VERSION +1 -1
- data/bin/clone +7 -0
- data/clone.gemspec +4 -0
- data/docs/readme +16 -0
- data/docs/readme.txt +5 -0
- data/lib/clone.rb +13 -2
- data/lib/clone/config/config.rb +19 -0
- data/lib/clone/config/config.yml +22 -0
- data/lib/clone/config/default_config.yml +20 -0
- data/lib/clone/config/require.rb +3 -0
- data/lib/clone/config/version.rb +10 -0
- data/lib/clone/config/yml.rb +22 -0
- data/lib/clone/config/z_defaults.rb +28 -0
- data/lib/clone/generator/engine.rb +581 -0
- data/lib/clone/generator/terminal.rb +104 -0
- data/lib/clone/helpers/helper_methods.rb +251 -0
- data/lib/clone/helpers/local_methods.rb +150 -0
- data/lib/clone/helpers/require.rb +37 -0
- data/module/Marshal.4.8 +0 -0
- data/module/Marshal.4.8.Z +0 -0
- data/module/gems/commander-4.1.3/.gitignore +6 -0
- data/module/gems/commander-4.1.3/.travis.yml +11 -0
- data/module/gems/commander-4.1.3/DEVELOPMENT +15 -0
- data/module/gems/commander-4.1.3/Gemfile +3 -0
- data/module/gems/commander-4.1.3/History.rdoc +345 -0
- data/module/gems/commander-4.1.3/Manifest +38 -0
- data/module/gems/commander-4.1.3/README.rdoc +375 -0
- data/module/gems/commander-4.1.3/Rakefile +10 -0
- data/module/gems/commander-4.1.3/bin/commander +55 -0
- data/module/gems/commander-4.1.3/commander.gemspec +26 -0
- data/module/gems/commander-4.1.3/lib/commander.rb +32 -0
- data/module/gems/commander-4.1.3/lib/commander/blank.rb +8 -0
- data/module/gems/commander-4.1.3/lib/commander/command.rb +213 -0
- data/module/gems/commander-4.1.3/lib/commander/core_ext.rb +3 -0
- data/module/gems/commander-4.1.3/lib/commander/core_ext/array.rb +26 -0
- data/module/gems/commander-4.1.3/lib/commander/core_ext/object.rb +11 -0
- data/module/gems/commander-4.1.3/lib/commander/delegates.rb +13 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters.rb +8 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/base.rb +18 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal.rb +20 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/command_help.erb +35 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/help.erb +36 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact.rb +12 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/command_help.erb +27 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/help.erb +29 -0
- data/module/gems/commander-4.1.3/lib/commander/import.rb +10 -0
- data/module/gems/commander-4.1.3/lib/commander/platform.rb +8 -0
- data/module/gems/commander-4.1.3/lib/commander/runner.rb +411 -0
- data/module/gems/commander-4.1.3/lib/commander/user_interaction.rb +521 -0
- data/module/gems/commander-4.1.3/lib/commander/version.rb +3 -0
- data/module/gems/commander-4.1.3/spec/command_spec.rb +157 -0
- data/module/gems/commander-4.1.3/spec/core_ext/array_spec.rb +20 -0
- data/module/gems/commander-4.1.3/spec/core_ext/object_spec.rb +21 -0
- data/module/gems/commander-4.1.3/spec/help_formatters/terminal_spec.rb +67 -0
- data/module/gems/commander-4.1.3/spec/runner_spec.rb +526 -0
- data/module/gems/commander-4.1.3/spec/spec_helper.rb +59 -0
- data/module/gems/commander-4.1.3/spec/ui_spec.rb +30 -0
- data/module/gems/hello.rb +1 -0
- data/module/gems/highline-1.6.19/.gitignore +2 -0
- data/module/gems/highline-1.6.19/AUTHORS +3 -0
- data/module/gems/highline-1.6.19/CHANGELOG +346 -0
- data/module/gems/highline-1.6.19/COPYING +340 -0
- data/module/gems/highline-1.6.19/INSTALL +55 -0
- data/module/gems/highline-1.6.19/LICENSE +7 -0
- data/module/gems/highline-1.6.19/README.rdoc +63 -0
- data/module/gems/highline-1.6.19/Rakefile +50 -0
- data/module/gems/highline-1.6.19/TODO +6 -0
- data/module/gems/highline-1.6.19/examples/ansi_colors.rb +38 -0
- data/module/gems/highline-1.6.19/examples/asking_for_arrays.rb +18 -0
- data/module/gems/highline-1.6.19/examples/basic_usage.rb +75 -0
- data/module/gems/highline-1.6.19/examples/color_scheme.rb +32 -0
- data/module/gems/highline-1.6.19/examples/get_character.rb +12 -0
- data/module/gems/highline-1.6.19/examples/limit.rb +12 -0
- data/module/gems/highline-1.6.19/examples/menus.rb +65 -0
- data/module/gems/highline-1.6.19/examples/overwrite.rb +19 -0
- data/module/gems/highline-1.6.19/examples/page_and_wrap.rb +322 -0
- data/module/gems/highline-1.6.19/examples/password.rb +7 -0
- data/module/gems/highline-1.6.19/examples/repeat_entry.rb +21 -0
- data/module/gems/highline-1.6.19/examples/trapping_eof.rb +22 -0
- data/module/gems/highline-1.6.19/examples/using_readline.rb +17 -0
- data/module/gems/highline-1.6.19/highline.gemspec +37 -0
- data/module/gems/highline-1.6.19/lib/highline.rb +1012 -0
- data/module/gems/highline-1.6.19/lib/highline/color_scheme.rb +134 -0
- data/module/gems/highline-1.6.19/lib/highline/compatibility.rb +16 -0
- data/module/gems/highline-1.6.19/lib/highline/import.rb +41 -0
- data/module/gems/highline-1.6.19/lib/highline/menu.rb +398 -0
- data/module/gems/highline-1.6.19/lib/highline/question.rb +475 -0
- data/module/gems/highline-1.6.19/lib/highline/simulate.rb +48 -0
- data/module/gems/highline-1.6.19/lib/highline/string_extensions.rb +131 -0
- data/module/gems/highline-1.6.19/lib/highline/style.rb +181 -0
- data/module/gems/highline-1.6.19/lib/highline/system_extensions.rb +222 -0
- data/module/gems/highline-1.6.19/setup.rb +1360 -0
- data/module/gems/highline-1.6.19/site/.cvsignore +1 -0
- data/module/gems/highline-1.6.19/site/highline.css +65 -0
- data/module/gems/highline-1.6.19/site/images/logo.png +0 -0
- data/module/gems/highline-1.6.19/site/index.html +58 -0
- data/module/gems/highline-1.6.19/test/string_methods.rb +32 -0
- data/module/gems/highline-1.6.19/test/tc_color_scheme.rb +96 -0
- data/module/gems/highline-1.6.19/test/tc_highline.rb +1128 -0
- data/module/gems/highline-1.6.19/test/tc_import.rb +52 -0
- data/module/gems/highline-1.6.19/test/tc_menu.rb +439 -0
- data/module/gems/highline-1.6.19/test/tc_string_extension.rb +20 -0
- data/module/gems/highline-1.6.19/test/tc_string_highline.rb +38 -0
- data/module/gems/highline-1.6.19/test/tc_style.rb +567 -0
- data/module/gems/highline-1.6.19/test/ts_all.rb +16 -0
- data/module/latest_specs.4.8 +0 -0
- data/module/latest_specs.4.8.gz +0 -0
- data/module/prerelease_specs.4.8 +0 -0
- data/module/prerelease_specs.4.8.gz +0 -0
- data/module/specs.4.8 +0 -0
- data/module/specs.4.8.gz +0 -0
- data/samples/blather/restlike/Gemfile +4 -0
- data/samples/blather/restlike/cmd.yml +1 -0
- data/samples/blather/restlike/lib/blather.rb +9 -0
- data/samples/blather/restlike/lib/blather/dsl/api.rb +78 -0
- data/samples/blather/restlike/lib/blather/dsl/call.rb +13 -0
- data/samples/blather/restlike/lib/blather/dsl/client.rb +58 -0
- data/samples/blather/restlike/lib/blather/dsl/config.rb +11 -0
- data/samples/blather/restlike/lib/blather/dsl/extraDSL.rb +163 -0
- data/samples/blather/restlike/lib/blather/meta/require.rb +8 -0
- data/samples/blather/restlike/lib/blather/meta/xmpp.yml +5 -0
- data/samples/blather/restlike/lib/blather/vendors/xmpp_default.rb +27 -0
- data/samples/blather/restlike/readme +2 -0
- data/samples/grape/init/Gemfile +2 -0
- data/samples/grape/init/cmd.yml +3 -0
- data/samples/grape/init/config.ru +2 -0
- data/samples/grape/init/docs/grape/documentation.txt +939 -0
- data/samples/grape/init/docs/grape/generate_rest_routes.rb +37 -0
- data/samples/grape/init/docs/grape/ls_routes.rb +31 -0
- data/samples/grape/init/lib/grape.rb +4 -0
- data/samples/grape/init/lib/grape/meta/subclasses.rb +20 -0
- data/samples/grape/init/lib/grape/xpath/app.rb +30 -0
- data/samples/grape/init/lib/grape/xpath/ruotes.rb +6 -0
- data/samples/grape/init/readme +1 -0
- data/samples/grape/readme +29 -0
- data/samples/grape/vendor/lib/grape/vendors/v1/rest.rb +57 -0
- data/samples/mongoid/cmd.yml +1 -0
- data/samples/mongoid/init/Gemfile +3 -0
- data/samples/mongoid/init/cmd.yml +2 -0
- data/samples/mongoid/init/docs/mongoid/ModelsRelations.rb +11 -0
- data/samples/mongoid/init/docs/mongoid/documents.xls +0 -0
- data/samples/mongoid/init/docs/mongoid/generate_modelsToDocs.rb +25 -0
- data/samples/mongoid/init/docs/mongoid/modelsToDocs.rb +25 -0
- data/samples/mongoid/init/docs/mongoid/relations.txt +1354 -0
- data/samples/mongoid/init/lib/mongoid.rb +44 -0
- data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_CRUD.rb +446 -0
- data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_MP.rb +517 -0
- data/samples/mongoid/init/lib/mongoid/dsl/init.rb +37 -0
- data/samples/mongoid/init/lib/mongoid/dsl/params.rb +67 -0
- data/samples/mongoid/init/lib/mongoid/meta/banned.rb +147 -0
- data/samples/mongoid/init/lib/mongoid/meta/control.yml +13 -0
- data/samples/mongoid/init/lib/mongoid/meta/mongoid.yml +6 -0
- data/samples/mongoid/init/lib/mongoid/meta/mpatch.rb +14 -0
- data/samples/mongoid/model/lib/mongoid/models/model.rb +28 -0
- data/samples/mongoid/readme +33 -0
- data/samples/rack/init/Gemfile +10 -0
- data/samples/rack/init/cmd.yml +2 -0
- data/samples/rack/init/config.ru +1 -0
- data/samples/rack/init/docs/rack/rake introducing.txt +60 -0
- data/samples/rack/init/docs/rack/webservers/Thin +43 -0
- data/samples/rack/init/docs/rack/webservers/ebb +72 -0
- data/samples/rack/init/docs/rack/webservers/fcgi +103 -0
- data/samples/rack/init/docs/rack/webservers/mongrel +74 -0
- data/samples/rack/init/docs/rack/webservers/passenger +37 -0
- data/samples/rack/init/docs/rack/webservers/scgi +188 -0
- data/samples/rack/init/lib/rack.rb +1 -0
- data/samples/rack/init/lib/rack/meta/webserver/thin.rb +45 -0
- data/samples/rack/init/lib/rack/meta/webserver/thin.yml +6 -0
- data/samples/rack/init/server.rb +0 -0
- data/samples/rack/readme +13 -0
- data/samples/rest_client/init/Gemfile +5 -0
- data/samples/rest_client/init/boot.rb +2 -0
- data/samples/rest_client/init/cmd.yml +1 -0
- data/samples/rest_client/init/config/rest_client/defaults.rb +16 -0
- data/samples/rest_client/init/docs/rest_client/simple overlook +251 -0
- data/samples/rest_client/init/test/rest_client/rest_dsl.rb +5 -0
- data/samples/rest_client/readme +7 -0
- data/samples/scripts/lines_counter/lines_number.rb +32 -0
- data/samples/scripts/lines_counter/readme +5 -0
- data/samples/scripts/readme +1 -0
- metadata +197 -7
- data/lib/clone/cms.rb +0 -56
- data/lib/clone/ext.rb +0 -77
- data/sample/test.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f1bf7364749820489fcb871623e253dcf406190
|
4
|
+
data.tar.gz: dda9b9b6d4a9c09673bd47c4fca0db7e54c92ccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd087415c29cb49867504199a7303d762bbe6777d62372114f99db6294c19cbe0918910e3064322e778d0d46467baf15b48ea8a05f4474cceba0877838df1be2
|
7
|
+
data.tar.gz: 8146a894a19ee4b52c35b2c0c93dfcae80bb629f1d416d8c8c079ae6e952c206c0cf6c3d17cf5dae94a72efcd09126842247cc83ef7b06ec267fc0314763ed73
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Adam Luzsi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
-
|
1
|
+
Clone
|
2
2
|
=====
|
3
3
|
|
4
4
|
File system based sample cloner for projects
|
5
|
+
The main logic is to make the a simple to use,
|
6
|
+
terminal based sample generator.
|
7
|
+
|
8
|
+
It's in the early stage at this point, but the goals:
|
9
|
+
|
10
|
+
* generate samples from sample collection
|
11
|
+
* provide terminal helps for "navigating" between the samples
|
12
|
+
* provide functions for
|
13
|
+
* generate samples from folders
|
14
|
+
* helpers for modify samples
|
15
|
+
* clone function for random folders and helper to replace Module names
|
16
|
+
|
17
|
+
To install this app type
|
18
|
+
|
19
|
+
$ gem install clone
|
20
|
+
|
21
|
+
To get the functions type this to the terminal
|
22
|
+
|
23
|
+
$ clone --help
|
24
|
+
|
25
|
+
All help is welcomed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta
|
data/bin/clone
ADDED
data/clone.gemspec
CHANGED
@@ -9,6 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.description = %q{ File system based sample cloner. You can build new projects with it, or merge,reuse parts from one or other. }
|
10
10
|
spec.summary = %q{ Tool making projects from samples and vice versa }
|
11
11
|
|
12
|
+
spec.homepage = "https://github.com/adamluzsi/clone"
|
13
|
+
|
12
14
|
spec.files = `git ls-files`.split($/)
|
13
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
@@ -17,4 +19,6 @@ Gem::Specification.new do |spec|
|
|
17
19
|
spec.add_development_dependency "bundler"
|
18
20
|
spec.add_development_dependency "rake"
|
19
21
|
|
22
|
+
spec.add_dependency "commander"
|
23
|
+
|
20
24
|
end
|
data/docs/readme
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
A programot ruby kornyezet elleneben csak siman (terminalbol)
|
2
|
+
"rake install"
|
3
|
+
paranccsal telepitjuk is az alkalmazast
|
4
|
+
|
5
|
+
innentol kezdve akar hol vagyunk (terminal) a
|
6
|
+
"gen --help" vagy "gen help" nevu parancscsal megtudhatjuk az osszes eddig implementalt mintat es dokumentaciot
|
7
|
+
egy modul inicializalasa seged dokumentaciokat is letrehoz a tanulasahoz
|
8
|
+
|
9
|
+
A "generate" nevu parancsot mindig a project konyvtaranak gyokerebol adjuk le!
|
10
|
+
pl.:
|
11
|
+
|
12
|
+
mkdir my_project
|
13
|
+
cd my_project
|
14
|
+
gen generate **** *** ***
|
15
|
+
|
16
|
+
s a generator elvegzi a dolgot
|
data/docs/readme.txt
ADDED
data/lib/clone.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
1
|
module Clone;end
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
require 'loader'
|
4
|
+
|
5
|
+
### Apply monkey patch
|
6
|
+
require_relative_directory_r File.join "clone","helpers"
|
7
|
+
|
8
|
+
### Directory loader
|
9
|
+
require_relative_directory_r File.join "clone","config"
|
10
|
+
|
11
|
+
if defined? Clone::GCMD && Clone::GCMD[:state] == true
|
12
|
+
require File.join "clone","generator","engine"
|
13
|
+
require File.join "clone","generator","terminal"
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Clone
|
2
|
+
|
3
|
+
### Create Singleton for config params
|
4
|
+
class SampleConfig
|
5
|
+
class << self
|
6
|
+
attr_accessor :module_name,
|
7
|
+
:class_name,
|
8
|
+
:samples_path,
|
9
|
+
:structured,
|
10
|
+
:yml_file_path,
|
11
|
+
:yml_data,
|
12
|
+
:cmd_file_name,
|
13
|
+
:readme_file_names,
|
14
|
+
:special_file_names
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
structured: true
|
2
|
+
module_name: MODULE
|
3
|
+
class_name: CLASS
|
4
|
+
resource_name: RESOURCE
|
5
|
+
cmd_file_name: cmd.yml
|
6
|
+
readme_file_names:
|
7
|
+
- readme
|
8
|
+
- readme.txt
|
9
|
+
- ReadMe
|
10
|
+
- ReadMe.txt
|
11
|
+
- read_me
|
12
|
+
- read_me.txt
|
13
|
+
special_file_names:
|
14
|
+
- server.rb
|
15
|
+
- server
|
16
|
+
- boot.rb
|
17
|
+
- boot
|
18
|
+
- rakefile
|
19
|
+
- Rakefile
|
20
|
+
- gemfile
|
21
|
+
- Gemfile
|
22
|
+
- config.ru
|
@@ -0,0 +1,20 @@
|
|
1
|
+
structured: true
|
2
|
+
module_name: MODULE
|
3
|
+
class_name: CLASS
|
4
|
+
resource_name: RESOURCE
|
5
|
+
cmd_file_name: cmd.yml
|
6
|
+
readme_file_names:
|
7
|
+
- readme
|
8
|
+
- readme.txt
|
9
|
+
- ReadMe
|
10
|
+
- ReadMe.txt
|
11
|
+
- read_me
|
12
|
+
- read_me.txt
|
13
|
+
special_file_names:
|
14
|
+
- boot.rb
|
15
|
+
- boot
|
16
|
+
- rakefile
|
17
|
+
- Rakefile
|
18
|
+
- gemfile
|
19
|
+
- Gemfile
|
20
|
+
- config.ru
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Clone
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
### YML control
|
5
|
+
begin
|
6
|
+
class Yaml
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def set(config_hash)
|
10
|
+
SampleConfig.yml_data = config_hash
|
11
|
+
File.open(SampleConfig.yml_file_path, 'w+') {|f| f.write(SampleConfig.yml_data.to_yaml) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def load(file_path=SampleConfig.yml_file_path)
|
15
|
+
SampleConfig.yml_data = YAML.load(File.open(file_path))
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Clone
|
2
|
+
|
3
|
+
### Set Defaults
|
4
|
+
begin
|
5
|
+
|
6
|
+
### Set basic paths
|
7
|
+
begin
|
8
|
+
SampleConfig.samples_path = File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","samples"))
|
9
|
+
SampleConfig.yml_file_path = File.expand_path(File.join(File.dirname(__FILE__),"config.yml"))
|
10
|
+
end
|
11
|
+
|
12
|
+
### Yml data
|
13
|
+
begin
|
14
|
+
Yaml.load
|
15
|
+
end
|
16
|
+
|
17
|
+
### Config params
|
18
|
+
begin
|
19
|
+
SampleConfig.class_name = SampleConfig.yml_data['class_name']
|
20
|
+
SampleConfig.module_name = SampleConfig.yml_data['module_name']
|
21
|
+
SampleConfig.cmd_file_name = SampleConfig.yml_data['cmd_file_name']
|
22
|
+
SampleConfig.readme_file_names = SampleConfig.yml_data['readme_file_names']
|
23
|
+
SampleConfig.special_file_names = SampleConfig.yml_data['special_file_names']
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,581 @@
|
|
1
|
+
module Clone
|
2
|
+
class << self
|
3
|
+
### Generator method parts
|
4
|
+
begin
|
5
|
+
|
6
|
+
### Get exception files list #Return Array
|
7
|
+
def get_exceptions
|
8
|
+
|
9
|
+
return_array= Array.new
|
10
|
+
return_array= SampleConfig.readme_file_names
|
11
|
+
return_array.push SampleConfig.cmd_file_name
|
12
|
+
|
13
|
+
return return_array
|
14
|
+
end
|
15
|
+
|
16
|
+
### Get Directory list #Return Hash name:path
|
17
|
+
def get_directories(path)
|
18
|
+
#### Get Directories list
|
19
|
+
begin
|
20
|
+
|
21
|
+
### Check that does the path is absolute or not
|
22
|
+
if path != File.expand_path(path)
|
23
|
+
path = File.expand_path(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
### Generate directory lists with absolute paths
|
27
|
+
directories = Hash.new
|
28
|
+
Dir[File.join( path, '**')].uniq.each do |file_path|
|
29
|
+
if File.directory? file_path
|
30
|
+
directories[file_path.split(File::SEPARATOR).last.to_sym]= file_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
return directories
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
### Get files from path #Return Hash name:path
|
39
|
+
def get_files(path)
|
40
|
+
|
41
|
+
### Pre def. variables
|
42
|
+
begin
|
43
|
+
files = Hash.new
|
44
|
+
end
|
45
|
+
|
46
|
+
### Validation
|
47
|
+
begin
|
48
|
+
### Check that does the path is absolute or not
|
49
|
+
if path != File.expand_path(path)
|
50
|
+
path = File.expand_path(path)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
### Get Files list
|
55
|
+
begin
|
56
|
+
Dir[File.join(path,'**','*')].uniq.each do |file_path|
|
57
|
+
if !File.directory? file_path
|
58
|
+
files[file_path.split(File::SEPARATOR).last.to_sym]= file_path
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
return files
|
64
|
+
end
|
65
|
+
|
66
|
+
### Show Category list #Return: Hash
|
67
|
+
def get_categories_hash(root=SampleConfig.samples_path)
|
68
|
+
begin
|
69
|
+
get_directories root
|
70
|
+
rescue Errno::ENOENT
|
71
|
+
### nothing to do! YAY...
|
72
|
+
return nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
### Show Category participants name in a array
|
77
|
+
def show_categories(is_array=false,root=SampleConfig.samples_path)
|
78
|
+
begin
|
79
|
+
|
80
|
+
return_array = Array.new
|
81
|
+
get_categories_hash(root).each do |one_file_name,one_file_path|
|
82
|
+
return_array.push one_file_name
|
83
|
+
end
|
84
|
+
|
85
|
+
if is_array
|
86
|
+
return return_array
|
87
|
+
else
|
88
|
+
return return_array.join(', ')
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
rescue Errno::ENOENT
|
93
|
+
### nothing to do! YAY...
|
94
|
+
return nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
### Show Category commands
|
99
|
+
def get_commands_hash(category_name,root=SampleConfig.samples_path)
|
100
|
+
|
101
|
+
get_categories_hash(root).each do |file_name,file_path|
|
102
|
+
if file_name.to_s.downcase == category_name.to_s.downcase
|
103
|
+
return get_directories file_path
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
### Get command structure by file_data_array:file_path
|
110
|
+
def get_command_structure(category_name,command_name)
|
111
|
+
|
112
|
+
files_hash = Hash.new
|
113
|
+
get_commands_hash(category_name).each do |directory_name,directory_path|
|
114
|
+
if directory_name.to_s.downcase == command_name.to_s.downcase
|
115
|
+
|
116
|
+
get_files(directory_path).each do |file_name,file_path|
|
117
|
+
tmp_string_array = Array.new
|
118
|
+
|
119
|
+
## Read data out from the file
|
120
|
+
File.open(file_path).each do |one_line|
|
121
|
+
tmp_string_array.push one_line
|
122
|
+
end
|
123
|
+
|
124
|
+
### Make hash with the data String:Path
|
125
|
+
## generate dynamic path cutter length
|
126
|
+
begin
|
127
|
+
|
128
|
+
cut_from = SampleConfig.samples_path.to_s.length+1+\
|
129
|
+
category_name.to_s.length+1+\
|
130
|
+
command_name.to_s.length+1
|
131
|
+
|
132
|
+
cut_to = file_path.to_s.length-1
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
## Do the hash populate
|
137
|
+
files_hash[tmp_string_array]=file_path[cut_from..cut_to]
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
return files_hash
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
### Show Category commands
|
149
|
+
def show_commands(category_name=nil,is_array=false,root=SampleConfig.samples_path)
|
150
|
+
|
151
|
+
sum_array = Array.new
|
152
|
+
merge_hash = Hash.new
|
153
|
+
get_categories_hash(root).each do |category,path_to_category|
|
154
|
+
|
155
|
+
tmp_array=Array.new
|
156
|
+
if category_name.nil?
|
157
|
+
get_directories(path_to_category).each do |file_name,file_path|
|
158
|
+
tmp_array.push file_name
|
159
|
+
end
|
160
|
+
else
|
161
|
+
if file_name.to_s.downcase == category_name.to_s.downcase
|
162
|
+
get_directories(path_to_category).each do |file_name,file_path|
|
163
|
+
tmp_array.push file_name
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
merge_hash[category]=tmp_array
|
168
|
+
|
169
|
+
tmp_array.each do |one_element_of_tmp_array|
|
170
|
+
sum_array.push one_element_of_tmp_array
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
### Return the value
|
176
|
+
if is_array
|
177
|
+
return sum_array
|
178
|
+
else
|
179
|
+
return_string = String.new
|
180
|
+
merge_hash.each do |category,elements|
|
181
|
+
return_string+= "In "+category.to_s+ ": " + elements.inspect + ", "
|
182
|
+
end
|
183
|
+
return_string[return_string.length-2]=String.new
|
184
|
+
|
185
|
+
return return_string
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
### Show readmes from categories
|
190
|
+
def show_readmes(*args)
|
191
|
+
arg=Hash[*args]
|
192
|
+
|
193
|
+
### Set default variables
|
194
|
+
begin
|
195
|
+
|
196
|
+
arg[:root] ||= SampleConfig.samples_path
|
197
|
+
arg[:readme] ||= SampleConfig.readme_file_names
|
198
|
+
ready_paths = Array.new
|
199
|
+
tmp_array = Array.new
|
200
|
+
|
201
|
+
## Make readme-s united
|
202
|
+
if arg[:readme].class != Array
|
203
|
+
arg[:readme] = [arg[:readme]]
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
### Start searching for readme
|
209
|
+
begin
|
210
|
+
get_categories_hash(arg[:root]).each do |category_name,category_path|
|
211
|
+
|
212
|
+
### Get category readme list
|
213
|
+
begin
|
214
|
+
tmp_array.push "\n"
|
215
|
+
Dir[File.join(category_path,'*')].uniq.each do |category_file_path|
|
216
|
+
#if !File.directory? category_file_path
|
217
|
+
if arg[:readme].include? category_file_path.split(File::SEPARATOR).last
|
218
|
+
tmp_array.push "\t\t#{category_name.upcase}:\n"
|
219
|
+
File.open(category_file_path).each do |one_line|
|
220
|
+
tmp_array.push "\t\t\t#{one_line}"
|
221
|
+
end
|
222
|
+
tmp_array.push "\n"
|
223
|
+
ready_paths.push category_file_path
|
224
|
+
end
|
225
|
+
#end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
### Get category commands readme list
|
230
|
+
begin
|
231
|
+
Dir[File.join(category_path,'**','*')].uniq.each do |category_file_path|
|
232
|
+
if !File.directory? category_file_path
|
233
|
+
if !ready_paths.include? category_file_path
|
234
|
+
if arg[:readme].include? category_file_path.split(File::SEPARATOR).last
|
235
|
+
tmp_array.push "\n"
|
236
|
+
recursive_path= category_file_path[(category_path.length+1)..(category_file_path.length-1)]
|
237
|
+
tmp_array.push "\t\t#{category_name.upcase}/#{recursive_path.split(File::SEPARATOR)[0]}:\n"
|
238
|
+
File.open(category_file_path).each do |one_line|
|
239
|
+
tmp_array.push "\t\t\t#{one_line}"
|
240
|
+
end
|
241
|
+
tmp_array.push "\n"
|
242
|
+
ready_paths.push category_file_path
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
return tmp_array.join()
|
253
|
+
end
|
254
|
+
|
255
|
+
### this will only update bootfile isntead deleting the data
|
256
|
+
def update_special_file(create_path,input_string_array)
|
257
|
+
|
258
|
+
### default variables
|
259
|
+
begin
|
260
|
+
data_string = String.new
|
261
|
+
file_mod = "w"
|
262
|
+
end
|
263
|
+
|
264
|
+
### Update!
|
265
|
+
begin
|
266
|
+
|
267
|
+
### File write prepare
|
268
|
+
begin
|
269
|
+
|
270
|
+
if !File.exist?(create_path)
|
271
|
+
File.create :path => create_path,
|
272
|
+
:data => String.new,
|
273
|
+
:file_mod => file_mod
|
274
|
+
end
|
275
|
+
|
276
|
+
begin
|
277
|
+
|
278
|
+
merge_code = Array.new
|
279
|
+
source_code = String.new
|
280
|
+
|
281
|
+
### Create the old code block!
|
282
|
+
File.open(create_path).each do |one_line_of_source_code|
|
283
|
+
if one_line_of_source_code.gsub(' ','') != "\n"
|
284
|
+
merge_code.push one_line_of_source_code
|
285
|
+
source_code += one_line_of_source_code
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
### add a seperator line to the code
|
290
|
+
begin
|
291
|
+
merge_code.push "\n"
|
292
|
+
end
|
293
|
+
|
294
|
+
### Adding new lines
|
295
|
+
input_string_array.each do |target_line|
|
296
|
+
if !source_code.include? target_line
|
297
|
+
#puts target_line
|
298
|
+
merge_code.push target_line
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
### sub complete file data
|
303
|
+
data_string = merge_code.join
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
### File Write
|
309
|
+
begin
|
310
|
+
|
311
|
+
### prepeare data
|
312
|
+
begin
|
313
|
+
new_data= "\n"
|
314
|
+
new_data+= data_string
|
315
|
+
end
|
316
|
+
|
317
|
+
File.open(create_path,file_mod) do |file|
|
318
|
+
file.write new_data
|
319
|
+
end
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
#File.create :path => create_path,
|
324
|
+
# :data => data_string,
|
325
|
+
# :file_mod => file_mod
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
### Clone a command from the sample collection
|
333
|
+
def clone_sample(*args)
|
334
|
+
arg=Hash[*args]
|
335
|
+
begin
|
336
|
+
|
337
|
+
### 'Exception' throw
|
338
|
+
begin
|
339
|
+
|
340
|
+
### Check the two important argument
|
341
|
+
if arg[:category].nil? || arg[:command].nil?
|
342
|
+
if arg[:command].nil?
|
343
|
+
puts "missing chosen command"
|
344
|
+
end
|
345
|
+
if arg[:category].nil?
|
346
|
+
puts "missing chosen category"
|
347
|
+
end
|
348
|
+
|
349
|
+
return nil
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
### Generate Defaults
|
355
|
+
begin
|
356
|
+
|
357
|
+
### method variables
|
358
|
+
begin
|
359
|
+
|
360
|
+
##structured
|
361
|
+
begin
|
362
|
+
if arg[:structured] == "true"
|
363
|
+
arg[:structured]= true
|
364
|
+
elsif arg[:structured] == "false"
|
365
|
+
arg[:structured]= false
|
366
|
+
else
|
367
|
+
arg[:structured]= nil
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
arg[:file_name] ||= String.new
|
372
|
+
arg[:structured] ||= SampleConfig.yml_data['structured']
|
373
|
+
arg[:root] ||= SampleConfig.samples_path
|
374
|
+
#arg[:command] ||= "participant"
|
375
|
+
#arg[:category] ||= "general"
|
376
|
+
#arg[:module] ||= nil
|
377
|
+
#arg[:class] ||= nil
|
378
|
+
#arg[:file_name] ||= nil
|
379
|
+
|
380
|
+
end
|
381
|
+
|
382
|
+
### local variables
|
383
|
+
begin
|
384
|
+
|
385
|
+
samples = Hash.new
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
end
|
390
|
+
|
391
|
+
### Create samples
|
392
|
+
begin
|
393
|
+
|
394
|
+
### Generate sample from structure #=> String:short_path
|
395
|
+
begin
|
396
|
+
|
397
|
+
### Generate Structure
|
398
|
+
get_command_structure(arg[:category],arg[:command]).each do |data_array,short_path|
|
399
|
+
|
400
|
+
### Some dynamical value set
|
401
|
+
begin
|
402
|
+
|
403
|
+
### Generate Auto Module name
|
404
|
+
if arg[:module].nil? || arg[:file_name]==String.new
|
405
|
+
module_name = short_path.split(File::SEPARATOR).pinch.last.split('.')[0].downcase.capitalize
|
406
|
+
else
|
407
|
+
module_name = arg[:module]
|
408
|
+
end
|
409
|
+
|
410
|
+
### Generate Auto Class name
|
411
|
+
if arg[:file_name].nil? || arg[:file_name]==String.new
|
412
|
+
class_name = short_path.split(File::SEPARATOR).last.split('.')[0].downcase.capitalize
|
413
|
+
else
|
414
|
+
class_name = arg[:file_name].downcase.capitalize
|
415
|
+
end
|
416
|
+
|
417
|
+
|
418
|
+
### Generate Auto Resource name
|
419
|
+
if arg[:file_name].nil? || arg[:file_name]==String.new
|
420
|
+
resource_name = short_path.split(File::SEPARATOR).last.split('.')[0].downcase
|
421
|
+
else
|
422
|
+
resource_name = arg[:file_name].downcase
|
423
|
+
end
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
### do the data_array formation/replace
|
428
|
+
begin
|
429
|
+
begin
|
430
|
+
linenmb=0
|
431
|
+
data_array.each do |one_line|
|
432
|
+
data_array[linenmb]= data_array[linenmb].gsub(
|
433
|
+
SampleConfig.yml_data['module_name'],module_name
|
434
|
+
).gsub(
|
435
|
+
SampleConfig.yml_data['class_name'],class_name
|
436
|
+
).gsub(
|
437
|
+
SampleConfig.yml_data['resource_name'],resource_name
|
438
|
+
)
|
439
|
+
linenmb+=1
|
440
|
+
end
|
441
|
+
rescue ArgumentError
|
442
|
+
end
|
443
|
+
|
444
|
+
end
|
445
|
+
|
446
|
+
### Populate_hash
|
447
|
+
begin
|
448
|
+
|
449
|
+
samples[data_array]= File.expand_path short_path
|
450
|
+
|
451
|
+
end
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
end
|
456
|
+
|
457
|
+
### Create files on filesystem
|
458
|
+
begin
|
459
|
+
|
460
|
+
file_created = 0
|
461
|
+
samples.each do |final_string_array,short_path|
|
462
|
+
|
463
|
+
extension = String.new
|
464
|
+
if short_path.include? '.'
|
465
|
+
extension= '.'+short_path.split('.').last
|
466
|
+
end
|
467
|
+
|
468
|
+
begin
|
469
|
+
begin
|
470
|
+
if arg[:file_name] != String.new && !arg[:file_name].nil?
|
471
|
+
arg[:file_name]= "_"+arg[:file_name]
|
472
|
+
end
|
473
|
+
end
|
474
|
+
file_path= short_path.split(File::SEPARATOR).pinch.join(File::SEPARATOR)
|
475
|
+
file_name= (short_path.split(File::SEPARATOR).last.split('.')[0]+arg[:file_name])+extension
|
476
|
+
end
|
477
|
+
|
478
|
+
if arg[:structured]
|
479
|
+
create_path = File.join(
|
480
|
+
file_path,file_name
|
481
|
+
)
|
482
|
+
else
|
483
|
+
create_path = File.join(
|
484
|
+
short_path.split(File::SEPARATOR).last.split('.')[0]+
|
485
|
+
arg[:file_name]+file_created.to_s+extension
|
486
|
+
)
|
487
|
+
end
|
488
|
+
|
489
|
+
### Create the File!
|
490
|
+
if SampleConfig.special_file_names.include?(create_path.split(File::SEPARATOR).last)
|
491
|
+
update_special_file(create_path,final_string_array)
|
492
|
+
else
|
493
|
+
if !get_exceptions.include? short_path.split(File::SEPARATOR).last
|
494
|
+
if File.exist?(create_path)
|
495
|
+
puts "File already exist at #{create_path}" if $DEBUG
|
496
|
+
else
|
497
|
+
File.create :path => create_path,
|
498
|
+
:data => final_string_array.join
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|
502
|
+
file_created+=1
|
503
|
+
end
|
504
|
+
|
505
|
+
end
|
506
|
+
|
507
|
+
end
|
508
|
+
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
### after part for command launch
|
513
|
+
def extension_command(*args)
|
514
|
+
arg=Hash[*args]
|
515
|
+
begin
|
516
|
+
get_command_structure(arg[:category],arg[:command]).each do |file_string,short_path|
|
517
|
+
|
518
|
+
file_path = File.join(SampleConfig.samples_path,arg[:category],arg[:command],short_path)
|
519
|
+
file_name = file_path.split(File::SEPARATOR).last
|
520
|
+
if file_name == SampleConfig.cmd_file_name
|
521
|
+
(YAML.load(File.open(file_path))).each do |category,command|
|
522
|
+
|
523
|
+
clone_sample :category => category.to_s,
|
524
|
+
:command => command.to_s,
|
525
|
+
:file_name => arg[:file_name],
|
526
|
+
:structured => arg[:structured]
|
527
|
+
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
### Prev part for command launch
|
535
|
+
def command_for_sample_generate(*args)
|
536
|
+
arg=Hash[*args]
|
537
|
+
|
538
|
+
### variables
|
539
|
+
begin
|
540
|
+
#:category
|
541
|
+
#:command
|
542
|
+
#:structured
|
543
|
+
#:file_name
|
544
|
+
end
|
545
|
+
|
546
|
+
## validation and job
|
547
|
+
begin
|
548
|
+
|
549
|
+
extension_command :category => arg[:category],
|
550
|
+
:command => arg[:command],
|
551
|
+
:file_name => arg[:file_name],
|
552
|
+
:structured => arg[:structured]
|
553
|
+
|
554
|
+
clone_sample :category => arg[:category],
|
555
|
+
:command => arg[:command],
|
556
|
+
:file_name => arg[:file_name],
|
557
|
+
:structured => arg[:structured]
|
558
|
+
|
559
|
+
end
|
560
|
+
|
561
|
+
end
|
562
|
+
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
=begin
|
570
|
+
implementations:
|
571
|
+
|
572
|
+
#rescue Exception
|
573
|
+
|
574
|
+
#require 'fileutils'
|
575
|
+
#
|
576
|
+
##def copy_with_path(src, dst)
|
577
|
+
# FileUtils.mkdir_p(File.dirname())
|
578
|
+
# FileUtils.cp(src, dst)
|
579
|
+
##end
|
580
|
+
|
581
|
+
=end
|