Permalink
Browse files

Better README DRY tools

  • Loading branch information...
1 parent f5eb59b commit 6eabba0fb8933174533bf03fc911972bdff52492 @rking committed with rking@sharpsaw.org Jan 7, 2013
Showing with 58 additions and 10 deletions.
  1. +3 −0 Gemfile
  2. +2 −0 Guardfile
  3. +9 −6 README.md
  4. +1 −0 Rakefile
  5. +0 −1 bin/working-init
  6. +24 −2 lib/working.rb
  7. +1 −0 lib/working/rake_tasks.rb
  8. +1 −1 lib/working/version.rb
  9. +5 −0 test/test_helper.rb
  10. +12 −0 test/working_test.rb
View
@@ -1 +1,4 @@
source :rubygems; gemspec
+group :development do
+ gem 'working', path: '.'
+end
View
@@ -0,0 +1,2 @@
+require 'working/guard'
+# vim ft=ruby
View
@@ -1,22 +1,25 @@
-# Working
+= Working
Whoa!! ☈king's opinionated rig for Ruby dev.
-- Guard for test running (`bundle exec guard`)
+== Basic Idea
+
+- Opinionatedly uses MiniTest for everything. It makes better in-memory structures than RSpec, and is therefore better for the goals of https://github.com/pry/pry/wiki/pry-de
- 1:1 mapping between stuff in `lib/` or `app/` and the `test/` dirs.
+- Guard for test running (`bundle exec guard`)
- Spork in effect for faster runs
-# See also:
+== See also:
http://github.com/rking/working-rails
-## Example uses:
+== Example uses:
- https://github.com/rking/demo-ruby-tests
- https://github.com/rking/monkeynote
- https://github.com/rking/terminal-info
-## Installation
+== Installation
Add this line to your application's Gemfile:
@@ -27,6 +30,6 @@ And then execute:
bundle
working-init # this tinkers with several files (verbosely)
-## TODO
+== TODO
Explain the parts.
View
@@ -1 +1,2 @@
require 'bundler/gem_tasks'
+require 'working/rake_tasks'
View
@@ -24,7 +24,6 @@ end
'# vim ft=ruby',
],
'Rakefile' => [
- # gem TODO require 'bundler/gem_tasks'
%{require 'working/rake_tasks'}
],
'test/test_helper.rb' => [
View
@@ -1,5 +1,27 @@
-require "working/version"
+require 'working/version'
module Working
- # Your code goes here...
+ README_PATH = 'README.rdoc'
+
+ class << self
+ def file_snippet path, start_pattern, end_pattern
+ desired = []
+ File.readlines(path).each do |e|
+ return desired.join if e[end_pattern]
+ in_desired_region = true if e[start_pattern]
+ desired << e if in_desired_region
+ end
+ desired
+ end
+ def readme_snippet start_pattern, end_pattern
+ file_snippet README_PATH, start_pattern, end_pattern
+ end
+
+ def file_third_line path
+ File.readlines(path)[2]
+ end
+ def third_line_of_readme
+ file_third_line README_PATH
+ end
+ end
end
@@ -1,3 +1,4 @@
+require 'bundler/gem_tasks'
task default: :test
task :test do
Dir['test/**/*_test.rb'].each{|e| load e}
@@ -1,3 +1,3 @@
module Working
- VERSION = '0.0.7'
+ VERSION = '0.0.8'
end
View
@@ -0,0 +1,5 @@
+require 'working/test_helper'
+# Spork.prefork doesn't like when this is missing
+Spork.each_run do
+ require 'working'
+end
View
@@ -0,0 +1,12 @@
+require './test/test_helper.rb'
+class WorkingTest < MiniTest::Unit::TestCase
+ def test_file_snippet
+ actual = Working.file_snippet(__FILE__, /^require/, /^class/)
+ assert_equal "require './test/test_helper.rb'\n", actual
+ end
+
+ # This is because I put the gem.summary on the 3rd line of the README.rdoc
+ def test_third_line
+ assert_equal " def test_file_snippet\n", Working.file_third_line(__FILE__)
+ end
+end

0 comments on commit 6eabba0

Please sign in to comment.