ric 0.11.7 → 0.11.9
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.yml +2 -0
- data/Manifest +1 -0
- data/TODO +1 -0
- data/VERSION +1 -1
- data/bin/xcopy +23 -73
- data/lib/ric/conf.rb +4 -3
- data/lib/ric/files.rb +3 -2
- data/ric.gemspec +2 -2
- data/test/sample_conf.yml +17 -0
- metadata +4 -3
data/HISTORY.yml
CHANGED
data/Manifest
CHANGED
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.9
|
data/bin/xcopy
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby -wKU
|
2
2
|
|
3
3
|
=begin
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
@history:
|
5
|
+
2011-02-05 1.0.1: better myconf
|
6
|
+
2011-02-05 0.9.1: Created
|
7
7
|
=end
|
8
8
|
|
9
9
|
require 'optparse' # http://ruby.about.com/od/advancedruby/a/optionparser.htm
|
@@ -13,73 +13,27 @@
|
|
13
13
|
require 'yaml'
|
14
14
|
|
15
15
|
|
16
|
-
$PROG_VER = '0.
|
16
|
+
$PROG_VER = '1.0.1'
|
17
17
|
$DEBUG = false
|
18
18
|
|
19
19
|
$myconf = {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
'author' => 'Riccardo Carlesso <riccardo.carlesso@gmail.com>',
|
21
|
+
'description' => 'Please put an interesting description HERE for future use!',
|
22
|
+
'from' => '~/Documents/',
|
23
|
+
'to' => '/tmp/my_docs_backup/',
|
24
|
+
'files' => ["**/{*.{mp3,jpg}}", 'README', 'put', 'your', 'files', 'here' ],
|
25
|
+
'dryrun' => true,
|
25
26
|
}
|
26
27
|
|
27
|
-
def usage(comment=nil)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def travasa(from,to,glob_files, opts={})
|
37
|
-
n_actions = 0
|
38
|
-
puts "+ Travasing: #{yellow from} ==> #{green to}"
|
39
|
-
verbose = opts.fetch :verbose, true
|
40
|
-
|
41
|
-
unless File.exists?("#{to}/.git")
|
42
|
-
fatal 1,"Sorry cant travase data to an unversioned dir, u'know the casin?!?"
|
43
|
-
exit 1
|
44
|
-
end
|
45
|
-
unless File.exists?("#{to}/.safe_travasa")
|
46
|
-
fatal 12, "Sorry cant travase data unless you ask me to. You have to do this before:\n #{yellow "touch #{to}/.safe_travasa"} . Thanks"
|
47
|
-
end
|
48
|
-
|
49
|
-
# With this i can understand what has been deleted, with lots of magic from git on both ends.. :)
|
50
|
-
deb "+ First the differences:"
|
51
|
-
deb `diff -qr #{from} #{to} |egrep -v '\\.git' `
|
52
|
-
|
53
|
-
puts "+ Files: #{cyan glob_files}"
|
54
|
-
Dir.chdir(from)
|
55
|
-
Dir.glob(glob_files).each{ |file|
|
56
|
-
from_file = "#{from}/#{file}"
|
57
|
-
to_file = "#{to}/#{file}"
|
58
|
-
destdir = File.dirname(to_file)
|
59
|
-
deb "Copying: #{yellow from_file}.."
|
60
|
-
# could need creating the dir..
|
61
|
-
if File.exists?(destdir)
|
62
|
-
# just copy the file
|
63
|
-
command = "cp \"#{from_file}\" \"#{to_file}\""
|
64
|
-
else
|
65
|
-
# mkdir dest AND copy file
|
66
|
-
pred "Hey, Dir '#{destdir}' doesnt exist! Creating it.."
|
67
|
-
command = "mkdir -p \"#{destdir}\" && cp \"#{from_file}\" \"#{to_file}\""
|
68
|
-
end
|
69
|
-
|
70
|
-
if opts.fetch(:dryrun, false)
|
71
|
-
puts "[DRYRUN] Skipping #{gray command}"
|
72
|
-
else
|
73
|
-
ret = `#{command} 2>&1`
|
74
|
-
puts "EXE: #{gray command}" if verbose
|
75
|
-
n_actions += 1
|
76
|
-
print( "[ret=$?]", ret, "\n") if (ret.length > 1 || $? != 0) # if output or not zero
|
77
|
-
end
|
78
|
-
}
|
79
|
-
puts "#{n_actions} commands executed."
|
80
|
-
end
|
81
|
-
|
82
|
-
def real_program
|
28
|
+
#def usage(comment=nil)
|
29
|
+
# puts "#{$0} v.#{$PROG_VER}"
|
30
|
+
# puts "Usage: #{File.basename $0} [-dhjv] [-l LOGFILE] <FOO> <BAR>"
|
31
|
+
# puts $opts
|
32
|
+
# pred comment if comment
|
33
|
+
# exit 11
|
34
|
+
#end
|
35
|
+
|
36
|
+
def main
|
83
37
|
debug_on 'Just created script, presuming u need some debug. TODO REMOVE ME when everything works!' if $DEBUG
|
84
38
|
# Maybe you may want to check on ARGV
|
85
39
|
deb "+ Your configuration: #{purple $myconf}"
|
@@ -90,11 +44,13 @@
|
|
90
44
|
File.expand_path(myconf['from']),
|
91
45
|
File.expand_path(myconf['to']),
|
92
46
|
myconf['files'] ,
|
93
|
-
|
47
|
+
myconf
|
48
|
+
#‘’:dryrun => myconf['dryrun'] ,
|
49
|
+
#‘’:description => myconf['dryrun'] ,
|
94
50
|
)
|
95
51
|
end
|
96
52
|
|
97
|
-
# remove me in 0.11.
|
53
|
+
# remove me in 0.11.8!
|
98
54
|
def fatal(ret,str=nil)
|
99
55
|
unless str
|
100
56
|
str = ret
|
@@ -104,10 +60,4 @@
|
|
104
60
|
exit ret
|
105
61
|
end
|
106
62
|
|
107
|
-
def main()
|
108
|
-
#lib_autoinit # if u dont like the autoinit, uncomment init :)
|
109
|
-
real_program
|
110
|
-
end
|
111
|
-
|
112
|
-
#lib_automain(__FILE__)
|
113
63
|
main
|
data/lib/ric/conf.rb
CHANGED
@@ -18,11 +18,12 @@ so you can call load_auto_conf('foo') and it will look throughout any ./.foo.yml
|
|
18
18
|
=end
|
19
19
|
|
20
20
|
def load_auto_conf(confname, opts={})
|
21
|
+
libver = '1.1'
|
21
22
|
dirs = opts.fetch :dirs, ['.', '~', '/etc/', '/etc/ric/auto_conf/']
|
22
23
|
file_patterns = opts.fetch :file_patterns, [".#{confname}.yml", "#{confname}/conf.yml"]
|
23
24
|
sample_hash = opts.fetch :sample_hash, { 'load_auto_conf' => "please add an :sample_hash to me" , :anyway => "I'm in #{__FILE__}"}
|
24
25
|
verbose = opts.fetch :verbose, true
|
25
|
-
puts "load_auto_conf('#{confname}') start.." if verbose
|
26
|
+
puts "load_auto_conf('#{confname}') v#{libver} start.." if verbose
|
26
27
|
dirs.each{|d|
|
27
28
|
dir = File.expand_path(d)
|
28
29
|
deb "DIR: #{dir}"
|
@@ -33,8 +34,8 @@ so you can call load_auto_conf('foo') and it will look throughout any ./.foo.yml
|
|
33
34
|
if File.exists?(file)
|
34
35
|
puts "Found! #{green file}"
|
35
36
|
yaml = YAML.load( File.read(file) )
|
36
|
-
|
37
|
-
return yaml
|
37
|
+
puts "load_auto_conf('#{confname}', v#{libver}) found: #{green yaml}" if verbose
|
38
|
+
return yaml # in the future u can have a host based autoconf! Yay!
|
38
39
|
end
|
39
40
|
}
|
40
41
|
}
|
data/lib/ric/files.rb
CHANGED
@@ -13,11 +13,12 @@ module Ric
|
|
13
13
|
verbose = opts.fetch :verbose, true
|
14
14
|
|
15
15
|
unless File.exists?("#{to}/.git")
|
16
|
-
fatal "Sorry cant travase data to an unversioned dir
|
16
|
+
fatal 11,"Sorry cant travase data to an unversioned dir. Please version it with git (or add a .git dir/file to trick me)"
|
17
17
|
exit 1
|
18
18
|
end
|
19
19
|
unless File.exists?("#{to}/.safe_xcopy")
|
20
|
-
fatal 12, "Sorry
|
20
|
+
fatal 12, "Sorry I refuse to xcopy data unless you explicitly ask me to. You have to do this before:\n #{yellow "touch #{to}/.safe_xcopy"} .
|
21
|
+
You are for sure a very smart person but there are a LOT of people out there who could destroy theyr file system! Thanks"
|
21
22
|
end
|
22
23
|
|
23
24
|
# With this i can understand what has been deleted, with lots of magic from git on both ends.. :)
|
data/ric.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ric}
|
5
|
-
s.version = "0.11.
|
5
|
+
s.version = "0.11.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Riccardo Carlesso"]
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = %q{['p','ll','diusbonton].join('a') @ gmail.com}
|
14
14
|
s.executables = ["itunes", "ric", "riclib-test", "septober", "xcopy"]
|
15
15
|
s.extra_rdoc_files = ["LICENSE", "README.md", "TODO", "bin/itunes", "bin/ric", "bin/riclib-test", "bin/septober", "bin/xcopy", "lib/rails/acts_as_carlesso.rb", "lib/rails/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/colors.rb", "lib/ric/conf.rb", "lib/ric/debug.rb", "lib/ric/files.rb", "lib/ric/html.rb", "lib/ric/zibaldone.rb", "lib/ruby_classes/strings.rb", "lib/tmp/uniquify.rb"]
|
16
|
-
s.files = ["HISTORY.yml", "LICENSE", "Manifest", "README.md", "Rakefile", "TODO", "VERSION", "bin/itunes", "bin/ric", "bin/riclib-test", "bin/septober", "bin/xcopy", "init.rb", "lib/rails/acts_as_carlesso.rb", "lib/rails/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/colors.rb", "lib/ric/conf.rb", "lib/ric/debug.rb", "lib/ric/files.rb", "lib/ric/html.rb", "lib/ric/zibaldone.rb", "lib/ruby_classes/strings.rb", "lib/tmp/uniquify.rb", "rails/init.rb", "sbin/reboot.rb", "sbin/ric_reboot.rb", "test/strings_helper.rb", "test/test_helper.rb", "var/www/index.html", "ric.gemspec"]
|
16
|
+
s.files = ["HISTORY.yml", "LICENSE", "Manifest", "README.md", "Rakefile", "TODO", "VERSION", "bin/itunes", "bin/ric", "bin/riclib-test", "bin/septober", "bin/xcopy", "init.rb", "lib/rails/acts_as_carlesso.rb", "lib/rails/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/colors.rb", "lib/ric/conf.rb", "lib/ric/debug.rb", "lib/ric/files.rb", "lib/ric/html.rb", "lib/ric/zibaldone.rb", "lib/ruby_classes/strings.rb", "lib/tmp/uniquify.rb", "rails/init.rb", "sbin/reboot.rb", "sbin/ric_reboot.rb", "test/sample_conf.yml", "test/strings_helper.rb", "test/test_helper.rb", "var/www/index.html", "ric.gemspec"]
|
17
17
|
s.homepage = %q{http://github.com/palladius/riclib}
|
18
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ric", "--main", "README.md"]
|
19
19
|
s.require_paths = ["lib"]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#Creatd by ric.rb:load_auto_conf()
|
2
|
+
# TODO test with THIS yaml
|
3
|
+
---
|
4
|
+
app_name: ric gem test yaml
|
5
|
+
conf:
|
6
|
+
dryrun: true
|
7
|
+
author: Riccardo Carlesso <riccardo.carlesso@gmail.com>
|
8
|
+
files:
|
9
|
+
- "**/{*.{mp3,jpg}}"
|
10
|
+
- README
|
11
|
+
- put
|
12
|
+
- your
|
13
|
+
- files
|
14
|
+
- here
|
15
|
+
from: ~/git/yaffle_guide/vendor/plugins/ric_admin/
|
16
|
+
to: ~/git/ric_admin/
|
17
|
+
description: Please put an interesting description HERE for future use!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 33
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 11
|
9
|
-
-
|
10
|
-
version: 0.11.
|
9
|
+
- 9
|
10
|
+
version: 0.11.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Riccardo Carlesso
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- rails/init.rb
|
81
81
|
- sbin/reboot.rb
|
82
82
|
- sbin/ric_reboot.rb
|
83
|
+
- test/sample_conf.yml
|
83
84
|
- test/strings_helper.rb
|
84
85
|
- test/test_helper.rb
|
85
86
|
- var/www/index.html
|