cuki 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/Gemfile.lock +22 -0
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/bin/cuki +1 -1
- data/cuki.gemspec +2 -2
- data/cuki.yaml.sample +2 -1
- data/lib/cuki.rb +76 -78
- metadata +4 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,46 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
builder (3.0.0)
|
5
|
+
cucumber (1.1.0)
|
6
|
+
builder (>= 2.1.2)
|
7
|
+
diff-lcs (>= 1.1.2)
|
8
|
+
gherkin (~> 2.5.0)
|
9
|
+
json (>= 1.4.6)
|
10
|
+
term-ansicolor (>= 1.0.6)
|
11
|
+
diff-lcs (1.1.3)
|
12
|
+
gherkin (2.5.1)
|
13
|
+
json (>= 1.4.6)
|
4
14
|
git (1.2.5)
|
5
15
|
httpclient (2.2.1)
|
6
16
|
jeweler (1.6.4)
|
7
17
|
bundler (~> 1.0)
|
8
18
|
git (>= 1.2.5)
|
9
19
|
rake
|
20
|
+
json (1.6.1)
|
10
21
|
nokogiri (1.5.0)
|
11
22
|
rake (0.9.2)
|
12
23
|
rcov (0.9.11)
|
24
|
+
rspec (2.6.0)
|
25
|
+
rspec-core (~> 2.6.0)
|
26
|
+
rspec-expectations (~> 2.6.0)
|
27
|
+
rspec-mocks (~> 2.6.0)
|
28
|
+
rspec-core (2.6.4)
|
29
|
+
rspec-expectations (2.6.0)
|
30
|
+
diff-lcs (~> 1.1.2)
|
31
|
+
rspec-mocks (2.6.0)
|
13
32
|
shoulda (2.11.3)
|
33
|
+
term-ansicolor (1.0.6)
|
14
34
|
|
15
35
|
PLATFORMS
|
16
36
|
ruby
|
17
37
|
|
18
38
|
DEPENDENCIES
|
19
39
|
bundler (~> 1.0.0)
|
40
|
+
cucumber
|
20
41
|
httpclient
|
21
42
|
jeweler (~> 1.6.4)
|
22
43
|
nokogiri
|
23
44
|
rcov
|
45
|
+
rspec
|
24
46
|
shoulda
|
data/README.rdoc
CHANGED
@@ -27,11 +27,11 @@ Cuki expects a configuration file in config/cuki.yml. See the sample provided.
|
|
27
27
|
|
28
28
|
Run it from the command line:
|
29
29
|
|
30
|
-
bundle exec cuki
|
30
|
+
bundle exec cuki pull
|
31
31
|
|
32
|
-
or, if using
|
32
|
+
or, if using binstubs:
|
33
33
|
|
34
|
-
bin/cuki
|
34
|
+
bin/cuki pull
|
35
35
|
|
36
36
|
== Options
|
37
37
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/bin/cuki
CHANGED
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.4"
|
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-15"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "andy@andywaite.com"
|
15
15
|
s.executables = ["cuki"]
|
data/cuki.yaml.sample
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
# the mappings associate the page IDs on Confluence with local feature files
|
3
3
|
# the .feature extension is added automatically
|
4
4
|
---
|
5
|
-
|
5
|
+
host: http://mywiki
|
6
6
|
tags:
|
7
7
|
draft: "{info:title=Draft version}"
|
8
|
+
signed_off: "{info:title=Signed-off}"
|
8
9
|
mappings:
|
9
10
|
123: products/add_product
|
10
11
|
124: products/remove_product
|
data/lib/cuki.rb
CHANGED
@@ -6,35 +6,43 @@ require 'CGI'
|
|
6
6
|
|
7
7
|
class Cuki
|
8
8
|
|
9
|
-
|
10
|
-
START_INDICATOR = /\d\. \*Specification\*/
|
9
|
+
CONFIG_PATH = 'config/cuki.yaml'
|
11
10
|
|
12
|
-
def self.invoke
|
13
|
-
new
|
11
|
+
def self.invoke(args)
|
12
|
+
new(args)
|
14
13
|
end
|
15
14
|
|
16
|
-
def initialize
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
def initialize(args)
|
16
|
+
raise "No command given" if args.empty?
|
17
|
+
parse_config_file
|
18
|
+
command = args.first
|
19
|
+
if 'pull' == command
|
20
|
+
verify_project
|
21
|
+
configure_http_client
|
22
|
+
@config['mappings'].each { |id, filepath| process_feature id, filepath }
|
23
|
+
autoformat
|
24
|
+
elsif 'push' == command
|
25
|
+
feature_to_be_pushed = args[1] # e.g. features/products/add_product.feature
|
26
|
+
feature_as_in_yaml = feature_to_be_pushed.gsub('features/', '').gsub('.feature', '')
|
27
|
+
id = @config['mappings'].invert[feature_as_in_yaml]
|
28
|
+
raise "No mapping found for #{feature_as_in_yaml}" unless id
|
29
|
+
else
|
30
|
+
raise "Unknown command '#{command}"
|
31
|
+
end
|
22
32
|
end
|
23
33
|
|
24
34
|
private
|
25
35
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
raise "
|
36
|
-
|
37
|
-
@tag_mappings = config['tags']
|
36
|
+
def verify_project
|
37
|
+
# check features folder exists
|
38
|
+
raise "features folder not found" unless File.exists?('features')
|
39
|
+
autoformat
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_config_file
|
43
|
+
@config = YAML::load( File.open( CONFIG_PATH ) )
|
44
|
+
raise "Host not found in #{CONFIG_PATH}" unless @config["host"]
|
45
|
+
raise "Mappings not found in #{CONFIG_PATH}" unless @config["mappings"]
|
38
46
|
end
|
39
47
|
|
40
48
|
def configure_http_client
|
@@ -43,76 +51,66 @@ class Cuki
|
|
43
51
|
@client.ssl_config.set_client_cert_file(ENV['PEM'], ENV['PEM']) if ENV['PEM']
|
44
52
|
end
|
45
53
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
54
|
+
def process_feature(id, filepath)
|
55
|
+
@content = ''
|
56
|
+
wiki_link = @config['host'] + '/pages/editpage.action?pageId=' + id.to_s
|
49
57
|
puts "Downloading #{wiki_link}"
|
50
|
-
|
51
58
|
response = @client.get wiki_link
|
52
|
-
|
53
59
|
doc = Nokogiri(response.body)
|
60
|
+
|
61
|
+
process_tags
|
54
62
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
wiki_text.gsub(' ', '')
|
59
|
-
|
60
|
-
cuke_text = ''
|
61
|
-
|
62
|
-
tags = []
|
63
|
-
if @tag_mappings
|
64
|
-
@tag_mappings.each do |tag, snippet|
|
65
|
-
tags << "@#{tag}" if wiki_text.include?(snippet)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
cuke_text += tags.join(' ') + "\n" unless [] == tags
|
70
|
-
|
71
|
-
title = title.split(' - ').first
|
72
|
-
|
73
|
-
# assuming that title is format REF - TITLE - PROJECT NAME - WIKI NAME
|
74
|
-
cuke_text += "Feature: " + title + "\n\n"
|
75
|
-
|
76
|
-
cuke_text += "#{wiki_link}\n\n"
|
77
|
-
|
78
|
-
if wiki_text.match(START_INDICATOR)
|
79
|
-
cuke_text += wiki_text.split(START_INDICATOR).last
|
80
|
-
else
|
81
|
-
cuke_text += wiki_text.split(START_INDICATOR).last
|
82
|
-
end
|
63
|
+
@content += "Feature: " + doc.at('#content-title')[:value] + "\n\n"
|
64
|
+
@content += "#{wiki_link}\n\n"
|
65
|
+
@content += CGI.unescapeHTML(doc.css('#markupTextarea').text)
|
83
66
|
|
67
|
+
clean
|
68
|
+
save_file filepath
|
69
|
+
end
|
70
|
+
|
71
|
+
def autoformat
|
72
|
+
`cucumber -a . --dry-run -P` unless ENV['SKIP_AUTOFORMAT']
|
73
|
+
end
|
74
|
+
|
75
|
+
def clean
|
76
|
+
|
77
|
+
@content.gsub(' ', '')
|
78
|
+
|
84
79
|
# remove the double pipes used for table headers in Confluence
|
85
|
-
|
80
|
+
@content.gsub!('||', '|')
|
86
81
|
|
87
82
|
# remove other noise
|
88
|
-
|
89
|
-
|
90
|
-
|
83
|
+
@content.gsub!("\r\n", "\n")
|
84
|
+
@content.gsub!("\\\\\n", '')
|
85
|
+
@content.gsub!('\\', '')
|
91
86
|
|
92
87
|
# remove any unwanted headers
|
93
|
-
|
94
|
-
|
95
|
-
# remove an other confluence markup
|
96
|
-
cuke_text.gsub!(/\{.*\}/, '')
|
97
|
-
|
98
|
-
# check features folder exists
|
99
|
-
raise "features folder not found" unless File.exists?('features')
|
100
|
-
|
101
|
-
file_path = "features/#{value}.feature"
|
102
|
-
dir_path = File.dirname(file_path)
|
103
|
-
|
104
|
-
unless File.exists?(dir_path)
|
105
|
-
Dir.mkdir(dir_path)
|
106
|
-
end
|
88
|
+
@content.gsub!(/h\d\. /, '')
|
107
89
|
|
108
|
-
|
109
|
-
|
110
|
-
|
90
|
+
# remove any other confluence markup
|
91
|
+
@content.gsub!(/\{.*\}/, '')
|
92
|
+
end
|
93
|
+
|
94
|
+
def process_tags
|
95
|
+
tags = []
|
96
|
+
if @config['tags']
|
97
|
+
@config['tags'].each do |tag, snippet|
|
98
|
+
tags << "@#{tag}" if @content.include?(snippet)
|
99
|
+
end
|
111
100
|
end
|
101
|
+
@content += tags.join(' ') + "\n" unless tags.empty?
|
112
102
|
end
|
113
103
|
|
114
|
-
def
|
115
|
-
|
104
|
+
def save_file(filepath)
|
105
|
+
full_filepath = "features/#{filepath}.feature"
|
106
|
+
dir_path = File.dirname(full_filepath)
|
107
|
+
|
108
|
+
Dir.mkdir(dir_path) unless File.exists?(dir_path)
|
109
|
+
|
110
|
+
File.open(full_filepath, 'w') do |f|
|
111
|
+
puts "Writing #{full_filepath}"
|
112
|
+
f.puts @content
|
113
|
+
end
|
116
114
|
end
|
117
115
|
|
118
116
|
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
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-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|