rdd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -0
- data/README.md +45 -0
- data/Rakefile +12 -0
- data/lib/rdd/rspec.rb +27 -0
- data/lib/rdd/version.rb +3 -0
- data/lib/rdd.rb +1 -0
- data/rdd.gemspec +23 -0
- data/spec/rdd/readme_spec.rb +3 -0
- metadata +90 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
dm-regex
|
2
|
+
===
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/locochris/rdd.png)](https://travis-ci.org/locochris/rdd)
|
5
|
+
[![Dependency Status](https://gemnasium.com/locochris/rdd.png)](https://gemnasium.com/locochris/rdd)
|
6
|
+
|
7
|
+
Installation
|
8
|
+
---
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install rdd
|
12
|
+
```
|
13
|
+
|
14
|
+
# Usage
|
15
|
+
|
16
|
+
* create a `spec/readme_spec.rb` spec file
|
17
|
+
``` ruby
|
18
|
+
require 'rdd/rspec'
|
19
|
+
|
20
|
+
describe_readme(File.expand_path('../../../README.md', __FILE__))
|
21
|
+
```
|
22
|
+
|
23
|
+
* run the spec
|
24
|
+
```
|
25
|
+
rspec -cfn spec/readme_spec.rb
|
26
|
+
```
|
27
|
+
|
28
|
+
# Example Usages
|
29
|
+
---
|
30
|
+
|
31
|
+
### Example: First example
|
32
|
+
``` ruby
|
33
|
+
p 1 + 1
|
34
|
+
# => 2
|
35
|
+
```
|
36
|
+
|
37
|
+
### Example: Second example
|
38
|
+
``` ruby
|
39
|
+
a = 6
|
40
|
+
b = 7
|
41
|
+
p a + b
|
42
|
+
# => 13
|
43
|
+
p a * b
|
44
|
+
# => 42
|
45
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
|
7
|
+
task "default" => "spec"
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new do |t|
|
10
|
+
t.pattern = 'spec/**/*_spec.rb'
|
11
|
+
t.rspec_opts = ["--colour", "--format", "nested"]
|
12
|
+
end
|
data/lib/rdd/rspec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
def describe_readme(readme, example_regex=default_example_regex)
|
2
|
+
open(readme) do |f|
|
3
|
+
f.read.scan(example_regex).each do |example_name, example_code|
|
4
|
+
describe "#{example_name} (from README)" do
|
5
|
+
subject { eval_code(example_code) } # This is safe isn't it!?!? :)
|
6
|
+
|
7
|
+
it { should == expected_output(example_code) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_example_regex
|
14
|
+
@default_example_regex ||= /(Example:[ ].*?)\n``` ruby\n(.*?)```/m
|
15
|
+
end
|
16
|
+
|
17
|
+
def expected_output(example_code)
|
18
|
+
example_code.scan(/^# => (.*)/).flatten.join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def eval_code code
|
22
|
+
IO.popen("ruby", "w+") { |f|
|
23
|
+
f.write code
|
24
|
+
f.close_write
|
25
|
+
f.read.strip
|
26
|
+
}
|
27
|
+
end
|
data/lib/rdd/version.rb
ADDED
data/lib/rdd.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rdd/rspec'
|
data/rdd.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rdd/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'rdd'
|
6
|
+
|
7
|
+
gem.authors = [ 'locochris' ]
|
8
|
+
gem.email = [ 'chris@locomote.com.au' ]
|
9
|
+
gem.summary = 'RDD - Readme Driven Development - runs examples found in README files'
|
10
|
+
gem.description = gem.summary
|
11
|
+
gem.homepage = "http://github.com/locochris/#{gem.name}"
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
15
|
+
|
16
|
+
gem.require_paths = [ 'lib' ]
|
17
|
+
gem.version = RDD::VERSION
|
18
|
+
|
19
|
+
gem.required_ruby_version = '>= 1.9.2'
|
20
|
+
|
21
|
+
gem.add_development_dependency('rake', '~> 10.0')
|
22
|
+
gem.add_development_dependency('rspec', '~> 2.0')
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- locochris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '10.0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '10.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.0'
|
46
|
+
description: RDD - Readme Driven Development - runs examples found in README files
|
47
|
+
email:
|
48
|
+
- chris@locomote.com.au
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .travis.yml
|
55
|
+
- Gemfile
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/rdd.rb
|
59
|
+
- lib/rdd/rspec.rb
|
60
|
+
- lib/rdd/version.rb
|
61
|
+
- rdd.gemspec
|
62
|
+
- spec/rdd/readme_spec.rb
|
63
|
+
homepage: http://github.com/locochris/rdd
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.9.2
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
hash: 2687271622349677059
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.24
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: RDD - Readme Driven Development - runs examples found in README files
|
90
|
+
test_files: []
|