public
Description: Ruby objects are weak. They let just anybody push them over.... Pertinacious objects aren't. They'll always be there for you.
Clone URL: git://github.com/elliottcable/pertinacious.git
Search Repo:
Improved documentation, as well as fixing the YARD tasks
elliottcable (author)
Sat Jun 21 15:38:51 -0700 2008
commit  e61d6222f27831d2948f817f44f6436b2fdd534f
tree    b5561b2e512c82a35de721c357bba92bae9a5c1b
parent  9b1584260f25bfc4cfba30bd5929938460c2b1b8
...
8
9
10
 
 
11
12
13
...
45
46
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
49
50
...
83
84
85
86
 
87
88
89
...
8
9
10
11
12
13
14
15
...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
...
110
111
112
 
113
114
115
116
0
@@ -8,6 +8,8 @@ require 'yard'
0
 require 'spec/rake/spectask'
0
 require 'spec/rake/verify_rcov'
0
 
0
+require 'pp'
0
+
0
 # Runs specs, generates rcov, and opens rcov in your browser.
0
 namespace :rcov do
0
   Spec::Rake::SpecTask.new(:full) do |t|
0
@@ -45,6 +47,31 @@ namespace :yard do
0
     t.options = ['--readme', 'README.mkdn', '--output-dir', 'meta/documentation']
0
   end
0
   
0
+ task :ycov do
0
+ YARD::Registry.load
0
+
0
+ items = YARD::Registry.all
0
+ num_items = items.size.to_f
0
+ uncovered_items = YARD::Registry.all.select {|x| x.docstring.empty? }
0
+ num_uncovered_items = uncovered_items.size.to_f
0
+ num_covered_items = num_items - num_uncovered_items
0
+
0
+ items_coverage = (num_covered_items / num_items) * 100
0
+ items_coverage_string = items_coverage.to_s[/^(\d+.\d)/, 1]
0
+
0
+ coverage_threshold = 95
0
+
0
+ unless items_coverage > coverage_threshold
0
+ puts "Documentation threshold is #{coverage_threshold.to_s}%, but yours is only #{items_coverage_string}% (#{num_covered_items.to_i}/#{num_items.to_i})"
0
+ puts "Uncovered:"
0
+ uncovered_items.each do |uncovered|
0
+ puts " - #{uncovered.path} (#{uncovered.type})"
0
+ end
0
+ exit
0
+ end
0
+ puts "Documentation: #{items_coverage_string}% (threshold: #{coverage_threshold.to_s}%)"
0
+ end
0
+
0
   task :open do
0
     system 'open ' + :meta / :documentation / 'index.html' if PLATFORM['darwin']
0
   end
0
@@ -83,7 +110,7 @@ end
0
 
0
 desc 'Check everything over before commiting'
0
 task :aok => [:'rcov:full', :'rcov:open', :'rcov:verify',
0
- :'yard:html', :'yard:open',
0
+ :'yard:html', :'yard:open', :'yard:ycov',
0
               :'ditz:stage', :'ditz:html', :'ditz:todo', :'ditz:status', :'ditz:html:open']
0
 
0
 # desc 'Task run during continuous integration'
...
7
8
9
 
10
11
12
...
7
8
9
10
11
12
13
0
@@ -7,6 +7,7 @@ require 'pertinacious/base'
0
 
0
 # Welcome to Pertinacious!
0
 module Pertinacious
0
+ # This version of Pertinacious.
0
   VERSION = 0
0
   
0
   # This is incase anybody uses +include Pertinacious+ instead of the
...
49
50
51
52
53
54
55
56
 
57
58
 
 
 
 
 
 
 
 
59
 
60
61
62
63
64
65
 
66
67
68
...
49
50
51
 
 
 
 
 
52
53
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
0
@@ -49,20 +49,25 @@ module Pertinacious
0
       
0
     end
0
   end
