ratch 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/task/stats ADDED
@@ -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
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: ratch
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2007-09-09 00:00:00 -07:00
8
+ summary: Ruby-based Batch Fils
9
+ require_paths:
10
+ - lib
11
+ email: Thomas Sawyer <transfire@gmail.com>
12
+ homepage: http://proutils.rubyforge.org
13
+ rubyforge_project:
14
+ description: Ratch is batch file system suitable for creating project build scripts and any variety of command line utilities.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc:
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Thomas Sawyer <transfire@gmail.com>
31
+ files:
32
+ - LICENSE.txt
33
+ - README.txt
34
+ - bin
35
+ - bin/lt
36
+ - bin/ludo
37
+ - bin/ratch
38
+ - data
39
+ - data/mint
40
+ - data/mint/ratch
41
+ - data/mint/ratch/announce
42
+ - data/mint/ratch/install
43
+ - data/mint/ratch/notes
44
+ - data/mint/ratch/publish
45
+ - data/mint/ratch/rdoc
46
+ - data/mint/ratch/setup
47
+ - data/mint/ratch/stats
48
+ - demo
49
+ - demo/README
50
+ - demo/doc
51
+ - demo/doc/rdoc
52
+ - demo/doc/rdoc/classes
53
+ - demo/doc/rdoc/created.rid
54
+ - demo/doc/rdoc/files
55
+ - demo/doc/rdoc/files/README.html
56
+ - demo/doc/rdoc/files/lib
57
+ - demo/doc/rdoc/files/lib/foo
58
+ - demo/doc/rdoc/files/lib/foo/foo_rb.html
59
+ - demo/doc/rdoc/fr_class_index.html
60
+ - demo/doc/rdoc/fr_file_index.html
61
+ - demo/doc/rdoc/fr_method_index.html
62
+ - demo/doc/rdoc/index.html
63
+ - demo/doc/rdoc/rdoc-style.css
64
+ - demo/lib
65
+ - demo/lib/foo
66
+ - demo/lib/foo/foo.rb
67
+ - demo/util
68
+ - demo/util/conf
69
+ - demo/util/conf/rdoc
70
+ - demo/util/one
71
+ - demo/util/rdoc
72
+ - demo/util/tryme
73
+ - dev
74
+ - dev/taskable-simple.rb
75
+ - dev/taskable.rb
76
+ - lib
77
+ - lib/ratch
78
+ - lib/ratch/batch.rb
79
+ - lib/ratch/cli
80
+ - lib/ratch/cli/lt.rb
81
+ - lib/ratch/cli/ludo.rb
82
+ - lib/ratch/cli/ratch.rb
83
+ - lib/ratch/configutils.rb
84
+ - lib/ratch/consoleutils.rb
85
+ - lib/ratch/emailutils.rb
86
+ - lib/ratch/fileutils.rb
87
+ - lib/ratch/options.rb
88
+ - lib/ratch/runnable.rb
89
+ - lib/ratch/taskable.rb
90
+ - lib/ratch/taskutils.rb
91
+ - lib/ratch/uploadutils.rb
92
+ - meta
93
+ - meta/manifest.txt
94
+ - meta/project.yaml
95
+ - misc
96
+ - misc/original.rb
97
+ - task
98
+ - task/setup
99
+ - task/stats
100
+ - test
101
+ test_files: []
102
+
103
+ rdoc_options: []
104
+
105
+ extra_rdoc_files: []
106
+
107
+ executables: []
108
+
109
+ extensions: []
110
+
111
+ requirements: []
112
+
113
+ dependencies: []
114
+