Skip to content
This repository
Browse code

got suites going ... need to pay some tech debt asap

  • Loading branch information...
commit 3690a872b703fc6194ba468452e72a1baac2d3e4 1 parent f53b6cc
mike suarez msuarz authored
2  package.json
... ... @@ -1,6 +1,6 @@
1 1 {
2 2 "name": "frankendoc",
3   - "version": "0.2.2",
  3 + "version": "0.2.3",
4 4 "description" : "bringing documents alive",
5 5 "repository" : { "type" : "git", "url" : "https://github.com/limadelic/frankendoc.git" },
6 6 "keywords" : ["testing", "atdd", "bdd"],
8 src/frankendoc.coffee
@@ -18,10 +18,10 @@ class Frank
18 18 @report.start()
19 19 @read()
20 20
21   - console.log doc.name for doc in @files.docs
22   - #if doc.is_suite
23   - #then @report.suite doc
24   - #else @run_doc doc
  21 + for doc in @files.docs()
  22 + if doc.is_suite
  23 + then @report.suite doc
  24 + else @run_doc doc
25 25
26 26 @report.stop()
27 27
36 src/readers/confluence.coffee
... ... @@ -1,5 +1,5 @@
1 1 rest = require 'restler'
2   -{ Doc } = require './doc'
  2 +{ Docs } = require './docs'
3 3
4 4 class @Reader
5 5
@@ -7,36 +7,32 @@ class @Reader
7 7 return unless @root?
8 8 @pending_docs = [ @root ]
9 9 while @pending_docs.length
10   - doc @pending_docs.shift()
  10 + doc = @pending_docs.shift()
11 11 if doc.is_suite
12   - @docs.push doc
13   - else
14   - @sync.read_doc doc
  12 + then @docs.add_suite doc.name
  13 + else @sync.read_doc doc
  14 + @docs
15 15
16 16 read_doc: (id, done) ->
17 17 uri = "#{@root_uri}/content/#{id}?expand=children"
18 18
19   - rest.get(uri, @options).on 'complete', (data) =>
20   - children = @children data
21   - @add_suite data if children.length
22   - @add_doc data
23   - @pending_docs.unshift children
  19 + rest.get(uri, @options).on 'complete', (@data) =>
  20 + @add_suite() if @has_children()
  21 + @add_doc()
  22 + @queue_children()
24 23 done()
25 24
26   - add_suite: (data) -> @pending_docs.unshift @docs.push
27   - name: data.title
28   - is_suite: true
  25 + add_suite: -> @pending_docs.unshift @docs.add_suite @data.title
29 26
30   - add_doc: (data) -> @docs.push
31   - name: data.title
32   - steps: @doc.read data.body.value
  27 + add_doc: -> @docs.add @data.title, @data.body.value
33 28
34   - children: (data) -> child.id for child in data.children.content
  29 + has_children: -> @data.children.content.length
  30 +
  31 + queue_children: -> for child in @data.children.content
  32 + @pending_docs.unshift child.id
35 33
36 34 constructor: ->
37   - @docs = []
38   -
39   - @doc = new Doc
  35 + @docs = new Docs
40 36 line_break: '\n'
41 37 code_block: /ac:name="code".*?CDATA\[([\s\S]*?)\]\]><\//g
42 38
28 src/readers/docs.coffee
... ... @@ -0,0 +1,28 @@
  1 +{ Doc } = require './doc'
  2 +_ = require 'underscore'
  3 +
  4 +class @Docs
  5 +
  6 + constructor: (opt) ->
  7 + @docs = []
  8 + @doc = new Doc opt
  9 +
  10 + add: (name, content) ->
  11 + @docs.push
  12 + name: name
  13 + steps: @doc.read content
  14 + @last()
  15 +
  16 + add_suite: (name) ->
  17 + return if @removed_empty_suite(name)?
  18 +
  19 + @docs.push
  20 + name: name
  21 + is_suite: true
  22 +
  23 + @last()
  24 +
  25 + removed_empty_suite: (name) ->
  26 + @docs.pop() if @last()?.is_suite and @last().name is name
  27 +
  28 + last: -> _.last @docs
