todo_next 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/CHANGELOG +2 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/LICENSE +22 -0
- data/README.md +67 -0
- data/Rakefile +2 -0
- data/bin/todo_next +4 -0
- data/bin/todonext +4 -0
- data/doc/screenshot_1.png +0 -0
- data/doc/screenshot_2.png +0 -0
- data/lib/todo_next/cli/assets/rspec_example_file.rb.erb +19 -0
- data/lib/todo_next/cli/sample_file_generator.rb +56 -0
- data/lib/todo_next/cli.rb +11 -0
- data/lib/todo_next/line.rb +25 -0
- data/lib/todo_next/parser.rb +26 -0
- data/lib/todo_next/rspec_generator_visitor.rb +22 -0
- data/lib/todo_next/tree/depth_first_visitor_base.rb +24 -0
- data/lib/todo_next/tree/factory.rb +43 -0
- data/lib/todo_next/tree/node.rb +25 -0
- data/lib/todo_next/tree/parents_list.rb +23 -0
- data/lib/todo_next/tree.rb +19 -0
- data/lib/todo_next/version.rb +3 -0
- data/lib/todo_next.rb +23 -0
- data/spec/01_parse_the_text_spec.rb +69 -0
- data/spec/02_visit_the_tree_spec.rb +41 -0
- data/spec/03_rspec_generator_visitor_spec.rb +34 -0
- data/spec/spec_helper.rb +52 -0
- data/todo_next.gemspec +20 -0
- metadata +126 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alain Ravet
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Goal::Tdd
|
2
|
+
|
3
|
+
A small DSL that converts free text into pending tests/specs.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'todo_next'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Create a first spec with a todo_next skeleton:
|
18
|
+
|
19
|
+
```shell
|
20
|
+
$ cd <project>
|
21
|
+
$ todo_next stack
|
22
|
+
# => <project>/spec/stack_spec.rb was created.
|
23
|
+
$ cat spec/stack_spec.rb
|
24
|
+
# =>
|
25
|
+
```
|
26
|
+
```ruby
|
27
|
+
require 'rubygems'
|
28
|
+
require 'rspec'
|
29
|
+
require 'todo_next'
|
30
|
+
|
31
|
+
todo_next(<<TEXT)
|
32
|
+
A Foobar
|
33
|
+
- is white by default
|
34
|
+
- can be resized
|
35
|
+
truthiness()
|
36
|
+
- is always true
|
37
|
+
(add more tests)
|
38
|
+
TEXT
|
39
|
+
|
40
|
+
|
41
|
+
#describe "<what you're testing>" do
|
42
|
+
# specify 'this should happen' do
|
43
|
+
# .. some code
|
44
|
+
# end
|
45
|
+
```
|
46
|
+
This text is equivalent to :
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
describe "A Foobar" do
|
50
|
+
it "- is white by default"
|
51
|
+
describe "- can be resized" do
|
52
|
+
it "- is always true"
|
53
|
+
end
|
54
|
+
it "(add more tests)"
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
![screenshot1](https://github.com/alainravet/todo_next/raw/master/doc/screenshot_1.png)
|
59
|
+
![screenshot1](https://github.com/alainravet/todo_next/raw/master/doc/screenshot_2.png)
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/todo_next
ADDED
data/bin/todonext
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'todo_next'
|
4
|
+
|
5
|
+
todo_next(<<TEXT)
|
6
|
+
A <%= classname %>
|
7
|
+
- is white by default
|
8
|
+
- can be resized
|
9
|
+
truthiness()
|
10
|
+
- is always true
|
11
|
+
(add more tests)
|
12
|
+
TEXT
|
13
|
+
|
14
|
+
|
15
|
+
#describe "<what you're testing>" do
|
16
|
+
# specify 'this should happen' do
|
17
|
+
# .. some code
|
18
|
+
# end
|
19
|
+
#end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module TodoNext
|
4
|
+
class CLI
|
5
|
+
class SampleFileGenerator
|
6
|
+
|
7
|
+
TEMPLATE_PATH = File.dirname(__FILE__) + '/assets/rspec_example_file.rb.erb'
|
8
|
+
|
9
|
+
def self.generate(object_name)
|
10
|
+
object_name = object_name && object_name.downcase
|
11
|
+
target_file = sample_file_path(object_name)
|
12
|
+
|
13
|
+
erb = ERB.new(File.read(TEMPLATE_PATH))
|
14
|
+
classname = (object_name || 'foobar').capitalize # for ERB/binding
|
15
|
+
rspec_sample = erb.result(binding)
|
16
|
+
|
17
|
+
if File.exist?(target_file)
|
18
|
+
File.open(target_file, "r") do |orig|
|
19
|
+
@original = orig.read()
|
20
|
+
end
|
21
|
+
if @original.include?(rspec_sample)
|
22
|
+
puts "skipping : sample code already present in #{target_file}."
|
23
|
+
else
|
24
|
+
File.open(target_file, "r") do |orig|
|
25
|
+
File.unlink(target_file)
|
26
|
+
File.open(target_file, "w") do |new|
|
27
|
+
new.write rspec_sample
|
28
|
+
new.write(@original)
|
29
|
+
end
|
30
|
+
puts "sample code was inserted in #{target_file}."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
else
|
34
|
+
File.open(target_file,'w') do |f| f.write(rspec_sample) end
|
35
|
+
puts "#{target_file} was created."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def self.sample_file_path(object_name)
|
42
|
+
file_name = object_name ?
|
43
|
+
"#{object_name}_spec.rb" :
|
44
|
+
'todo_next_spec.rb'
|
45
|
+
"#{sample_file_dir}/#{file_name}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.sample_file_dir
|
49
|
+
curr_dir = `pwd`.chomp
|
50
|
+
candidate = "#{curr_dir}/spec"
|
51
|
+
File.directory?(candidate) ? candidate : curr_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TodoNext
|
2
|
+
|
3
|
+
class Line
|
4
|
+
attr_accessor :text, :col_offset, :leaf
|
5
|
+
|
6
|
+
def initialize(text, col_offset)
|
7
|
+
@text, @col_offset = text, col_offset
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
"<Line# text:#{text}, leaf:#{leaf}, col_offset:#{col_offset}>"
|
12
|
+
end
|
13
|
+
|
14
|
+
def blank?
|
15
|
+
text =~ /^\s*$/
|
16
|
+
end
|
17
|
+
def comment?
|
18
|
+
text =~ /^#/
|
19
|
+
end
|
20
|
+
|
21
|
+
def leaf? ; leaf end
|
22
|
+
def branch? ; !leaf? end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/tree'
|
2
|
+
require File.dirname(__FILE__) + '/line'
|
3
|
+
require File.dirname(__FILE__) + '/rspec_generator_visitor'
|
4
|
+
require File.dirname(__FILE__) + '/cli'
|
5
|
+
|
6
|
+
module TodoNext
|
7
|
+
|
8
|
+
class Parser
|
9
|
+
def self.parse(text)
|
10
|
+
lines = extract_meaningful_lines(text)
|
11
|
+
tree = Tree::Factory.build(lines)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.extract_meaningful_lines(text)
|
15
|
+
text.
|
16
|
+
split("\n").
|
17
|
+
collect do |text|
|
18
|
+
col_offset = text =~ /\S/
|
19
|
+
Line.new(text.strip, col_offset)
|
20
|
+
end.
|
21
|
+
reject{|l| l.blank? }.
|
22
|
+
reject{|l| l.comment?}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/tree/depth_first_visitor_base'
|
2
|
+
|
3
|
+
module TodoNext
|
4
|
+
|
5
|
+
class RspecGeneratorVisitor < TodoNext::Tree::DepthFirstVisitorBase
|
6
|
+
def visit(curr_node, level) #nodoc#
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def process_terminal_node(curr_node, level)
|
11
|
+
tabs = ' '*(level-1)
|
12
|
+
code = %Q|#{tabs}it("#{curr_node.text}", :pending => "#{curr_node.text}"){}|
|
13
|
+
end
|
14
|
+
|
15
|
+
def process_non_terminal_node(curr_node, level)
|
16
|
+
tabs = ' '*(level-1)
|
17
|
+
codes = curr_node.children.collect { |node| visit(node, 1+level) }
|
18
|
+
[%Q|#{tabs}describe "#{curr_node.text}" do|] + codes + ["#{tabs}end"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module TodoNext
|
2
|
+
class Tree
|
3
|
+
|
4
|
+
class DepthFirstVisitorBase
|
5
|
+
|
6
|
+
def visit(curr_node, level) #nodoc#
|
7
|
+
if curr_node.terminal?
|
8
|
+
process_terminal_node(curr_node, level)
|
9
|
+
else
|
10
|
+
process_non_terminal_node(curr_node, level)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# overwrite in the concrete visitor class
|
15
|
+
def process_terminal_node(curr_node, level)
|
16
|
+
end
|
17
|
+
|
18
|
+
# overwrite in the concrete visitor class
|
19
|
+
def process_non_terminal_node(curr_node, level)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/node'
|
2
|
+
require File.dirname(__FILE__) + '/parents_list'
|
3
|
+
|
4
|
+
module TodoNext
|
5
|
+
|
6
|
+
class Tree
|
7
|
+
class Factory
|
8
|
+
|
9
|
+
def self.build(lines)
|
10
|
+
mark_the_leaves_and_the_branches(lines)
|
11
|
+
|
12
|
+
tree = Tree.new
|
13
|
+
parents = ParentsList.new
|
14
|
+
|
15
|
+
lines.each do |line|
|
16
|
+
curr_line_col = line.col_offset
|
17
|
+
parent = parents.get_for_item_at_column(curr_line_col) || tree
|
18
|
+
|
19
|
+
if line.branch?
|
20
|
+
new_node = Tree::OL.new(line.text, parent)
|
21
|
+
parents.register_parent(new_node, :for_col => curr_line_col)
|
22
|
+
else
|
23
|
+
new_node = Tree::LI.new(line.text, parent)
|
24
|
+
end
|
25
|
+
parent.children << new_node
|
26
|
+
end
|
27
|
+
tree
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def self.mark_the_leaves_and_the_branches(lines)
|
33
|
+
lines.each_with_index do |curr_line, idx|
|
34
|
+
next_line = lines[1+idx]
|
35
|
+
next_line_is_child = next_line && curr_line.col_offset < next_line.col_offset
|
36
|
+
curr_line.leaf = !next_line_is_child
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TodoNext
|
2
|
+
|
3
|
+
class Tree
|
4
|
+
class Node
|
5
|
+
attr_accessor :text, :parent, :children
|
6
|
+
def initialize(text, parent=nil)
|
7
|
+
@text, @parent = text, parent
|
8
|
+
@children = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def terminal?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class OL < Node ; end
|
17
|
+
|
18
|
+
class LI < Node
|
19
|
+
def terminal?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TodoNext
|
2
|
+
|
3
|
+
class Tree
|
4
|
+
class ParentsList
|
5
|
+
|
6
|
+
def initialize(parents=nil)
|
7
|
+
@parents = parents || { -1 => nil }
|
8
|
+
end
|
9
|
+
|
10
|
+
def register_parent(new_parent, options)
|
11
|
+
curr_col = options.fetch(:for_col)
|
12
|
+
@parents[1+curr_col] = new_parent
|
13
|
+
@parents.delete_if{|k, v| k > 1+curr_col }
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_for_item_at_column(curr_col)
|
17
|
+
parent_key = @parents.keys.sort.reverse.detect {|col| col < curr_col}
|
18
|
+
@parents[parent_key]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/tree/factory'
|
2
|
+
|
3
|
+
module TodoNext
|
4
|
+
|
5
|
+
class Tree
|
6
|
+
attr_accessor :children
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@children = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def visit(visitor)
|
13
|
+
children.collect do |node|
|
14
|
+
visitor.visit(node, level=1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/todo_next.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/todo_next/version'
|
2
|
+
|
3
|
+
module TodoNext
|
4
|
+
# Your code goes here...
|
5
|
+
end
|
6
|
+
require File.dirname(__FILE__) + '/todo_next/parser'
|
7
|
+
|
8
|
+
main = TOPLEVEL_BINDING.eval('self')
|
9
|
+
def main.todo_next(text, puts_code=false)
|
10
|
+
code = TodoNext(text)
|
11
|
+
if puts_code
|
12
|
+
puts '---' ; puts code ; puts '---'
|
13
|
+
end
|
14
|
+
eval code
|
15
|
+
end
|
16
|
+
|
17
|
+
def TodoNext(source)
|
18
|
+
TodoNext::Parser.
|
19
|
+
parse(source).
|
20
|
+
visit(TodoNext::RspecGeneratorVisitor.new).
|
21
|
+
flatten.
|
22
|
+
join("\n")
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TodoNext::Parser, 'parsing indented text and producing a Tree' do
|
4
|
+
|
5
|
+
it 'ignores comments and blank lines' do
|
6
|
+
@source = '# a comment' + "\n" +
|
7
|
+
' # a comment' + "\n" +
|
8
|
+
' ' + "\n" +
|
9
|
+
''
|
10
|
+
result_should_be []
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'converts a single line into a free :li element' do
|
14
|
+
@source = 'HEADER 1' + "\n"
|
15
|
+
|
16
|
+
result_should_be [{:type => :li , :text => "HEADER 1"}]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'converts 2 lines starting in col 0 into 2 free :li elements' do
|
20
|
+
@source = 'HEADER 1' + "\n" +
|
21
|
+
'HEADER 2' + "\n"
|
22
|
+
|
23
|
+
result_should_be [ {:type => :li , :text => "HEADER 1"},
|
24
|
+
{:type => :li , :text => "HEADER 2"}
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'converts 2 lines under a header as 2 :li under 1 :ol' do
|
29
|
+
@source = 'HEADER 1' + "\n" +
|
30
|
+
' spec a' + "\n" +
|
31
|
+
' spec b'
|
32
|
+
|
33
|
+
result_should_be [ {:type => :ol , :text => "HEADER 1",
|
34
|
+
:children => [
|
35
|
+
{:type => :li, :text => "spec a"},
|
36
|
+
{:type => :li, :text => "spec b"}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'converts a complex text into the proper Tree' do
|
43
|
+
@source = 'HEADER 1' + "\n" +
|
44
|
+
' HEADER 2' + "\n" +
|
45
|
+
' HEADER 3' + "\n" +
|
46
|
+
' spec a' + "\n" +
|
47
|
+
'HEADER 4' + "\n" +
|
48
|
+
' spec b' + "\n"
|
49
|
+
|
50
|
+
result_should_be [ {:type => :ol, :text => "HEADER 1",
|
51
|
+
:children => [
|
52
|
+
{:type => :ol, :text => "HEADER 2",
|
53
|
+
:children => [
|
54
|
+
{:type =>:ol, :text => "HEADER 3",
|
55
|
+
:children =>[ {:type => :li, :text => "spec a"} ]
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
]
|
60
|
+
},
|
61
|
+
|
62
|
+
{:type => :ol, :text => "HEADER 4",
|
63
|
+
:children => [
|
64
|
+
{:type => :li, :text=>"spec b"}
|
65
|
+
]
|
66
|
+
}
|
67
|
+
]
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe TodoNext::Tree, 'visiting the tree depth-first' do
|
5
|
+
|
6
|
+
|
7
|
+
class SimpleVisitor < TodoNext::Tree::DepthFirstVisitorBase
|
8
|
+
def process_terminal_node(curr_node, level)
|
9
|
+
curr_node.text
|
10
|
+
end
|
11
|
+
|
12
|
+
def process_non_terminal_node(curr_node, level)
|
13
|
+
result = curr_node.children.collect { |node| visit(node, 1+level) }.join(', ')
|
14
|
+
"#{curr_node.text}=[#{result}]"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
it 'visits the tree depth-first' do
|
20
|
+
expected = ['HEADER 1=[HEADER 2=[HEADER 3=[spec a, spec b]]]' ,
|
21
|
+
'HEADER 4=[spec c]',
|
22
|
+
'HEADER 5',
|
23
|
+
'HEADER 6'
|
24
|
+
]
|
25
|
+
|
26
|
+
source = 'HEADER 1' + "\n" +
|
27
|
+
' HEADER 2' + "\n" +
|
28
|
+
' HEADER 3' + "\n" +
|
29
|
+
' spec a' + "\n" +
|
30
|
+
' spec b' + "\n" +
|
31
|
+
'HEADER 4' + "\n" +
|
32
|
+
' spec c' + "\n" +
|
33
|
+
'HEADER 5' + "\n" +
|
34
|
+
'HEADER 6'
|
35
|
+
|
36
|
+
TodoNext::Parser.
|
37
|
+
parse(source).
|
38
|
+
visit(SimpleVisitor.new).
|
39
|
+
should == expected
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TodoNext::RspecGeneratorVisitor do
|
4
|
+
|
5
|
+
it 'visits the tree depth-first' do
|
6
|
+
source = 'HEADER 1' + "\n" +
|
7
|
+
' HEADER 2' + "\n" +
|
8
|
+
' HEADER 3' + "\n" +
|
9
|
+
' spec a' + "\n" +
|
10
|
+
' spec b' + "\n" +
|
11
|
+
'HEADER 4' + "\n" +
|
12
|
+
' spec c' + "\n" +
|
13
|
+
'HEADER 5' + "\n" +
|
14
|
+
'HEADER 6'
|
15
|
+
|
16
|
+
expected =<<RUBY.chomp
|
17
|
+
describe "HEADER 1" do
|
18
|
+
describe "HEADER 2" do
|
19
|
+
describe "HEADER 3" do
|
20
|
+
it("spec a", :pending => "spec a"){}
|
21
|
+
it("spec b", :pending => "spec b"){}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe "HEADER 4" do
|
26
|
+
it("spec c", :pending => "spec c"){}
|
27
|
+
end
|
28
|
+
it("HEADER 5", :pending => "HEADER 5"){}
|
29
|
+
it("HEADER 6", :pending => "HEADER 6"){}
|
30
|
+
RUBY
|
31
|
+
|
32
|
+
TodoNext(source).should == expected
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
18
|
+
|
19
|
+
require File.dirname(__FILE__) + '/../lib/todo_next.rb'
|
20
|
+
|
21
|
+
class TodoNext::Tree
|
22
|
+
def to_hash
|
23
|
+
{
|
24
|
+
:children => children.collect{|ch| ch.to_hash }
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
class OL
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
{ :type => :ol,
|
32
|
+
:text => text,
|
33
|
+
:children => children.collect{|ch| ch.to_hash }
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
class LI
|
38
|
+
def to_hash
|
39
|
+
{ :type => :li,
|
40
|
+
:text => text
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def parsed_result(source)
|
47
|
+
TodoNext::Parser.parse(source).to_hash[:children]
|
48
|
+
end
|
49
|
+
|
50
|
+
def result_should_be(expected)
|
51
|
+
parsed_result(@source).should == expected
|
52
|
+
end
|
data/todo_next.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/todo_next/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alain Ravet"]
|
6
|
+
gem.email = ["alainravet@gmail.com"]
|
7
|
+
gem.description = %q{small DSL to convert free text into pending tests/specs}
|
8
|
+
gem.summary = %q{small DSL to convert free text into pending tests/specs}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "todo_next"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = TodoNext::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rake' # to run 'All specs in Rubymine'
|
19
|
+
gem.add_development_dependency 'rspec'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: todo_next
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alain Ravet
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-07-21 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
prerelease: false
|
31
|
+
type: :development
|
32
|
+
name: rake
|
33
|
+
requirement: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
hash: 3
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
prerelease: false
|
45
|
+
type: :development
|
46
|
+
name: rspec
|
47
|
+
requirement: *id002
|
48
|
+
description: small DSL to convert free text into pending tests/specs
|
49
|
+
email:
|
50
|
+
- alainravet@gmail.com
|
51
|
+
executables:
|
52
|
+
- todo_next
|
53
|
+
- todonext
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- .rspec
|
61
|
+
- CHANGELOG
|
62
|
+
- Gemfile
|
63
|
+
- Guardfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/todo_next
|
68
|
+
- bin/todonext
|
69
|
+
- doc/screenshot_1.png
|
70
|
+
- doc/screenshot_2.png
|
71
|
+
- lib/todo_next.rb
|
72
|
+
- lib/todo_next/cli.rb
|
73
|
+
- lib/todo_next/cli/assets/rspec_example_file.rb.erb
|
74
|
+
- lib/todo_next/cli/sample_file_generator.rb
|
75
|
+
- lib/todo_next/line.rb
|
76
|
+
- lib/todo_next/parser.rb
|
77
|
+
- lib/todo_next/rspec_generator_visitor.rb
|
78
|
+
- lib/todo_next/tree.rb
|
79
|
+
- lib/todo_next/tree/depth_first_visitor_base.rb
|
80
|
+
- lib/todo_next/tree/factory.rb
|
81
|
+
- lib/todo_next/tree/node.rb
|
82
|
+
- lib/todo_next/tree/parents_list.rb
|
83
|
+
- lib/todo_next/version.rb
|
84
|
+
- spec/01_parse_the_text_spec.rb
|
85
|
+
- spec/02_visit_the_tree_spec.rb
|
86
|
+
- spec/03_rspec_generator_visitor_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- todo_next.gemspec
|
89
|
+
homepage: ""
|
90
|
+
licenses: []
|
91
|
+
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.8.24
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: small DSL to convert free text into pending tests/specs
|
122
|
+
test_files:
|
123
|
+
- spec/01_parse_the_text_spec.rb
|
124
|
+
- spec/02_visit_the_tree_spec.rb
|
125
|
+
- spec/03_rspec_generator_visitor_spec.rb
|
126
|
+
- spec/spec_helper.rb
|