ric 0.9.7 → 0.10.2alpha

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  # would like to have this in YML format :)
2
2
 
3
+ 2011-01-16 v0.10.1:
4
+ - moving everything! Its a miracle if it still works.. in fact it doesnt
3
5
  2011-01-16 v0.9.7:
4
6
  - ric_help fixed
5
7
  - VERSION made DRY! (same in module Ric.version and into gem! Its extremely unefficient but thats the price for dryness!)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2010 Riccardo Carlesso
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/Manifest CHANGED
@@ -1,4 +1,5 @@
1
1
  HISTORY.yml
2
+ LICENSE
2
3
  Manifest
3
4
  README.md
4
5
  Rakefile
@@ -8,9 +9,15 @@ bin/itunes
8
9
  bin/ric
9
10
  bin/riclib-test
10
11
  init.rb
11
- lib/helpers/rails_helper.rb
12
+ lib/rails/acts_as_carlesso.rb
13
+ lib/rails/helpers/rails_helper.rb
12
14
  lib/ric.rb
15
+ lib/ric/colors.rb
13
16
  lib/ric/html.rb
14
- lib/ric_colors.rb
15
- lib/uniquify.rb
17
+ lib/ric/zibaldone.rb
18
+ lib/ruby_classes/strings.rb
19
+ lib/tmp/uniquify.rb
20
+ rails/init.rb
21
+ sbin/reboot.rb
22
+ sbin/ric_reboot.rb
16
23
  var/www/index.html
data/Rakefile CHANGED
@@ -15,6 +15,7 @@ Echoe.new('ric', version ) do |p|
15
15
  "tmp/*",
16
16
  "docs/*",
17
17
  "script/*",
18
+ "tmp/*", "tmp/*/*", "tmp/*/*/*",
18
19
  "images/*/*/*", "images/*/*", 'images',
19
20
  "private/*",
20
21
  "HISTORY"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.7
1
+ 0.10.2alpha
data/bin/ric CHANGED
@@ -1,9 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
- require 'ric'
3
+ $ver = '1.1'
5
4
 
6
- puts "Welcome to ric, the swiss-army knife tool from Riccardo, included in riclib gem (v#{Ric.version})"
5
+ def main
6
+ require 'rubygems'
7
+ require 'ric'
8
+ include Ric::Colors
9
+
10
+ dir = File.dirname( File.dirname(__FILE__) + '/../..' )
11
+ ver_manual = File.read( File.expand_path('VERSION',dir) )
12
+ ver = Ric::Zibaldone.version rescue "UnknownVersionErr(#{$!})"
13
+ puts "#{$0} v.#{$ver} -- ARGS='#{ARGV.join(' ')}'"
14
+ puts "ric library version: ''#{ver_manual}'"
15
+ puts "Welcome to ric, the swiss-army knife tool from Riccardo,\n included in riclib gem (version=#{ver})"
16
+ pyellow 'ciao' rescue "Errors with color yellow: #{$!}"
17
+ Ric::Zibaldone.say_hello()
7
18
 
8
- #include RicColors
9
- #Colors.pyellow 'ciao'
19
+ end
20
+
21
+ main
data/bin/riclib-test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  # When this works, just remove it!
14
14
  #require 'ric'
15
- $ver = '1.2.0'
15
+ $ver = '1.2.1'
16
16
 
17
17
  def richiedi(str)
