rdoc-readme 0.0.2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,3 +1,13 @@
1
+ 2011-04-06 v0.1.1
2
+ - Rake task can now send output to a file.
3
+
4
+ 2011-04-06 v0.1.0
5
+ - '#from_file' now returns array instead of printing to $stdout.
6
+ - '#from_file_handle' now returns array instead of printing to $stdout.
7
+
8
+ 2011-04-06 v0.0.3
9
+ - Added Rake task
10
+
1
11
  2011-04-01 v0.0.2
2
12
  - Documentation fix.
3
13
 
data/README.rdoc CHANGED
@@ -2,15 +2,31 @@
2
2
 
3
3
  == Usage
4
4
 
5
+ require 'rdoc-readme'
6
+
5
7
  RDoc::Readme.new do |rdoc|
6
- rdoc.from_file(file_name) # Prints to $stdout
7
- rdoc.from_file_handle($stdin) # Prints to $stdout
8
+ # Read from file
9
+ rdoc.from_file(file_name).each { |line| puts line }
10
+
11
+ # Read from file handle
12
+ rdoc.from_file_handle($stdin).each { |line| puts line }
8
13
  end
9
14
 
15
+ == Rake Task
16
+
17
+ require 'rdoc-readme/rake_task'
18
+
19
+ # Pull in RDoc from source file and print to destination file.
20
+ RDoc::Readme::RakeTask.new 'lib/rdoc-readme.rb', 'README.rdoc'
21
+
22
+ # Pull in RDoc from source file and print to $stdout.
23
+ RDoc::Readme::RakeTask.new 'lib/rdoc-readme.rb'
24
+
25
+ # Pull in RDoc from $stdin and print to $stdout.
26
+ RDoc::Readme::RakeTask.new
27
+
10
28
  == To Do
11
29
 
12
30
  * Tests!
13
- * Add Rake task
14
- * Don't automagically print to +STDOUT+
15
31
  * Use +RDoc+ and/or +YARD+ to handle the parsing.
16
32
 
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require './lib/rdoc-readme/rake_task'
5
+ RDoc::Readme::RakeTask.new 'lib/rdoc-readme.rb', 'README.rdoc'
6
+
@@ -0,0 +1,31 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'rdoc-readme'
4
+
5
+ module RDoc # :nodoc:
6
+ class Readme # :nodoc:
7
+
8
+ class RakeTask < ::Rake::TaskLib # :nodoc:
9
+
10
+ def initialize( src=nil, dst=nil )
11
+ @name = 'rdoc:readme'
12
+
13
+ desc('Generate README from RDoc')
14
+ task @name do
15
+ RDoc::Readme.new do |rdoc|
16
+ if src && dst
17
+ File.open(dst, 'w').puts( rdoc.from_file(src) )
18
+ elsif src
19
+ puts rdoc.from_file(src)
20
+ else
21
+ puts rdoc.from_file_handle($stdin)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ end # class RakeTask
28
+
29
+ end # class Readme
30
+ end # module RDoc
31
+
@@ -1,5 +1,5 @@
1
1
  module RDoc # :nodoc:
2
2
  class Readme
3
- VERSION = '0.0.2'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
data/lib/rdoc-readme.rb CHANGED
@@ -3,16 +3,32 @@ module RDoc # :nodoc:
3
3
  #
4
4
  # == Usage
5
5
  #
6
+ # require 'rdoc-readme'
7
+ #
6
8
  # RDoc::Readme.new do |rdoc|
7
- # rdoc.from_file(file_name) # Prints to $stdout
8
- # rdoc.from_file_handle($stdin) # Prints to $stdout
9
+ # # Read from file
10
+ # rdoc.from_file(file_name).each { |line| puts line }
11
+ #
12
+ # # Read from file handle
13
+ # rdoc.from_file_handle($stdin).each { |line| puts line }
9
14
  # end
10
15
  #
16
+ # == Rake Task
17
+ #
18
+ # require 'rdoc-readme/rake_task'
19
+ #
20
+ # # Pull in RDoc from source file and print to destination file.
21
+ # RDoc::Readme::RakeTask.new 'lib/rdoc-readme.rb', 'README.rdoc'
22
+ #
23
+ # # Pull in RDoc from source file and print to $stdout.
24
+ # RDoc::Readme::RakeTask.new 'lib/rdoc-readme.rb'
25
+ #
26
+ # # Pull in RDoc from $stdin and print to $stdout.
27
+ # RDoc::Readme::RakeTask.new
28
+ #
11
29
  # == To Do
12
30
  #
13
31
  # * Tests!
14
- # * Add Rake task
15
- # * Don't automagically print to +STDOUT+
16
32
  # * Use +RDoc+ and/or +YARD+ to handle the parsing.
17
33
  #
18
34
  class Readme
@@ -22,22 +38,31 @@ module RDoc # :nodoc:
22
38
  yield self if block_given?
23
39
  end
24
40
 
25
- # Read RDoc from filehandle.
41
+ # Read RDoc from file handle. Returns array of output lines.
42
+ #
43
+ # Params:
44
+ # +fh+:: Read from this file handle.
26
45
  def from_file_handle(fh)
27
- rdoc = false
46
+ out = []
47
+ rdoc = false
28
48
 
29
49
  fh.readlines.each do |line|
30
50
  line.chomp!
31
51
 
32
52
  if rdoc
33
- comment?(line) ? ( puts sanitize(line) ) : rdoc = false
53
+ comment?(line) ? ( out << sanitize(line) ) : rdoc = false
34
54
  else
35
- start?(line) ? ( rdoc = true ; puts sanitize(line) ) : rdoc = false
55
+ start?(line) ? ( rdoc = true ; out << sanitize(line) ) : rdoc = false
36
56
  end
37
57
  end
58
+
59
+ out
38
60
  end
39
61
 
40
- # Read RDoc from file.
62
+ # Read RDoc from file. Returns array of output lines.
63
+ #
64
+ # Params:
65
+ # +fn+:: Read from this file.
41
66
  def from_file(fn)
42
67
  from_file_handle( File.open(fn) )
43
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-readme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-01 00:00:00.000000000 -05:00
12
+ date: 2011-04-06 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Extract high-level RDoc for use in a README file
@@ -27,6 +27,7 @@ files:
27
27
  - Rakefile
28
28
  - bin/rdoc2readme
29
29
  - lib/rdoc-readme.rb
30
+ - lib/rdoc-readme/rake_task.rb
30
31
  - lib/rdoc-readme/version.rb
31
32
  - rdoc-readme.gemspec
32
33
  has_rdoc: true