0
-
0
- # This is included, by Pertinacious, into pertinacious classes. Thus,
0
- # +attribute+ is available to all pertinacious classes. It takes a series of
0
- # symbols as names of attributes, as well as an optional block the define
0
- # the default value of the attributes.
0
+
0
   module Core
0
- # def attribute *attributes, opts, &block # Some day, ruby 1.9, some day...
0
+
0
+ # Creates a new attribute on your class, and makes it pertinacious.
0
+ # Available to all pertinacious classes. It takes a series of symbols as
0
+ # names of attributes, as well as an optional block the define the default
0
+ # value of the attributes.
0
+ #
0
+ # @param [*Symbol] attributes one or more attribute names (as symbols)
0
+ # @param [&Proc] block accepts a block, which is called to generate the default value
0
     def attribute *attributes, &block
0
+ # def attribute *attributes, opts, &block # Some day, ruby 1.9, some day...
0
       opts = attributes.pop if attributes.last.is_a?(Hash)
0
       
0
       attributes.each do |attribute|
0
         ::Pertinacious::Attribute.new attribute, self, opts, &block
0
       end
0
     end
0
+
0
   end
0
 end
0
 
...
 
1
2
 
 
 
3
 
 
 
 
4
5
6
...
10
11
12
 
13
14
15
16
 
 
 
 
17
18
 
19
20
21
22
...
1
2
 
3
4
5
6
7
8
9
10
11
12
13
...
17
18
19
20
21
 
 
 
22
23
24
25
26
27
28
29
30
31
32
0
@@ -1,6 +1,13 @@
0
+# See {File::Extension} and {File::Pathize#/}
0
 class File
0
- Extensions = %r=^(markdown|textile|haml|sass|css|html|xhtml|rb|txt|text|atom|rss|xml)$=i
0
+
0
+ # If a missing method is called, and it matches the {Extensions} regex, it
0
+ # will be appended.
0
   module Extension
0
+ # Valid file extensions to catch as 'methods'
0
+ Extensions = %r=^(markdown|textile|haml|sass|css|html|xhtml|rb|txt|text|atom|rss|xml)$=i
0
+
0
+ # Appends any missing method if it matches the {Extensions} regex.
0
     def method_missing(meth, *args)
0
       if Extensions =~ meth.to_s
0
         [self, '.', meth.to_s].join
0
@@ -10,12 +17,15 @@ class File
0
     end
0
   end
0
   
0
+ # See {#/}
0
   module Pathize
0
- # Concatenates two objects into a path (a string).
0
- def /(o)
0
- File.join(self.to_s, o.to_s)
0
+ # Concatenates self, with another object, into a path (a string).
0
+ # @param [String, Symbol, #to_s] other the object to concatenate to self
0
+ def /(other)
0
+ File.join(self.to_s, other.to_s)
0
     end
0
   end
0
+
0
 end
0
 
0
 # Specs are in string.rb and symbol.rb
0
\ No newline at end of file
...
 
1
2
 
 
3
4
5
6
 
7
8
9
...
1
2
3
4
5
6
7
8
 
9
10
11
12
0
@@ -1,9 +1,12 @@
0
+# A stub, holds a +#describe+ stub, so I can have in-file specs.
0
 module Spec
0
   
0
+ # Contains extensions to the +Kernel+ core class, and extensions placed in
0
+ # the global namespace.
0
   module ::Kernel
0
     unless defined?(Spec::Runner)
0
       def describe *args
0
- # do nothing
0
+ # do nothing, as this is a stub
0
       end
0
     end
0
   end
...
 
1
2
3
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
+# Contains extensions to the +Symbol+ core class.
0
 class String
0
   include File::Extension
0
   include File::Pathize
...
 
1
2
3
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
+# Contains extensions to the +Symbol+ core class.
0
 class Symbol
0
   include File::Extension
0
   include File::Pathize

Comments

    No one has commented yet.