18
18
  avail = `gem list #{str}`.split("\n").select{|line| line.match( /#{str} /) }.join('')
data/init.rb CHANGED
@@ -1,16 +1,8 @@
1
- #require 'lib/ric/color'
2
- require 'ric'
3
- require 'ric_colors'
4
- require 'ric/html'
5
- require 'uniquify'
6
1
 
7
- #include Ric
8
- #include Ric::Html
9
2
 
10
- #require 'rails_stuff'
11
- #require 'doesnt_exist'
12
- #require File.expand_path('lib/ric/colors.rb', File.dirname( __FILE__) )
13
- #require File.expand_path('ric/html.rb', File.dirname( __FILE__) )
14
- #require File.expand_path('helpers/rails_helper.rb', File.dirname( __FILE__) )
3
+ $debug = true
4
+ $init_debug_var = :init
15
5
 
16
- puts "ric: Welcome to Riccardo Carlesso first gem :)"
6
+ # Copying authlogic_facebook_shim logic
7
+ require File.dirname(__FILE__) + "/rails/init.rb"
8
+ # puts "Ric: init.rb Test Welcome to Riccardo Carlesso first gem :)"
@@ -0,0 +1,20 @@
1
+ module Rails
2
+ module ActsAsCarlesso
3
+ def self.included(klass)
4
+ klass.class_eval do
5
+ extend Config
6
+ add_acts_as_carlesso_module(Methods, :prepend)
7
+ end
8
+ end
9
+
10
+ module Config
11
+ end
12
+
13
+ module Methods
14
+ def self.included(klass)
15
+ klass.class_eval do
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+
2
+ module Rails
3
+ module Helpers
4
+ module RailsHelper
5
+
6
+ def anything_to_html(son,opts={})
7
+ ret = '(RailsHelper :: anything_to_html)' if opts.fetch(:verbose,true) # TODO change dflt to false
8
+ if opts != {}
9
+ ret << "(Options: " + anything_to_html(opts) + ")"
10
+ end
11
+ if son.class == Array
12
+ ret << "<ul class='subtopic' >"
13
+ son.each{|subtopic|
14
+ ret << content_tag(:li, anything_to_html(subtopic).html_safe ) # '- ' +
15
+ }
16
+ ret << "</ul>"
17
+ elsif son.class == Hash
18
+ #ret << hash_to_html(son)
19
+ ret += '<ul class="maintopic" >'
20
+ son.each{ |k,val|
21
+ ret << content_tag(:li, ( anything_to_html(k) + ' => ' + anything_to_html(val) ).html_safe )
22
+ }
23
+ ret << "</ul>"
24
+ elsif son.class == String
25
+ ret << "<font color='navy' class='ricclass_string' >#{son}</font>"
26
+ elsif son.class == Symbol
27
+ ret << "<i><font color='gray' class='ricclass_symbol' >:#{son}</font></i>"
28
+ else
29
+ ret << "(Unknown Class: #{son.class}) <b>#{son}</b>"
30
+ end
31
+ ret.html_safe
32
+ end
33
+
34
+ end #/RailsHelper
35
+ end
36
+ end
data/lib/ric.rb CHANGED
@@ -1,63 +1,25 @@
1
1
 
2
- # RICLIB!
2
+ # Riccardo New Stuff
3
+ require 'ric/colors'
4
+ require 'ric/html'
5
+ require 'ric/zibaldone'
6
+
7
+ # riccardo Old SVN repository...
8
+ # require 'ruby_classes/strings'
9
+
10
+ #if ActiveRecord::Base.respond_to?(:add_acts_as_carlesso_module)
11
+ # require 'rails/acts_as_carlesso'
12
+ # ActiveRecord::Base.send :include, Rails::ActsAsCarlesso
13
+ #end
14
+
15
+ #puts "Ric: lib/riccardo_includes.rb Test Welcome to Riccardo Carlesso first gem :)"
3
16
  module Ric
4
- $version
5
- require File.expand_path('ric_colors.rb', File.dirname( __FILE__) )
6
- #include RicColors
7
-
8
- def self.version
9
- # TODO memoize/cache this into @@version
10
- #File.read( 'VERSION' ) rescue "0.0.42_bugged"
11
- #{}"0.9.6WET (See file in '#{Ric.gemdir}')"
12
- File.read( File.expand_path('VERSION' , Ric.gemdir ) )
13
- end
14
-
15
- def self.say_hello
16
- puts "Ric: Hello world by #{yellow 'Riccardo Carlesso' rescue 'Riccardo Carlesso Error'}"
17
- end
17
+ #include Ric::Colors
18
18
 
19
19
  def self.ric_help
20
- ret = <<-HTML
21
- == Ric (formerly RicLib) ==
22
- This is Riccardo library (my first gem!). Try the following commands maybe
23
- Try some of the following:
24
-
25
- pred 'This is in red'
26
- pyellow 'This is yellow instead'
27
-
28
- gemdir: #{ gemdir }
29
- HTML
30
- puts( ret )
31
- ret
32
- end
33
- alias :help :ric_help
34
- #alias :about :ric_help
35
-
36
- def self.gemdir
37
- File.dirname( File.dirname(__FILE__) + '../' )
38
- end
39
-
40
- def foo
41
- :bar
42
- end
43
-
44
- def self.foo
45
- 'self.bar'
46
- end
47
-
48
- # you can require more than one gem and a symbol as well :)
49
- def self.richiedi(gems)
50
- puts "Riccardo personal super-'require'.. "
51
- case gems.class.to_s
52
- when 'String'
53
- return require gems
54
- when 'Array'
55
- return require gems
56
- else
57
- return require gems.to_s
58
- end
20
+ puts :TODO
59
21
  end
60
22
 
61
23
  end
62
24
 
63
- include Ric
25
+ include Ric::Colors
@@ -2,7 +2,8 @@
2
2
 
3
3
  # $Id: ric_colors.rb 5438 2010-12-16 15:06:29Z rcarlesso $
4
4
 
5
- module RicColors
5
+ module Ric
6
+ module Colors
6
7
 
7
8
  $colors_active = true # DEFAULT: active
8
9
  $color_db = [
@@ -297,6 +298,5 @@ module RicColors
297
298
  return !! terminal.to_s.match( /Apple_Terminal/ )
298
299
  end
299
300
 
300
- end # /module
301
-
302
- #$colors_active = ! RicColor.daltonic_terminal? # DEFAULT: active
301
+ end # /module Colors
302
+ end # /module Ric
data/lib/ric/html.rb CHANGED
@@ -1,4 +1,5 @@
1
- module Ric::Html
1
+ module Ric
2
+ module Html
2
3
 
3
4
  def test
4
5
  anything_to_html({:note => 'remove me', :foo => :bar } )
@@ -33,5 +34,5 @@ module Ric::Html
33
34
  ret.html_safe
34
35
  end
35
36
 
36
-
37
- end #/RicHtml
37
+ end #/Html
38
+ end #/Ric
@@ -0,0 +1,38 @@
1
+ # random methods i dont know wher eto put right now :(
2
+
3
+ module Ric
4
+ module Zibaldone
5
+
6
+
7
+ def self.gemdir
8
+ File.dirname( File.dirname(__FILE__) + '/../../..' ) # Im in lib/ric/zibaldone.rb
9
+ end
10
+
11
+ def self.version
12
+ # TODO memoize/cache this into @@version
13
+ File.read( File.expand_path('VERSION' , gemdir() ) )
14
+ end
15
+
16
+ def self.say_hello
17
+ puts "Ric::Zibaldone.say_hello(): This hello is brought to you by ''#{yellow 'Riccardo Carlesso' rescue 'Riccardo Carlesso (Error with color yellow)'}''"
18
+ end
19
+
20
+ def self.ric_help
21
+ ret = <<-HTML
22
+ == Ric (formerly RicLib) ==
23
+ This is Riccardo library (my first gem!). Try the following commands maybe
24
+ Try some of the following:
25
+
26
+ pred 'This is in red'
27
+ pyellow 'This is yellow instead'
28
+
29
+ gemdir: #{ gemdir }
30
+ HTML
31
+ puts( ret )
32
+ ret
33
+ end
34
+ #alias :help :ric_help
35
+ #alias :about :ric_help
36
+
37
+ end #/Zibaldone
38
+ end #/Ric
@@ -0,0 +1,281 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module RubyClasses
4
+ module String
5
+
6
+ class String
7
+
8
+ def basename
9
+ split('/').last
10
+ end
11
+
12
+ def left(length,padding)
13
+ mylen = self.length
14
+ padding_char = padding[0] # troppo difficile fare che paddi "abc" su 8 fa "abcabcab" checcavolo :)
15
+ mylen < length ?
16
+ self + padding * (length - mylen) :
17
+ self
18
+ end
19
+
20
+ def color(mycolor = :orange )
21
+ send(mycolor,self)
22
+ end
23
+
24
+ def uncolor()
25
+ scolora(self)
26
+ end
27
+
28
+ # trovata qui: la mia funziona cmq
29
+ # http://www.ruby-forum.com/topic/96222
30
+ def to_class
31
+ Object.const_get(self)
32
+ #ret = eval(self)
33
+ #deb "this is a class? cls=#{ret.class}"
34
+ #raise "Exception its not a class!" if ret.class.to_s != 'Class'
35
+ #return ret
36
+ end
37
+
38
+ def nlines
39
+ split("\n").size
40
+ end
41
+
42
+ # rimuove spazi a inizio e fine
43
+ def trim
44
+ self.gsub(/^\s+/,'').gsub(/\s+$/,'')
45
+ end
46
+
47
+ def escape_printf
48
+ gsub("%",'%%')
49
+ end
50
+
51
+ def escape_double_quotes
52
+ gsub('"','\"')
53
+ end
54
+ def escape_single_quotes
55
+ gsub("'","\'")
56
+ end
57
+
58
+ # dumps string to file (in APPEND) :)
59
+ def tee(opts={})
60
+ filename = opts.fetch :file, __FILE__ + ".tmpric"
61
+ verbose = opts.fetch :verbose, true
62
+ preamble = lambda {|where| return "# Teeing string (pid=#{$$}, size=#{self.size}B, opts=#{opts}) into file: #{blue filename}\n" }
63
+ deb "Teeing string (#{self.size}B, opts=#{opts}) into file: #{blue filename}"
64
+ File.open(filename, 'a') {|f|
65
+ f.write("# {{{ String.tee #{} from #{__FILE__}\n") if verbose
66
+ f.write(preamble.call(:BEGIN)) if verbose
67
+ f.write(self)
68
+ f.write("\n" + preamble.call(:END))if verbose
69
+ f.write("\n# }}} Tee stop pid=##{$$}\n")if verbose
70
+ } # i think it closes it here...
71
+ puts "Written #{self.size}B in append to: '#{yellow filename}'" if verbose
72
+ return self
73
+ end
74
+
75
+ =begin
76
+ return string with regex highlighted
77
+
78
+ TODO highlight just the matching regex
79
+ =end
80
+ def grep_color(regex, opts={} )
81
+ deb "string grep_color(regex: '#{regex}')"
82
+ color = opts[:color] || true # false
83
+ verbose = opts[:verbose] || true # TODO false
84
+ return red(self) if self.match(regex)
85
+ return verbose ?
86
+ self :
87
+ ''
88
+ end
89
+
90
+ alias :right :left
91
+
92
+ def flag(nation)
93
+ flag(self, flag = '')
94
+ end
95
+
96
+ # enclose string in single quotes..
97
+ def quote(sep = nil)
98
+ sep ||= "'"
99
+ sep + self + sep
100
+ end
101
+ def double_quote(); quote('"') ; end
102
+
103
+ def depurate_for_file
104
+ gsub(/[\/: \.]/ , '_')
105
+ end
106
+
107
+ def prepend(str)
108
+ str.to_s+self
109
+ end
110
+ def append(str)
111
+ self+str.to_s
112
+ end
113
+
114
+ # a: b
115
+ # c: d
116
+ # -->
117
+ def to_hash(description='String::to_hash() made by genious RCarlesso (give a better description if u dont like this!)')
118
+ arr = Hash.new
119
+ arr['_meta'] = Hash.new
120
+ arr['_meta']['description'] = description
121
+ arr['_meta']['time'] = Time.now
122
+ self.split("\n").each{|line|
123
+ k,v = line.split(': ')
124
+ arr[k.strip] = v.strip
125
+ } rescue arr['_meta']['errors'] = $!
126
+ arr
127
+ end
128
+
129
+ def starts_with?(ch)
130
+ self.match(/^#{ch}/)
131
+ end
132
+
133
+ # 'abcde' => '*****'
134
+ def asterisks(ch='*')
135
+ ch * (self.size)
136
+ end
137
+
138
+ def shorten (count = 50)
139
+ if self.length >= count
140
+ shortened = self[0, count]
141
+ splitted = shortened.split(/\s/)
142
+ words = splitted.length
143
+ splitted[0, words-1].join(" ") + ' ...'
144
+ else
145
+ self
146
+ end
147
+ end
148
+ # alias :excerpt :shorten
149
+ # no dai, in realta excerpt sarebbe con SEARCH di parola e ci orla intorno...
150
+
151
+ # sanitizza un filename
152
+ def sanitize_path
153
+ gsub(/[\/: ]/,'_')
154
+ end
155
+
156
+ # see arrays!
157
+ # def method_missing
158
+ # end
159
+
160
+ def to_html
161
+ %(<span class="ricsvn_string" >#{self}</span>)
162
+ end
163
+
164
+ def initial; self[0..0] ; end
165
+
166
+
167
+ # canonicalize: delete leading and trailing spaces, replaces newlines
168
+ # with one space and then replace all continuouse spaces with one ' '
169
+ # (including tabs and other fancy things)
170
+
171
+ # non funziona bene perche non so come CACCHIO mappare il /g.
172
+ # oare che in ruby ci sia solo /i x(xtended) n(multiline)
173
+ def canonicalize
174
+ value = self
175
+ value = value.gsub( /^\s+/, '') # s/^\s+//;
176
+ value = value.gsub( /\s+$/, '') # value =~ s/\s+$//;
177
+ value = value.gsub( /\r*\n/n, ' ') # value =~ s/\r*\n/ /g;
178
+ value = value.gsub( /\s+$/n , ' ') # value =~ s/\s+$/ /g;
179
+ deb "Original: '''#{self}'''"
180
+ deb "Canonical: '''#{value}'''"
181
+ return value
182
+ end
183
+
184
+ # a manhouse :-(
185
+ def singolarizza
186
+ return self.singularize if self.respond_to?(:singularize)
187
+ deb("singularize '#{self}'")
188
+ m = self.match( /(.*)es$/) # i.e. matches
189
+ return m[1] if (m)
190
+ m = self.match( /(.*)s$/)
191
+ return m[1] if m
192
+ return m
193
+ end
194
+
195
+ =begin
196
+ greppa dalla prima occorrenza di FROM in poi
197
+
198
+ =end
199
+
200
+ def from_first_line_matching(regex_from)
201
+ arr_lines = self.split("\n")
202
+ ix1 = arr_lines.index_regex(regex_from) || 0
203
+ if ! ix1
204
+ throw "Cattivo Indice per arr_lines. Non greppa una fava con: #{regex_from}"
205
+ ix1 = 0
206
+ end
207
+ ix2 = arr_lines.length
208
+ deb "#{ix1}..#{ix2}"
209
+ joint = arr_lines[ix1..ix2].join("\n") #rescue ''
210
+ return joint
211
+ end
212
+
213
+ def to_first_line_matching(regex_from)
214
+ arr_lines = self.split("\n")
215
+ ix2 = arr_lines.index_regex(regex_from)
216
+ #ix2 = arr_lines.length
217
+ return arr_lines[0..ix2].join("\n")
218
+ end
219
+
220
+ end #/Class String
221
+
222
+
223
+ ### Miscellaneous string functions
224
+
225
+ def clear_screen
226
+ print "\e[2J\e[f"
227
+ end
228
+ alias :clear :clear_screen
229
+
230
+ def title(s)
231
+ title_n(s)
232
+ end
233
+ def title_n(s,n=2)
234
+ "== #{s} =="
235
+ end
236
+
237
+
238
+
239
+ LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin at purus id ante pulvinar dapibus. Donec risus justo, gravida ac vulputate a, lacinia eget leo. Duis quam tellus, tempus at feugiat a, eleifend et velit. Donec et enim id libero malesuada luctus nec at nibh. Sed elit est, interdum sit amet sollicitudin ac, vulputate eget metus. In hac habitasse platea dictumst. Cras vitae justo at turpis elementum sollicitudin. Etiam quis quam placerat erat tincidunt fermentum. Ut vel mauris magna. Vestibulum luctus leo eget lectus gravida ac dignissim enim vestibulum. Integer facilisis mi sed justo aliquet a lacinia lacus scelerisque.
240
+
241
+ Aliquam sed purus vel felis euismod pharetra eu a ipsum. Suspendisse potenti. Mauris aliquet, lorem id mattis ornare, dolor mauris tincidunt tellus, ac feugiat urna sem eget diam. Nulla venenatis urna et elit lobortis eleifend. Ut feugiat adipiscing nisi vitae accumsan. Aliquam ullamcorper odio a nibh scelerisque non tincidunt urna ullamcorper. Sed vitae eleifend quam. Nunc vulputate vulputate viverra. Duis eu enim eros. Nunc lacinia nibh neque, sit amet varius arcu.
242
+
243
+ Maecenas facilisis porttitor vestibulum. Phasellus nisl elit, porttitor id pulvinar nec, malesuada quis lectus. Suspendisse lacinia odio vitae eros molestie suscipit. Vivamus eu nulla ac augue adipiscing luctus. Curabitur rhoncus placerat dui a consectetur. Integer suscipit felis vitae eros mattis cursus. Integer sollicitudin ante in risus feugiat tincidunt sed sit amet libero. Nunc molestie lorem ut nulla aliquam viverra. Etiam bibendum mollis mattis. Phasellus ipsum tortor, egestas consequat sollicitudin non, hendrerit eu tortor. Nam at magna ipsum, non convallis ligula. Etiam ac eros a nunc elementum bibendum vitae vitae lacus. Vivamus placerat quam sit amet urna mattis in luctus nulla venenatis. Praesent tempus egestas interdum. Nulla facilisi. Nulla id ligula et nunc egestas dictum sed sodales tellus. Integer vestibulum commodo mauris, blandit porta lectus tincidunt quis. Vestibulum varius est eu turpis ultrices pellentesque.
244
+
245
+ Donec aliquam elit quis augue tristique id lacinia augue laoreet. Duis placerat tellus eget urna vehicula volutpat. Vestibulum tortor dui, ultricies quis luctus sed, ultricies sit amet dui. Sed nec magna ac mauris imperdiet venenatis in id velit. Vestibulum non nibh nisi, eu elementum metus. Integer porttitor scelerisque pharetra. Maecenas eu tincidunt augue. Donec viverra diam lacinia ligula rhoncus viverra. Cras dictum rhoncus nisi sit amet malesuada. Quisque consectetur sollicitudin magna, nec faucibus nulla lacinia ac. Donec accumsan gravida odio, nec vehicula enim hendrerit sed. Etiam in mauris et mi sollicitudin congue non sit amet augue. Praesent nisi tortor, posuere vehicula rutrum interdum, tincidunt non tortor. Aliquam adipiscing mollis odio, eget accumsan lectus blandit sed. Sed tristique, ipsum eu laoreet dignissim, nunc nisi rhoncus tellus, sed molestie turpis ante vitae orci. Nullam tincidunt suscipit ligula sit amet sodales. Curabitur auctor tempus rutrum.
246
+
247
+ Donec non venenatis lectus. Ut imperdiet felis quis augue viverra pellentesque. Duis sodales, magna at tincidunt volutpat, turpis tellus auctor lacus, et mollis ante odio in tellus. Aliquam euismod tempor aliquam. Vivamus at eros eget felis consequat faucibus dignissim consequat diam. Cras et dolor sagittis mi pharetra tincidunt vitae a tortor. Vestibulum at dictum augue. Sed commodo magna quis lectus bibendum accumsan. Aliquam consectetur feugiat augue, eget suscipit mi mattis ac. Donec at tristique lorem. Nulla non nisl sed felis volutpat ullamcorper." unless defined?(LOREM_IPSUM)
248
+
249
+ def lorem_ipsum(len=0)
250
+ len == 0 ?
251
+ LOREM_IPSUM :
252
+ LOREM_IPSUM[0..len]
253
+ end
254
+
255
+ alias :lorem :lorem_ipsum
256
+
257
+ # supports: strings, arrays and regexes :)
258
+ # @returns a Regexp
259
+ def autoregex(anything)
260
+ deb "Autoregex() supercool! With a #{blue anything.class}"
261
+ case anything.class.to_s
262
+ when 'String'
263
+ if anything.match(/^\/.*\/$/) # '/asd/' is probably an error! The regex builder trails with '/' automatically
264
+ fatal 23,"Attention, the regex is a string with trailing '/', are you really SURE this is what you want?!?"
265
+ end
266
+ return Regexp.new(anything)
267
+ when 'Regexp'
268
+ return anything # already ok
269
+ when 'Array'
270
+ return Regexp.new(anything.join('|'))
271
+ else
272
+ msg = "Unknown class for autoregexing: #{red anything.class}"
273
+ $stderr.puts( msg )
274
+ raise( msg )
275
+ end
276
+ return nil
277
+ end
278
+
279
+ end #/String
280
+ end #/RubyClasses
281
+
@@ -37,9 +37,9 @@ end
37
37
  class ActiveRecord::Base
38
38
  include Uniquify
39
39
 
40
- # returns an array of ids
40
+ ### returns an array of ids
41
41
  def self.ids
42
- map{|active_record| active_record.id }
42
+ { :brought_to_you_by_ric_library => map{|active_record| active_record.id } }
43
43
  end
44
44
 
45
45
  def self.names
data/rails/init.rb ADDED
@@ -0,0 +1,7 @@
1
+ #require 'riccardo_includes'
2
+
3
+ $init_debug_var = 'rails init'
4
+
5
+ require File.dirname(__FILE__) + "/../lib/ric.rb"
6
+
7
+ #puts "rails/init: I dont know why 2 levels of indirection. Maybe this is called by rails.."
data/ric.gemspec CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ric}
5
- s.version = "0.9.7"
5
+ s.version = "0.10.2alpha"
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"]
9
- s.date = %q{2011-01-16}
9
+ s.date = %q{2011-01-17}
10
10
  s.description = %q{My first gem with various utilities (colors and tests now).
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
14
  s.executables = ["itunes", "ric", "riclib-test"]
15
- s.extra_rdoc_files = ["README.md", "TODO", "bin/itunes", "bin/ric", "bin/riclib-test", "lib/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/html.rb", "lib/ric_colors.rb", "lib/uniquify.rb"]
16
- s.files = ["HISTORY.yml", "Manifest", "README.md", "Rakefile", "TODO", "VERSION", "bin/itunes", "bin/ric", "bin/riclib-test", "init.rb", "lib/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/html.rb", "lib/ric_colors.rb", "lib/uniquify.rb", "var/www/index.html", "ric.gemspec"]
15
+ s.extra_rdoc_files = ["LICENSE", "README.md", "TODO", "bin/itunes", "bin/ric", "bin/riclib-test", "lib/rails/acts_as_carlesso.rb", "lib/rails/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/colors.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", "init.rb", "lib/rails/acts_as_carlesso.rb", "lib/rails/helpers/rails_helper.rb", "lib/ric.rb", "lib/ric/colors.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", "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"]
data/sbin/reboot.rb ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts 'Ric: test reboot... only root should be able to do this'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts 'Ric: test reboot... only root should be able to do this'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ric
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
5
- prerelease:
4
+ hash: -1851332122
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
- - 9
9
- - 7
10
- version: 0.9.7
8
+ - 10
9
+ - 2
10
+ - alpha
11
+ version: 0.10.2alpha
11
12
  platform: ruby
12
13
  authors:
13
14
  - Riccardo Carlesso
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-01-16 00:00:00 +00:00
19
+ date: 2011-01-17 00:00:00 +00:00
19
20
  default_executable:
20
21
  dependencies: []
21
22
 
@@ -31,18 +32,23 @@ executables:
31
32
  extensions: []
32
33
 
33
34
  extra_rdoc_files:
35
+ - LICENSE
34
36
  - README.md
35
37
  - TODO
36
38
  - bin/itunes
37
39
  - bin/ric
38
40
  - bin/riclib-test
39
- - lib/helpers/rails_helper.rb
41
+ - lib/rails/acts_as_carlesso.rb
42
+ - lib/rails/helpers/rails_helper.rb
40
43
  - lib/ric.rb
44
+ - lib/ric/colors.rb
41
45
  - lib/ric/html.rb
42
- - lib/ric_colors.rb
43
- - lib/uniquify.rb
46
+ - lib/ric/zibaldone.rb
47
+ - lib/ruby_classes/strings.rb
48
+ - lib/tmp/uniquify.rb
44
49
  files:
45
50
  - HISTORY.yml
51
+ - LICENSE
46
52
  - Manifest
47
53
  - README.md
48
54
  - Rakefile
@@ -52,11 +58,17 @@ files:
52
58
  - bin/ric
53
59
  - bin/riclib-test
54
60
  - init.rb
55
- - lib/helpers/rails_helper.rb
61
+ - lib/rails/acts_as_carlesso.rb
62
+ - lib/rails/helpers/rails_helper.rb
56
63
  - lib/ric.rb
64
+ - lib/ric/colors.rb
57
65
  - lib/ric/html.rb
58
- - lib/ric_colors.rb
59
- - lib/uniquify.rb
66
+ - lib/ric/zibaldone.rb
67
+ - lib/ruby_classes/strings.rb
68
+ - lib/tmp/uniquify.rb
69
+ - rails/init.rb
70
+ - sbin/reboot.rb
71
+ - sbin/ric_reboot.rb
60
72
  - var/www/index.html
61
73
  - ric.gemspec
62
74
  has_rdoc: true
@@ -1,31 +0,0 @@
1
- module RailsHelper
2
-
3
- def anything_to_html(son,opts={})
4
- ret = '(RailsHelper :: anything_to_html)' if opts.fetch(:verbose,true) # TODO change dflt to false
5
- if opts != {}
6
- ret << "(Options: " + anything_to_html(opts) + ")"
7
- end
8
- if son.class == Array
9
- ret << "<ul class='subtopic' >"
10
- son.each{|subtopic|
11
- ret << content_tag(:li, anything_to_html(subtopic).html_safe ) # '- ' +
12
- }
13
- ret << "</ul>"
14
- elsif son.class == Hash
15
- #ret << hash_to_html(son)
16
- ret += '<ul class="maintopic" >'
17
- son.each{ |k,val|
18
- ret << content_tag(:li, ( anything_to_html(k) + ' => ' + anything_to_html(val) ).html_safe )
19
- }
20
- ret << "</ul>"
21
- elsif son.class == String
22
- ret << "<font color='navy' class='ricclass_string' >#{son}</font>"
23
- elsif son.class == Symbol
24
- ret << "<i><font color='gray' class='ricclass_symbol' >:#{son}</font></i>"
25
- else
26
- ret << "(Unknown Class: #{son.class}) <b>#{son}</b>"
27
- end
28
- ret.html_safe
29
- end
30
-
31
- end #/RailsHelper