cuki 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +20 -0
- data/README.rdoc +5 -1
- data/Rakefile +8 -12
- data/VERSION +1 -1
- data/cuki.gemspec +19 -4
- data/features/pull/pull.feature +62 -0
- data/features/pull/pull_single.feature +28 -0
- data/features/pull/tables.feature +40 -0
- data/features/pull/tags.feature +32 -0
- data/features/pull/textile.feature +32 -0
- data/features/push/push.feature +79 -0
- data/features/push/tables.feature +3 -0
- data/features/push/tags.feature +25 -0
- data/features/step_defs/pull_steps.rb +17 -0
- data/features/support/env.rb +9 -0
- data/lib/cuki.rb +54 -15
- data/spec/cuki_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +32 -6
- data/test/helper.rb +0 -18
- data/test/test_cuki.rb +0 -7
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.8.7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.2.6)
|
5
|
+
aruba (0.4.6)
|
6
|
+
bcat (>= 0.6.1)
|
7
|
+
childprocess (>= 0.2.0)
|
8
|
+
cucumber (>= 1.0.2)
|
9
|
+
rdiscount (>= 1.6.8)
|
10
|
+
rspec (>= 2.6.0)
|
11
|
+
bcat (0.6.2)
|
12
|
+
rack (~> 1.0)
|
4
13
|
builder (3.0.0)
|
14
|
+
childprocess (0.2.2)
|
15
|
+
ffi (~> 1.0.6)
|
16
|
+
crack (0.3.1)
|
5
17
|
cucumber (1.1.0)
|
6
18
|
builder (>= 2.1.2)
|
7
19
|
diff-lcs (>= 1.1.2)
|
@@ -9,6 +21,7 @@ GEM
|
|
9
21
|
json (>= 1.4.6)
|
10
22
|
term-ansicolor (>= 1.0.6)
|
11
23
|
diff-lcs (1.1.3)
|
24
|
+
ffi (1.0.9)
|
12
25
|
gherkin (2.5.1)
|
13
26
|
json (>= 1.4.6)
|
14
27
|
git (1.2.5)
|
@@ -19,8 +32,10 @@ GEM
|
|
19
32
|
rake
|
20
33
|
json (1.6.1)
|
21
34
|
nokogiri (1.5.0)
|
35
|
+
rack (1.3.4)
|
22
36
|
rake (0.9.2)
|
23
37
|
rcov (0.9.11)
|
38
|
+
rdiscount (1.6.8)
|
24
39
|
rspec (2.6.0)
|
25
40
|
rspec-core (~> 2.6.0)
|
26
41
|
rspec-expectations (~> 2.6.0)
|
@@ -31,11 +46,15 @@ GEM
|
|
31
46
|
rspec-mocks (2.6.0)
|
32
47
|
shoulda (2.11.3)
|
33
48
|
term-ansicolor (1.0.6)
|
49
|
+
webmock (1.7.7)
|
50
|
+
addressable (~> 2.2, > 2.2.5)
|
51
|
+
crack (>= 0.1.7)
|
34
52
|
|
35
53
|
PLATFORMS
|
36
54
|
ruby
|
37
55
|
|
38
56
|
DEPENDENCIES
|
57
|
+
aruba
|
39
58
|
bundler (~> 1.0.0)
|
40
59
|
cucumber
|
41
60
|
httpclient
|
@@ -44,3 +63,4 @@ DEPENDENCIES
|
|
44
63
|
rcov
|
45
64
|
rspec
|
46
65
|
shoulda
|
66
|
+
webmock
|
data/README.rdoc
CHANGED
@@ -32,6 +32,10 @@ Run it from the command line:
|
|
32
32
|
or, if using binstubs:
|
33
33
|
|
34
34
|
bin/cuki pull
|
35
|
+
|
36
|
+
You can also pull a single feature:
|
37
|
+
|
38
|
+
cuki pull features/add_product.feature
|
35
39
|
|
36
40
|
== Options
|
37
41
|
|
@@ -49,7 +53,7 @@ or, if using binstubs:
|
|
49
53
|
== TODO
|
50
54
|
|
51
55
|
* Handle links
|
52
|
-
*
|
56
|
+
* Support for pushing features to Confluence (roundtrip editing)
|
53
57
|
|
54
58
|
== Copyright
|
55
59
|
|
data/Rakefile
CHANGED
@@ -25,22 +25,18 @@ Jeweler::Tasks.new do |gem|
|
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
27
27
|
|
28
|
-
require '
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
test.verbose = true
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
32
|
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
test.pattern = 'test/**/test_*.rb'
|
39
|
-
test.verbose = true
|
40
|
-
test.rcov_opts << '--exclude "gems/*"'
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
41
37
|
end
|
42
38
|
|
43
|
-
task :default => :
|
39
|
+
task :default => :spec
|
44
40
|
|
45
41
|
require 'rake/rdoctask'
|
46
42
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/cuki.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cuki"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andy Waite"]
|
12
|
-
s.date = "2011-10-
|
12
|
+
s.date = "2011-10-16"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "andy@andywaite.com"
|
15
15
|
s.executables = ["cuki"]
|
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
|
+
".rspec",
|
23
|
+
".rvmrc",
|
22
24
|
"Gemfile",
|
23
25
|
"Gemfile.lock",
|
24
26
|
"LICENSE.txt",
|
@@ -28,9 +30,19 @@ Gem::Specification.new do |s|
|
|
28
30
|
"bin/cuki",
|
29
31
|
"cuki.gemspec",
|
30
32
|
"cuki.yaml.sample",
|
33
|
+
"features/pull/pull.feature",
|
34
|
+
"features/pull/pull_single.feature",
|
35
|
+
"features/pull/tables.feature",
|
36
|
+
"features/pull/tags.feature",
|
37
|
+
"features/pull/textile.feature",
|
38
|
+
"features/push/push.feature",
|
39
|
+
"features/push/tables.feature",
|
40
|
+
"features/push/tags.feature",
|
41
|
+
"features/step_defs/pull_steps.rb",
|
42
|
+
"features/support/env.rb",
|
31
43
|
"lib/cuki.rb",
|
32
|
-
"
|
33
|
-
"
|
44
|
+
"spec/cuki_spec.rb",
|
45
|
+
"spec/spec_helper.rb"
|
34
46
|
]
|
35
47
|
s.homepage = "http://github.com/andyw8/cuki"
|
36
48
|
s.licenses = ["MIT"]
|
@@ -48,6 +60,7 @@ Gem::Specification.new do |s|
|
|
48
60
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
61
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
50
62
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
64
|
else
|
52
65
|
s.add_dependency(%q<httpclient>, [">= 0"])
|
53
66
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
@@ -55,6 +68,7 @@ Gem::Specification.new do |s|
|
|
55
68
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
69
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
57
70
|
s.add_dependency(%q<rcov>, [">= 0"])
|
71
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
58
72
|
end
|
59
73
|
else
|
60
74
|
s.add_dependency(%q<httpclient>, [">= 0"])
|
@@ -63,6 +77,7 @@ Gem::Specification.new do |s|
|
|
63
77
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
78
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
65
79
|
s.add_dependency(%q<rcov>, [">= 0"])
|
80
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
66
81
|
end
|
67
82
|
end
|
68
83
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Feature: Pull
|
2
|
+
|
3
|
+
Scenario: Missing action
|
4
|
+
When I run `cuki`
|
5
|
+
Then it should fail with:
|
6
|
+
"""
|
7
|
+
No action given
|
8
|
+
"""
|
9
|
+
|
10
|
+
Scenario: Missing config
|
11
|
+
Given no file named "config/cuki.yaml" exists
|
12
|
+
When I run `cuki pull`
|
13
|
+
Then it should fail with:
|
14
|
+
"""
|
15
|
+
No config file found at config/cuki.yaml
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: Pull all features
|
19
|
+
Given a file named "config/cuki.yaml" with:
|
20
|
+
"""
|
21
|
+
---
|
22
|
+
host: http://example.com
|
23
|
+
mappings:
|
24
|
+
123: products/add_product
|
25
|
+
456: products/remove_product
|
26
|
+
"""
|
27
|
+
And a Confluence page on "example.com" with id 123:
|
28
|
+
"""
|
29
|
+
<input id="content-title" value="Add Product">
|
30
|
+
<div id="markupTextarea">
|
31
|
+
This feature describes adding a product
|
32
|
+
</div>
|
33
|
+
"""
|
34
|
+
And a Confluence page on "example.com" with id 456:
|
35
|
+
"""
|
36
|
+
<input id="content-title" value="Remove Product">
|
37
|
+
<div id="markupTextarea">
|
38
|
+
This feature describes removing a product
|
39
|
+
</div>
|
40
|
+
"""
|
41
|
+
When I run `cuki pull`
|
42
|
+
Then the file "features/products/add_product.feature" should contain exactly:
|
43
|
+
"""
|
44
|
+
Feature: Add Product
|
45
|
+
|
46
|
+
http://example.com/pages/editpage.action?pageId=123
|
47
|
+
|
48
|
+
|
49
|
+
This feature describes adding a product
|
50
|
+
|
51
|
+
"""
|
52
|
+
Then the file "features/products/remove_product.feature" should contain exactly:
|
53
|
+
"""
|
54
|
+
Feature: Remove Product
|
55
|
+
|
56
|
+
http://example.com/pages/editpage.action?pageId=456
|
57
|
+
|
58
|
+
|
59
|
+
This feature describes removing a product
|
60
|
+
|
61
|
+
"""
|
62
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Pull single
|
2
|
+
|
3
|
+
Scenario: Pull all features
|
4
|
+
Given a file named "config/cuki.yaml" with:
|
5
|
+
"""
|
6
|
+
---
|
7
|
+
host: http://example.com
|
8
|
+
mappings:
|
9
|
+
123: products/add_product
|
10
|
+
456: products/remove_product
|
11
|
+
"""
|
12
|
+
And a Confluence page on "example.com" with id 123:
|
13
|
+
"""
|
14
|
+
<input id="content-title" value="Add Product">
|
15
|
+
<div id="markupTextarea">
|
16
|
+
This feature describes adding a product
|
17
|
+
</div>
|
18
|
+
"""
|
19
|
+
And a Confluence page on "example.com" with id 456:
|
20
|
+
"""
|
21
|
+
<input id="content-title" value="Remove Product">
|
22
|
+
<div id="markupTextarea">
|
23
|
+
This feature describes removing a product
|
24
|
+
</div>
|
25
|
+
"""
|
26
|
+
When I run `cuki pull features/products/add_product.feature`
|
27
|
+
Then a file named "features/products/add_product.feature" should exist
|
28
|
+
But the file "features/products/remove_product.feature" should not exist
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Assume no header for single column tables?
|
2
|
+
Feature: Tables
|
3
|
+
|
4
|
+
Scenario: Table with more than one column
|
5
|
+
|
6
|
+
Given a file named "config/cuki.yaml" with:
|
7
|
+
"""
|
8
|
+
---
|
9
|
+
host: http://example.com
|
10
|
+
mappings:
|
11
|
+
123: products/add_product
|
12
|
+
"""
|
13
|
+
And a Confluence page on "example.com" with id 123:
|
14
|
+
"""
|
15
|
+
<input id="content-title" value="Add Product">
|
16
|
+
<div id="markupTextarea">
|
17
|
+
h5. Scenario: Foo
|
18
|
+
|
19
|
+
Given this:
|
20
|
+
|| foo || bar ||
|
21
|
+
| a | 1 |
|
22
|
+
| b | 2 |
|
23
|
+
</div>
|
24
|
+
"""
|
25
|
+
When I run `cuki pull`
|
26
|
+
Then the file "features/products/add_product.feature" should contain exactly:
|
27
|
+
"""
|
28
|
+
Feature: Add Product
|
29
|
+
|
30
|
+
http://example.com/pages/editpage.action?pageId=123
|
31
|
+
|
32
|
+
|
33
|
+
Scenario: Foo
|
34
|
+
|
35
|
+
Given this:
|
36
|
+
| foo | bar |
|
37
|
+
| a | 1 |
|
38
|
+
| b | 2 |
|
39
|
+
|
40
|
+
"""
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: Tags
|
2
|
+
|
3
|
+
Scenario:
|
4
|
+
Given a file named "config/cuki.yaml" with:
|
5
|
+
"""
|
6
|
+
---
|
7
|
+
host: http://example.com
|
8
|
+
tags:
|
9
|
+
draft: "{info:title=Draft version}"
|
10
|
+
signed_off: "{info:title=Signed-off}"
|
11
|
+
mappings:
|
12
|
+
123: products/add_product
|
13
|
+
"""
|
14
|
+
And a Confluence page on "example.com" with id 123:
|
15
|
+
"""
|
16
|
+
<input id="content-title" value="Add Product">
|
17
|
+
<div id="markupTextarea">{info:title=Draft version}
|
18
|
+
h5. Scenario: Foo
|
19
|
+
</div>
|
20
|
+
"""
|
21
|
+
When I run `cuki pull`
|
22
|
+
Then the file "features/products/add_product.feature" should contain exactly:
|
23
|
+
"""
|
24
|
+
@draft
|
25
|
+
Feature: Add Product
|
26
|
+
|
27
|
+
http://example.com/pages/editpage.action?pageId=123
|
28
|
+
|
29
|
+
|
30
|
+
Scenario: Foo
|
31
|
+
|
32
|
+
"""
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: Textile
|
2
|
+
|
3
|
+
Scenario:
|
4
|
+
Given a file named "config/cuki.yaml" with:
|
5
|
+
"""
|
6
|
+
---
|
7
|
+
host: http://example.com
|
8
|
+
mappings:
|
9
|
+
123: products/add_product
|
10
|
+
"""
|
11
|
+
And a Confluence page on "example.com" with id 123:
|
12
|
+
"""
|
13
|
+
<input id="content-title" value="Add Product">
|
14
|
+
<div id="markupTextarea">
|
15
|
+
h5. Scenario: Foo
|
16
|
+
|
17
|
+
h6. Scenario Outline: Bar
|
18
|
+
</div>
|
19
|
+
"""
|
20
|
+
When I run `cuki pull`
|
21
|
+
Then the file "features/products/add_product.feature" should contain exactly:
|
22
|
+
"""
|
23
|
+
Feature: Add Product
|
24
|
+
|
25
|
+
http://example.com/pages/editpage.action?pageId=123
|
26
|
+
|
27
|
+
|
28
|
+
Scenario: Foo
|
29
|
+
|
30
|
+
Scenario Outline: Bar
|
31
|
+
|
32
|
+
"""
|
@@ -0,0 +1,79 @@
|
|
1
|
+
@pending
|
2
|
+
Feature: Push
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given a file named "config/cuki.yaml" with:
|
6
|
+
"""
|
7
|
+
---
|
8
|
+
host: http://mywiki
|
9
|
+
mappings:
|
10
|
+
123: products/add_product
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: Push a feature with no scenarios
|
14
|
+
Given a file named "config/cuki.yaml" with:
|
15
|
+
"""
|
16
|
+
Feature: Hello world & all
|
17
|
+
|
18
|
+
This is my feature
|
19
|
+
"""
|
20
|
+
When I run `cuki push features/products/add_product.feature`
|
21
|
+
Then the feature should be pushed to "http://mywiki/pages/editpage.action?pageId=123"
|
22
|
+
And the Confluence content should be:
|
23
|
+
"""
|
24
|
+
This is my feature
|
25
|
+
"""
|
26
|
+
And the Confluence title should be:
|
27
|
+
"""
|
28
|
+
Hello world & all
|
29
|
+
"""
|
30
|
+
|
31
|
+
Scenario: Push a feature containing a scenario
|
32
|
+
Given a file named "config/cuki.yaml" with:
|
33
|
+
"""
|
34
|
+
Scenario: My scenario
|
35
|
+
Given something
|
36
|
+
When something
|
37
|
+
Then something
|
38
|
+
"""
|
39
|
+
When I push that feature
|
40
|
+
Then the Confluence content should include:
|
41
|
+
"""
|
42
|
+
h2. My scenario
|
43
|
+
|
44
|
+
Given something
|
45
|
+
When something
|
46
|
+
Then something
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: Push a feature containing a scenario outline
|
50
|
+
|
51
|
+
The first row of the examples table should be a header row.
|
52
|
+
Given a feature file in "features/hello_world.feature"
|
53
|
+
And that feature includes the scenario:
|
54
|
+
"""
|
55
|
+
Scenario: My scenario
|
56
|
+
Given <condition>
|
57
|
+
When <action>
|
58
|
+
Then <outcome>
|
59
|
+
Examples:
|
60
|
+
| condition | action | outcome |
|
61
|
+
| a | b | c |
|
62
|
+
"""
|
63
|
+
When I push that feature
|
64
|
+
Then the Confluence content should include:
|
65
|
+
"""
|
66
|
+
h2. My scenario
|
67
|
+
|
68
|
+
Given <condition>
|
69
|
+
When <action>
|
70
|
+
Then <outcome>
|
71
|
+
Examples:
|
72
|
+
|| condition || action || outcome ||
|
73
|
+
| a | b | c |
|
74
|
+
|
75
|
+
"""
|
76
|
+
|
77
|
+
Scenario: Push a feature containing a scenario outline with multiple example
|
78
|
+
Pending
|
79
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
@pending
|
2
|
+
Feature: Tags
|
3
|
+
|
4
|
+
Tags on a feature or scenario should be turned into {info} macros.
|
5
|
+
|
6
|
+
Scenario: Tagged feature
|
7
|
+
|
8
|
+
Tag names should be titleised, with underscores converted to spaces.
|
9
|
+
Given the feature:
|
10
|
+
"""
|
11
|
+
@pending @in_progress @some-other
|
12
|
+
Feature: Hello world
|
13
|
+
|
14
|
+
Here is the feature
|
15
|
+
"""
|
16
|
+
When I push that feature to Confluence
|
17
|
+
Then the Confluence content should be:
|
18
|
+
"""
|
19
|
+
{info:Pending}
|
20
|
+
{info:In Progress}
|
21
|
+
{info:Some-other}
|
22
|
+
|
23
|
+
Here is a feature
|
24
|
+
"""
|
25
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Given /^a Confluence page on "([^"]*)" with id (\d+):$/ do |host, id, content|
|
2
|
+
|
3
|
+
# Since the command-line app runs in a difference process, we need serialize
|
4
|
+
# the URLs to be stubbed
|
5
|
+
|
6
|
+
@stubs ||= {}
|
7
|
+
@stubs["http://#{host}/pages/editpage.action?pageId=#{id}"] = content
|
8
|
+
|
9
|
+
File.open('stubs.json', 'w') do |f|
|
10
|
+
f.write @stubs.to_json
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
Given /^no file named "([^"]*)" exists$/ do |file|
|
16
|
+
File.delete(file) if File.exist?(file)
|
17
|
+
end
|
data/lib/cuki.rb
CHANGED
@@ -3,6 +3,16 @@ require 'httpclient'
|
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'yaml'
|
5
5
|
require 'CGI'
|
6
|
+
require 'webmock'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
include WebMock::API
|
10
|
+
if File.exist?('stubs.json')
|
11
|
+
stubs = JSON.parse(File.open('stubs.json').read)
|
12
|
+
stubs.each_pair do |url, body|
|
13
|
+
stub_request(:get, url).to_return(:status => 200, :body => body, :headers => {})
|
14
|
+
end
|
15
|
+
end
|
6
16
|
|
7
17
|
class Cuki
|
8
18
|
|
@@ -13,21 +23,35 @@ class Cuki
|
|
13
23
|
end
|
14
24
|
|
15
25
|
def initialize(args)
|
16
|
-
|
26
|
+
if args.empty?
|
27
|
+
puts "No action given"
|
28
|
+
exit(1)
|
29
|
+
end
|
17
30
|
parse_config_file
|
18
|
-
|
19
|
-
if 'pull' ==
|
31
|
+
action = args.first
|
32
|
+
if 'pull' == action
|
20
33
|
verify_project
|
21
34
|
configure_http_client
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
file = args[1]
|
36
|
+
if file
|
37
|
+
puts "got file: #{file}"
|
38
|
+
key = file.gsub('features/', '').gsub('.feature', '')
|
39
|
+
puts "key: #{key}"
|
40
|
+
id = @config['mappings'].invert[key]
|
41
|
+
filepath = key
|
42
|
+
process_feature id, filepath
|
43
|
+
else
|
44
|
+
@config['mappings'].each { |id, filepath| process_feature id, filepath }
|
45
|
+
end
|
46
|
+
#autoformat
|
47
|
+
elsif 'push' == action
|
25
48
|
feature_to_be_pushed = args[1] # e.g. features/products/add_product.feature
|
26
49
|
feature_as_in_yaml = feature_to_be_pushed.gsub('features/', '').gsub('.feature', '')
|
27
50
|
id = @config['mappings'].invert[feature_as_in_yaml]
|
28
51
|
raise "No mapping found for #{feature_as_in_yaml}" unless id
|
29
52
|
else
|
30
|
-
|
53
|
+
puts "Unknown action '#{action}"
|
54
|
+
exit(1)
|
31
55
|
end
|
32
56
|
end
|
33
57
|
|
@@ -36,10 +60,14 @@ class Cuki
|
|
36
60
|
def verify_project
|
37
61
|
# check features folder exists
|
38
62
|
raise "features folder not found" unless File.exists?('features')
|
39
|
-
autoformat
|
63
|
+
#autoformat
|
40
64
|
end
|
41
65
|
|
42
66
|
def parse_config_file
|
67
|
+
unless File.exist?(CONFIG_PATH)
|
68
|
+
puts "No config file found at #{CONFIG_PATH}"
|
69
|
+
exit(1)
|
70
|
+
end
|
43
71
|
@config = YAML::load( File.open( CONFIG_PATH ) )
|
44
72
|
raise "Host not found in #{CONFIG_PATH}" unless @config["host"]
|
45
73
|
raise "Mappings not found in #{CONFIG_PATH}" unless @config["mappings"]
|
@@ -58,13 +86,20 @@ class Cuki
|
|
58
86
|
response = @client.get wiki_link
|
59
87
|
doc = Nokogiri(response.body)
|
60
88
|
|
61
|
-
|
89
|
+
unless doc.at('#content-title')
|
90
|
+
puts "Not a valid confluence page:"
|
91
|
+
puts doc.to_s
|
92
|
+
exit(1)
|
93
|
+
end
|
62
94
|
|
63
95
|
@content += "Feature: " + doc.at('#content-title')[:value] + "\n\n"
|
64
96
|
@content += "#{wiki_link}\n\n"
|
65
97
|
@content += CGI.unescapeHTML(doc.css('#markupTextarea').text)
|
66
98
|
|
67
99
|
clean
|
100
|
+
|
101
|
+
process_tags
|
102
|
+
|
68
103
|
save_file filepath
|
69
104
|
end
|
70
105
|
|
@@ -85,20 +120,24 @@ class Cuki
|
|
85
120
|
@content.gsub!('\\', '')
|
86
121
|
|
87
122
|
# remove any unwanted headers
|
88
|
-
@content.gsub!(/h\d\. /, '')
|
123
|
+
@content.gsub!(/h\d\. (Scenario: .*)/, '\1')
|
124
|
+
@content.gsub!(/h\d\. (Scenario Outline: .*)/, '\1')
|
89
125
|
|
90
|
-
# remove any other confluence markup
|
91
|
-
@content.gsub!(/\{.*\}/, '')
|
92
126
|
end
|
93
127
|
|
94
128
|
def process_tags
|
95
129
|
tags = []
|
96
130
|
if @config['tags']
|
97
|
-
@config['tags'].
|
98
|
-
tags << "@#{tag}"
|
131
|
+
@config['tags'].each_pair do |tag, snippet|
|
132
|
+
tags << "@#{tag}" if @content.include?(snippet)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
unless tags.empty?
|
136
|
+
@content = tags.join(' ') + "\n" + @content
|
137
|
+
tags.each do |tag|
|
138
|
+
@content.gsub!(@config['tags'][tag.gsub('@', '')], '')
|
99
139
|
end
|
100
140
|
end
|
101
|
-
@content += tags.join(' ') + "\n" unless tags.empty?
|
102
141
|
end
|
103
142
|
|
104
143
|
def save_file(filepath)
|
data/spec/cuki_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'cuki'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Waite
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
@@ -105,6 +105,20 @@ dependencies:
|
|
105
105
|
name: rcov
|
106
106
|
prerelease: false
|
107
107
|
type: :development
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
version_requirements: *id007
|
119
|
+
name: rspec
|
120
|
+
prerelease: false
|
121
|
+
type: :development
|
108
122
|
description: ""
|
109
123
|
email: andy@andywaite.com
|
110
124
|
executables:
|
@@ -116,6 +130,8 @@ extra_rdoc_files:
|
|
116
130
|
- README.rdoc
|
117
131
|
files:
|
118
132
|
- .document
|
133
|
+
- .rspec
|
134
|
+
- .rvmrc
|
119
135
|
- Gemfile
|
120
136
|
- Gemfile.lock
|
121
137
|
- LICENSE.txt
|
@@ -125,9 +141,19 @@ files:
|
|
125
141
|
- bin/cuki
|
126
142
|
- cuki.gemspec
|
127
143
|
- cuki.yaml.sample
|
144
|
+
- features/pull/pull.feature
|
145
|
+
- features/pull/pull_single.feature
|
146
|
+
- features/pull/tables.feature
|
147
|
+
- features/pull/tags.feature
|
148
|
+
- features/pull/textile.feature
|
149
|
+
- features/push/push.feature
|
150
|
+
- features/push/tables.feature
|
151
|
+
- features/push/tags.feature
|
152
|
+
- features/step_defs/pull_steps.rb
|
153
|
+
- features/support/env.rb
|
128
154
|
- lib/cuki.rb
|
129
|
-
-
|
130
|
-
-
|
155
|
+
- spec/cuki_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
131
157
|
homepage: http://github.com/andyw8/cuki
|
132
158
|
licenses:
|
133
159
|
- MIT
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'cuki'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|