ric 0.11.6 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  # would like to have this in YML format :)
2
+ 2011-02-06 v0.11.7:
3
+ - small small bug that forced u to include require yaml..
4
+ - added debug funcs like 'fatal' and 'warning'
2
5
  2011-02-06 v0.11.6:
3
6
  - Added xconf
4
7
  2011-02-06 v0.11.5:
data/Manifest CHANGED
@@ -9,6 +9,7 @@ bin/itunes
9
9
  bin/ric
10
10
  bin/riclib-test
11
11
  bin/septober
12
+ bin/xcopy
12
13
  init.rb
13
14
  lib/rails/acts_as_carlesso.rb
14
15
  lib/rails/helpers/rails_helper.rb
@@ -22,7 +23,6 @@ lib/ric/zibaldone.rb
22
23
  lib/ruby_classes/strings.rb
23
24
  lib/tmp/uniquify.rb
24
25
  rails/init.rb
25
- ric.gemspec
26
26
  sbin/reboot.rb
27
27
  sbin/ric_reboot.rb
28
28
  test/strings_helper.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.6
1
+ 0.11.7
data/bin/xcopy ADDED
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ =begin
4
+
5
+ @template_history:
6
+ 2011-02-05 1.0.0: Created
7
+ =end
8
+
9
+ require 'optparse' # http://ruby.about.com/od/advancedruby/a/optionparser.htm
10
+ #require '~/lib/ric.rb'
11
+ require 'rubygems'
12
+ require 'ric'
13
+ require 'yaml'
14
+
15
+
16
+ $PROG_VER = '0.9.1'
17
+ $DEBUG = false
18
+
19
+ $myconf = {
20
+ 'app_name' => 'travasa_plugin',
21
+ 'from' => '~/git/yaffle_guide/vendor/plugins/ric_admin/',
22
+ 'to' => '~/git/ric_admin/',
23
+ 'files' => ["**/{*.{rb,sh}}", 'README', 'VERSION', 'HISTORY.yml', 'Rakefile' , '.gitignore' ],
24
+ 'dryrun' => true
25
+ }
26
+
27
+ def usage(comment=nil)
28
+ puts "#{$0} v.#{$PROG_VER}"
29
+ puts "Usage2: #{File.basename $0} [-dhjv] [-l LOGFILE] <FOO> <BAR>"
30
+ puts $opts
31
+ pred comment if comment
32
+ exit 11
33
+ end
34
+
35
+ # similar to xcopy
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
83
+ debug_on 'Just created script, presuming u need some debug. TODO REMOVE ME when everything works!' if $DEBUG
84
+ # Maybe you may want to check on ARGV
85
+ deb "+ Your configuration: #{purple $myconf}"
86
+ include Ric::Conf
87
+ include Ric::Files
88
+ myconf = load_auto_conf('xcopy', :sample_hash => $myconf)
89
+ xcopy(
90
+ File.expand_path(myconf['from']),
91
+ File.expand_path(myconf['to']),
92
+ myconf['files'] ,
93
+ :dryrun => myconf['dryrun']
94
+ )
95
+ end
96
+
97
+ # remove me in 0.11.7!
98
+ def fatal(ret,str=nil)
99
+ unless str
100
+ str = ret
101
+ ret = 66
102
+ end
103
+ STDERR.puts "#{red 'XCpFatal (remove me from gem 0.11.7!)'}(#{ret}) #{str}"
104
+ exit ret
105
+ end
106
+
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
+ main
data/lib/ric/conf.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Ric
2
2
  module Conf
3
3
 
4
+ require 'yaml'
4
5
 
5
6
  =begin
6
7
  This wants to be a magic configuration loader who looks for configuration automatically in many places, like:
data/lib/ric/debug.rb CHANGED
@@ -30,12 +30,83 @@ module Ric
30
30
  end #/debug2()
31
31
  alias :debug :deb
32
32
 
33
- class RicDebug
34
- def self.help
35
- puts 'TODO RicDebug. This is experimental, u shouldnt use this at all!'
33
+ =begin
34
+
35
+ This is a denbug with steroids
36
+
37
+ Introduced tags: NORMAL deb() works.
38
+ If you launch debug_on('reason', :tags => [ :this, :foo, :bar])
39
+ from this moment on normal debug is prevented unless you debug using the explicit tags..
40
+
41
+ Il vecchio debug era:
42
+ debug (s, :really_write => true,:write_always => false )
43
+
44
+ =end
45
+ $_debug_tags = []
46
+ def debug_with_steroids(s, opts = {} )
47
+ out = opts.fetch(:out, $stdout)
48
+ tag = opts.fetch(:tag, '_DFLT_')
49
+ really_write = opts.fetch(:really_write, true) # you can prevent ANY debug setting this to false
50
+ write_always = opts.fetch(:write_always, false)
51
+
52
+ raise "ERROR: ':tags' must be an array in debug(), maybe you meant to use :tag?" if ( opts[:tags] && opts[:tags].class != Array )
53
+ final_str = "#RDeb#{write_always ? '!' : ''}[#{opts[:tag] || '-'}] #{s}"
54
+ final_str = "\033[1;30m" +final_str + "\033[0m" if opts.fetch(:coloured_debug, true) # color by gray by default
55
+ if (debug_tags_enabled? ) # tags
56
+ puts( final_str ) if debug_tag_include?( opts )
57
+ else # normal behaviour: if NOT tag
58
+ puts( final_str ) if ((really_write && $DEBUG) || write_always) && ! opts[:tag]
36
59
  end