37 src/readers/files.coffee
@@ -2,35 +2,37 @@ fs = require 'fs'
2 2 path = require 'path'
3 3
4 4 { Reader } = require './confluence'
5   -{ Doc } = require './doc'
  5 +{ Docs } = require './docs'
6 6
7 7 class @Files
8 8
9 9 constructor: ->
10   - @docs = []
11 10 @code = []
12   - @doc = new Doc
  11 + @_docs = new Docs
  12 +
  13 + docs: -> @_docs.docs
13 14
14 15 is_dir: -> fs.statSync(@file).isDirectory()
  16 + skip_dir: -> @file.match /node_modules$/
15 17
16 18 find_files: (dir, ext, add) ->
17 19 @add_suite dir
  20 +
18 21 for file in fs.readdirSync dir
19   - @file = path.resolve dir, file
20   - if @is_dir()
21   - @find_files @file, ext, add unless file is 'node_modules'
22   - else if @file.match ext
23   - add()
  22 + @find_file path.resolve(dir, file), ext, add
  23 +
24 24 @add_suite dir
25 25
  26 + find_file: (@file, ext, add) ->
  27 + if @is_dir()
  28 + then @find_files(@file, ext, add) unless @skip_dir()
  29 + else add() if @file.match(ext)
  30 +
26 31 read: ->
27 32 @read_docs()
28 33 @read_code()
29 34
30   - use_reader: ->
31   - reader = new Reader
32   - reader.docs = @docs
33   - reader.read()
  35 + use_reader: -> @_docs = new Reader().read()
34 36
35 37 read_docs: ->
36 38 return @use_reader() if settings.docs.source isnt 'files'
@@ -39,13 +41,12 @@ class @Files
39 41
40 42 @find_files settings.docs.root, docs_type, @add_doc
41 43
42   - add_doc: => @docs.push
43   - name: path.basename @file, settings.docs.type
44   - steps: @doc.read @contents()
  44 + add_doc: => @_docs.add(
  45 + path.basename @file, settings.docs.type
  46 + @contents()
  47 + )
45 48
46   - add_suite: (name) -> @docs.push
47   - name: name
48   - is_suite: true
  49 + add_suite: (name) -> @_docs.add_suite path.basename name
49 50
50 51 contents: -> fs.readFileSync @file, 'utf8'
51 52
10 src/reports/teamcity.coffee
@@ -11,10 +11,10 @@ class @Report
11 11 suite: (it) -> @suites.report it
12 12
13 13 start_suite: (suite) ->
14   - @report "SuiteStarted name='#{@suite.name}'"
  14 + @report "SuiteStarted name='#{suite.name}'"
15 15
16 16 stop_suite: (suite) ->
17   - @report "SuiteFinished name='#{@suite.name}' duration='#{@suite.duration}'"
  17 + @report "SuiteFinished name='#{suite.name}' duration='#{suite.duration}'"
18 18
19 19 running: (@name) ->
20 20 @stats.start()
@@ -25,10 +25,10 @@ class @Report
25 25 @[@stats.stop @results]()
26 26
27 27 passed: -> @report "Finished name='#{@name}' duration='#{@stats.duration}'"
28   - failed: -> @report "Failed name='#{@name}' message='#{@message()}'"
29   - pending: -> @report "Ignored name='#{@name}' message'#{@message()}'"
  28 + failed: -> @report "Failed name='#{@name}' message=\"#{@message()}\""
  29 + pending: -> @report "Ignored name='#{@name}' message=\"#{@message()}\""
30 30
31   - message: -> _.escape @stats.messages().join '\n'
  31 + message: -> @stats.messages().join '\n'
32 32
33 33 stop: ->
34 34

0 comments on commit 3690a87

Please sign in to comment.
Something went wrong with that request. Please try again.