ratch 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/LICENSE.txt +344 -0
  2. data/README.txt +10 -0
  3. data/bin/lt +4 -0
  4. data/bin/ludo +4 -0
  5. data/bin/ratch +8 -0
  6. data/data/mint/ratch/announce +224 -0
  7. data/data/mint/ratch/install +49 -0
  8. data/data/mint/ratch/notes +183 -0
  9. data/data/mint/ratch/publish +44 -0
  10. data/data/mint/ratch/rdoc +40 -0
  11. data/data/mint/ratch/setup +1616 -0
  12. data/data/mint/ratch/stats +138 -0
  13. data/demo/README +8 -0
  14. data/demo/doc/rdoc/created.rid +1 -0
  15. data/demo/doc/rdoc/files/README.html +112 -0
  16. data/demo/doc/rdoc/files/lib/foo/foo_rb.html +145 -0
  17. data/demo/doc/rdoc/fr_class_index.html +26 -0
  18. data/demo/doc/rdoc/fr_file_index.html +28 -0
  19. data/demo/doc/rdoc/fr_method_index.html +27 -0
  20. data/demo/doc/rdoc/index.html +24 -0
  21. data/demo/doc/rdoc/rdoc-style.css +208 -0
  22. data/demo/lib/foo/foo.rb +7 -0
  23. data/demo/util/conf/rdoc +4 -0
  24. data/demo/util/one +6 -0
  25. data/demo/util/rdoc +39 -0
  26. data/demo/util/tryme +10 -0
  27. data/dev/taskable-simple.rb +42 -0
  28. data/dev/taskable.rb +573 -0
  29. data/lib/ratch/batch.rb +43 -0
  30. data/lib/ratch/cli/lt.rb +56 -0
  31. data/lib/ratch/cli/ludo.rb +14 -0
  32. data/lib/ratch/cli/ratch.rb +47 -0
  33. data/lib/ratch/configutils.rb +100 -0
  34. data/lib/ratch/consoleutils.rb +88 -0
  35. data/lib/ratch/emailutils.rb +88 -0
  36. data/lib/ratch/fileutils.rb +173 -0
  37. data/lib/ratch/options.rb +57 -0
  38. data/lib/ratch/runnable.rb +117 -0
  39. data/lib/ratch/taskable.rb +105 -0
  40. data/lib/ratch/taskutils.rb +44 -0
  41. data/lib/ratch/uploadutils.rb +413 -0
  42. data/meta/manifest.txt +70 -0
  43. data/meta/project.yaml +24 -0
  44. data/misc/original.rb +308 -0
  45. data/task/setup +1616 -0
  46. data/task/stats +138 -0
  47. metadata +114 -0
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env ratch
2
+
3
+ # Simple code count analysis.
4
+ #
5
+ # This ratchet scan source code counting files,
6
+ # lines of code and comments and presents a
7
+ # report of it's findings.
8
+
9
+ main :stats do
10
+ statistics
11
+ end
12
+
13
+ DEFAULT_STATS_FILES = [ 'lib/**/*', 'ext/**/*', 'bin/**/*' ]
14
+
15
+ # Basic statics on line count.
16
+ #
17
+ # This task counts the file and lines of code in your
18
+ # project and provided some statistical figures.
19
+ #
20
+ # files Files to include and/or exclude in
21
+ # analysis. '+' and '-' files patterns
22
+ # are accepted. The default includes all
23
+ # files in the lib/ and ext/ directories.
24
+ #
25
+ # TODO Support - and + augmentations for configuration.
26
+
27
+ def statistics
28
+ config = configuration['stats'] || {}
29
+ scripts = config['files'] || DEFAULT_STATS_FILES
30
+ files = scripts.inject([]){ |memo, find| memo.concat(glob(find)); memo }
31
+ #Dir.multiglob_with_default(DEFAULT_STATS_FILES)
32
+
33
+ fc, l, c, r, t, s = *line_count(*files)
34
+
35
+ fct, lt, ct, rt, tt, st = *([0]*6)
36
+ if File.directory?('test')
37
+ fct, lt, ct, rt, tt, st = *line_count('test/**/*')
38
+ t = lt if lt > 0
39
+ end
40
+
41
+ rat = lambda do |d,n|
42
+ if d > n and n != 0
43
+ "%.1f" % [ d.to_f / n ]
44
+ elsif n > d and d != 0
45
+ "-" #"%.1f:1" % [ n.to_f / d ]
46
+ elsif d == 0 or n == 0
47
+ "-"
48
+ else
49
+ "1.0"
50
+ end
51
+ end
52
+
53
+ per = lambda do |n,d|
54
+ if d != 0
55
+ (((n.to_f / d)*100).to_i).to_s + "%"
56
+ else
57
+ "-"
58
+ end
59
+ end
60
+
61
+ max = l.to_s.size + 4
62
+
63
+ puts
64
+ #puts "FILES:"
65
+ #puts " source: #{fc}"
66
+ #puts " test : #{fct}"
67
+ #puts " total : #{fc+fct}"
68
+ #puts
69
+ #puts "LINES:"
70
+ #puts " code : %#{max}s %4s" % [ c.to_s, per[c,l] ]
71
+ #puts " docs : %#{max}s %4s" % [ r.to_s, per[r,l] ]
72
+ #puts " space : %#{max}s %4s" % [ s.to_s, per[s,l] ]
73
+ #puts " test : %#{max}s %4s" % [ t.to_s, per[t,l] ]
74
+ #puts " total : %#{max}s %4s" % [ l.to_s, per[l,l] ]
75
+ #puts
76
+ #puts "Ratio to 1 :"
77
+ #puts " code to test : #{rat[c,t]} #{per[c,t]}"
78
+
79
+ head = ["Total", "Code", "-%-", "Docs", "-%-", "Blank", "-%-", "Files"]
80
+ prod = [l.to_s, c.to_s, per[c,l], r.to_s, per[r,l], s.to_s, per[s,l], fc]
81
+ test = [lt.to_s, ct.to_s, per[ct,l], rt.to_s, per[rt,l], st.to_s, per[st,l], fct]
82
+ totl = [(l+lt), (c+ct), per[c+ct,l+lt], (r+rt), per[r+rt,l+lt], (s+st), per[s+st,l+lt], (fc+fct)]
83
+
84
+ puts "TYPE %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % head
85
+ puts "Source %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % prod
86
+ puts "Test %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % test
87
+ puts "Total %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % totl
88
+ puts
89
+ puts "RATIO Code Docs Blank Test Total"
90
+ puts "Code %7s %7s %7s %7s %7s" % [ rat[c,c], rat[c,r], rat[c,s], rat[c,t], rat[c,l] ]
91
+ puts "Docs %7s %7s %7s %7s %7s" % [ rat[r,c], rat[r,r], rat[r,s], rat[r,t], rat[r,l] ]
92
+ puts "Blank %7s %7s %7s %7s %7s" % [ rat[s,c], rat[s,r], rat[s,s], rat[s,t], rat[s,l] ]
93
+ puts "Test %7s %7s %7s %7s %7s" % [ rat[t,c], rat[t,r], rat[t,s], rat[t,t], rat[t,l] ]
94
+ puts "Total %7s %7s %7s %7s %7s" % [ rat[l,c], rat[l,r], rat[l,s], rat[l,t], rat[l,l] ]
95
+ puts
96
+ end
97
+
98
+ private
99
+
100
+ # Return line counts for files.
101
+
102
+ def line_count( *files )
103
+ files = files.inject([]) do |memo, find|
104
+ memo.concat(Dir.glob(find)); memo
105
+ end
106
+
107
+ fc, l, c, t, r = 0, 0, 0, 0, 0
108
+ bt, rb = false, false
109
+
110
+ files.each do |fname|
111
+ next unless fname =~ /.*rb/ # TODO should this be done?
112
+ fc += 1
113
+ File.open( fname ) do |f|
114
+ while line = f.gets
115
+ l += 1
116
+ next if line =~ /^\s*$/
117
+ case line
118
+ when /^=begin\s+test/
119
+ tb = true; t+=1
120
+ when /^=begin/
121
+ rb = true; r+=1
122
+ when /^=end/
123
+ t+=1 if tb
124
+ r+=1 if rb
125
+ rb, tb = false, false
126
+ when /^\s*#/
127
+ r += 1
128
+ else
129
+ c+=1 if !(rb or tb)
130
+ r+=1 if rb
131
+ t+=1 if tb
132
+ end
133
+ end
134
+ end
135
+ end
136
+ s = l - c - r - t
137
+ return fc, l, c, r, t, s
138
+ end
data/demo/README ADDED
@@ -0,0 +1,8 @@
1
+ = Demo of Ratchets
2
+
3
+ The Ruby Batch System
4
+
5
+ == What Do You Say?
6
+
7
+ This is Foo business.
8
+
@@ -0,0 +1 @@
1
+ Sun, 19 Aug 2007 08:19:45 -0700
@@ -0,0 +1,112 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Tue Jul 24 12:24:03 -0700 2007</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>Demo of Ratchets</h1>
73
+ <p>
74
+ The Ruby Batch System
75
+ </p>
76
+ <h2>What Do You Say?</h2>
77
+ <p>
78
+ This is Foo business.
79
+ </p>
80
+
81
+ </div>
82
+
83
+
84
+ </div>
85
+
86
+
87
+ </div>
88
+
89
+
90
+ <!-- if includes -->
91
+
92
+ <div id="section">
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <!-- if method_list -->
102
+
103
+
104
+ </div>
105
+
106
+
107
+ <div id="validator-badges">
108
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,145 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: foo.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>foo.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/foo/foo.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Sat Jul 28 14:20:30 -0700 2007</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <p>
73
+ Say <a href="foo_rb.html#M000001">hello</a>, Gracy.
74
+ </p>
75
+
76
+ </div>
77
+
78
+
79
+ </div>
80
+
81
+ <div id="method-list">
82
+ <h3 class="section-bar">Methods</h3>
83
+
84
+ <div class="name-list">
85
+ <a href="#M000001">hello</a>&nbsp;&nbsp;
86
+ </div>
87
+ </div>
88
+
89
+ </div>
90
+
91
+
92
+ <!-- if includes -->
93
+
94
+ <div id="section">
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ <!-- if method_list -->
104
+ <div id="methods">
105
+ <h3 class="section-bar">Public Instance methods</h3>
106
+
107
+ <div id="method-M000001" class="method-detail">
108
+ <a name="M000001"></a>
109
+
110
+ <div class="method-heading">
111
+ <a href="#M000001" class="method-signature">
112
+ <span class="method-name">hello</span><span class="method-args">()</span>
113
+ </a>
114
+ </div>
115
+
116
+ <div class="method-description">
117
+ <p>
118
+ Say <a href="foo_rb.html#M000001">hello</a>, Gracy.
119
+ </p>
120
+ <p><a class="source-toggle" href="#"
121
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
122
+ <div class="method-source-code" id="M000001-source">
123
+ <pre>
124
+ <span class="ruby-comment cmt"># File lib/foo/foo.rb, line 4</span>
125
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hello</span>
126
+ <span class="ruby-value str">&quot;Hello, Gracy&quot;</span>
127
+ <span class="ruby-keyword kw">end</span>
128
+ </pre>
129
+ </div>
130
+ </div>
131
+ </div>
132
+
133
+
134
+ </div>
135
+
136
+
137
+ </div>
138
+
139
+
140
+ <div id="validator-badges">
141
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
142
+ </div>
143
+
144
+ </body>
145
+ </html>
@@ -0,0 +1,26 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Classes
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Classes</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Classes</h1>
22
+ <div id="index-entries">
23
+ </div>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,28 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Files
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Files</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Files</h1>
22
+ <div id="index-entries">
23
+ <a href="files/README.html">README</a><br />
24
+ <a href="files/lib/foo/foo_rb.html">lib/foo/foo.rb</a><br />
25
+ </div>
26
+ </div>
27
+ </body>
28
+ </html>