37
-
60
+ end #/debug()
61
+ def debug_tags_enabled?
62
+ $_debug_tags != []
38
63
  end
64
+ def debug_tag_include?(opts)
65
+ assert_array($_debug_tags, 'debug_tags')
66
+ assert_class( opts[:tag], Symbol, "tag must be a symbol, ", :dontdie => true ) if opts[:tag]
67
+ assert_array( opts[:tags] , 'opts[:tags]' ) if opts[:tags]
68
+ return $_debug_tags.include?(opts[:tag].to_sym) if opts[:tag]
69
+ return ($_debug_tags & opts[:tags]).size > 0 if opts[:tags]
70
+ #return $_debug_tags.include?(tag_or_tags.to_sym) if (tag.class == String || tag.class == Symbol)
71
+ return false
72
+ end
73
+
74
+ # if DEBUG is true, then execute the code
75
+ def deb?()
76
+ yield if $DEBUG
77
+ end
78
+ alias :if_deb :deb?
79
+ alias :if_deb? :deb?
80
+
81
+ def debug?()
82
+ $DEBUG == true
83
+ end
84
+
85
+ def err(str)
86
+ $stderr.puts "ERR[RicLib] #{$0}: '#{str}'"
87
+ end
88
+
89
+ def fatal(ret,str)
90
+ err "#{get_red 'RubyFatal'}(#{ret}) #{str}"
91
+ exit ret
92
+ end
93
+
94
+ def warning(s)
95
+ err "#{yellow 'WARN'} #{s}"
96
+ end
97
+
98
+ def tbd(comment="TODO")
99
+ puts "#{white :TBD} (#{__FILE__}:#{__LINE__}): #{comment}"
100
+ raise "TBD_EXCEPTION! ''#{comment}''"
101
+ end
102
+
103
+ private
104
+ def _manage_debug_tags(opts)
105
+ $_debug_tags ||= []
106
+ $_debug_tags += opts[:tags] if opts[:tags]
107
+ $_debug_tags = $_debug_tags.uniq
108
+ deb "_manage_debug_tags(): new tags are: #{$_debug_tags}", :tag => :debug
109
+ end
39
110
 
40
111
  end # /module Colors
41
112
  end # /module Ric
data/lib/ric.rb CHANGED
@@ -17,4 +17,6 @@ module Ric
17
17
  end
18
18
 
19
19
  include Ric::Colors
20
+ include Ric::Conf
20
21
  include Ric::Debug
22
+ include Ric::Files
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.6"
5
+ s.version = "0.11.7"
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"]
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
  My name is Riccardo, hence 'ric' (ok I admit it, this was just ot prove Im able to build a sentence
12
12
  with hence!)}
13
13
  s.email = %q{['p','ll','diusbonton].join('a') @ gmail.com}
14
- s.executables = ["itunes", "ric", "riclib-test", "septober"]
15
- s.extra_rdoc_files = ["LICENSE", "README.md", "TODO", "bin/itunes", "bin/ric", "bin/riclib-test", "bin/septober", "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", "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", "ric.gemspec", "sbin/reboot.rb", "sbin/ric_reboot.rb", "test/strings_helper.rb", "test/test_helper.rb", "var/www/index.html"]
14
+ s.executables = ["itunes", "ric", "riclib-test", "septober", "xcopy"]
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"]
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"]
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: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 6
10
- version: 0.11.6
9
+ - 7
10
+ version: 0.11.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Riccardo Carlesso
@@ -29,6 +29,7 @@ executables:
29
29
  - ric
30
30
  - riclib-test
31
31
  - septober
32
+ - xcopy
32
33
  extensions: []
33
34
 
34
35
  extra_rdoc_files:
@@ -39,6 +40,7 @@ extra_rdoc_files:
39
40
  - bin/ric
40
41
  - bin/riclib-test
41
42
  - bin/septober
43
+ - bin/xcopy
42
44
  - lib/rails/acts_as_carlesso.rb
43
45
  - lib/rails/helpers/rails_helper.rb
44
46
  - lib/ric.rb
@@ -62,6 +64,7 @@ files:
62
64
  - bin/ric
63
65
  - bin/riclib-test
64
66
  - bin/septober
67
+ - bin/xcopy
65
68
  - init.rb
66
69
  - lib/rails/acts_as_carlesso.rb
67
70
  - lib/rails/helpers/rails_helper.rb
@@ -75,12 +78,12 @@ files:
75
78
  - lib/ruby_classes/strings.rb
76
79
  - lib/tmp/uniquify.rb
77
80
  - rails/init.rb
78
- - ric.gemspec
79
81
  - sbin/reboot.rb
80
82
  - sbin/ric_reboot.rb
81
83
  - test/strings_helper.rb
82
84
  - test/test_helper.rb
83
85
  - var/www/index.html
86
+ - ric.gemspec
84
87
  has_rdoc: true
85
88
  homepage: http://github.com/palladius/riclib
86
89
  licenses: []