cuki 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.rdoc +51 -13
  2. data/VERSION +1 -1
  3. data/cuki.gemspec +68 -0
  4. data/cuki.yaml.sample +7 -0
  5. data/lib/cuki.rb +65 -44
  6. metadata +5 -3
data/README.rdoc CHANGED
@@ -1,16 +1,54 @@
1
- = cuki
2
-
3
- Description goes here.
4
-
5
- == Contributing to cuki
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
1
+ = Overview
2
+
3
+ Cuki provides an easy way to import acceptance criteria from a Confluence wiki into Cucumber feature files
4
+
5
+ * Supports a mapping between Confluence pages and feature files
6
+ * Extracts only the acceptance criteria section of a wiki page
7
+ * Converts Confluence tables to Cucumber tables
8
+ * Strips out unncessary Confluence formatting (h1., macros, etc.)
9
+ * Adds a @pending tag if the wiki page is marked as a draft
10
+ * Includes a link back to the original Confluence page
11
+ * Formats the feature using Cucumber's autoformatter (optional)
12
+ * Support client SSL certificates for use within an organisation's secure intranet
13
+
14
+ It can be used as part of a CI process or just for ad-hoc imports.
15
+
16
+ == Installation
17
+
18
+ Require the gem in your Gemfile:
19
+
20
+ gem 'cuki'
21
+
22
+ == Setup
23
+
24
+ Cuki expects a configuration file in config/cuki.yml. See the sample provided.
25
+
26
+ == Usage
27
+
28
+ Run it from the command line:
29
+
30
+ bundle exec cuki
31
+
32
+ or, if using Bundler binstubs:
33
+
34
+ bin/cuki
35
+
36
+ == Options
37
+
38
+ * SKIP_AUTOFORMAT to avoid reformatting features (runs over the whole features directory)
39
+ * PEM=/path/to/something.pem.cer (for client certificates)
40
+ * CER=/path/to/something.pem (for client certificates)
41
+
42
+ == Known Issues and Limitation
43
+
44
+ * Expects the Cucumber scenarios to continue to the the last part of the the page
45
+ * Will only work with Confluence setups which have no password, or use client certificates for authentcation
46
+ * One provides one-way sync, i.e. you can't edit a file locally and push it to Confluence
47
+
48
+ == TODO
49
+
50
+ * Handle links
51
+ * Add tests
14
52
 
15
53
  == Copyright
16
54
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/cuki.gemspec ADDED
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "cuki"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andy Waite"]
12
+ s.date = "2011-10-12"
13
+ s.description = ""
14
+ s.email = "andy@andywaite.com"
15
+ s.executables = ["cuki"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/cuki",
29
+ "cuki.gemspec",
30
+ "cuki.yaml.sample",
31
+ "lib/cuki.rb",
32
+ "test/helper.rb",
33
+ "test/test_cuki.rb"
34
+ ]
35
+ s.homepage = "http://github.com/andyw8/cuki"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "1.8.10"
39
+ s.summary = "Pull acceptance criteria from a Confluence wiki page into a Cucumber feature file"
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<httpclient>, [">= 0"])
46
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
47
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<httpclient>, [">= 0"])
53
+ s.add_dependency(%q<nokogiri>, [">= 0"])
54
+ s.add_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
57
+ s.add_dependency(%q<rcov>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<httpclient>, [">= 0"])
61
+ s.add_dependency(%q<nokogiri>, [">= 0"])
62
+ s.add_dependency(%q<shoulda>, [">= 0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ end
67
+ end
68
+
data/cuki.yaml.sample ADDED
@@ -0,0 +1,7 @@
1
+ # edit this and save it as config/cuki.yaml
2
+ ---
3
+ base: http://mywiki/pages/editpage.action?pageId=
4
+ draft: "{info:title=Draft version}"
5
+ mappings:
6
+ 123: products/add_product
7
+ 124: products/remove_product
data/lib/cuki.rb CHANGED
@@ -7,78 +7,99 @@ require 'CGI'
7
7
  class Cuki
8
8
 
9
9
  # we're assuming that the acceptance criteria starts at this point and continues to the end of the page
10
- FEATURE_START = /\d\. \*Specification\*/
10
+ START_INDICATOR = /\d\. \*Specification\*/
11
11
 
12
12
  def self.invoke
13
+ new
14
+ end
13
15
 
16
+ def initialize
17
+ read_config
18
+ configure_http_client
19
+ @mappings.each { |key, value| process_mapping key, value }
20
+ autoformat
21
+ end
22
+
23
+ private
24
+
25
+ def read_config
14
26
  config_path = 'config/cuki.yaml'
15
27
 
16
28
  config = YAML::load( File.open( config_path ) )
17
29
 
18
- base = config["base"]
19
- raise "base not found in #{config_path}" unless base
20
-
21
- mappings = config["mappings"]
22
- raise "mappings not found in #{config_path}" unless mappings
30
+ @base = config["base"]
31
+ raise "base not found in #{config_path}" unless @base
23
32
 
24
- client = HTTPClient.new
25
- client.ssl_config.set_trust_ca(ENV['CER']) if ENV['CER']
26
- client.ssl_config.set_client_cert_file(ENV['PEM'], ENV['PEM']) if ENV['PEM']
27
-
28
- mappings.each do |key, value|
29
- wiki_link = base + key.to_s
33
+ @mappings = config["mappings"]
34
+ raise "mappings not found in #{config_path}" unless @mappings
35
+
36
+ @draft_indicator = config['draft']
37
+ end
38
+
39
+ def configure_http_client
40
+ @client = HTTPClient.new
41
+ @client.ssl_config.set_trust_ca(ENV['CER']) if ENV['CER']
42
+ @client.ssl_config.set_client_cert_file(ENV['PEM'], ENV['PEM']) if ENV['PEM']
43
+ end
44
+
45
+ def process_mapping(key, value)
46
+ wiki_link = @base + key.to_s
30
47
 
31
- puts "Downloading #{wiki_link}"
48
+ puts "Downloading #{wiki_link}"
32
49
 
33
- response = client.get wiki_link
50
+ response = @client.get wiki_link
34
51
 
35
- doc = Nokogiri(response.body)
52
+ doc = Nokogiri(response.body)
36
53
 
37
- title = doc.css('title').text
54
+ title = doc.css('title').text
38
55
 
39
- wiki_text = CGI.unescapeHTML(doc.css('#markupTextarea').text)
56
+ wiki_text = CGI.unescapeHTML(doc.css('#markupTextarea').text)
57
+ wiki_text.gsub('&nbsp;', '')
40
58
 
41
- cuke_text = ''
42
- cuke_text += "@pending\n" if wiki_text.include?(config['draft'])
59
+ cuke_text = ''
60
+ cuke_text += "@pending\n" if wiki_text.include?(@draft_indicator)
43
61
 
44
- # assuming that title is format REF - TITLE - PROJECT NAME - WIKI NAME
45
- cuke_text += "Feature: " + title.split(' - ')[1] + "\n\n"
62
+ title = title.split(' - ').first
46
63
 
47
- cuke_text += "[View on Confluence](#{wiki_link})\n\n"
64
+ # assuming that title is format REF - TITLE - PROJECT NAME - WIKI NAME
65
+ cuke_text += "Feature: " + title + "\n\n"
48
66
 
49
- cuke_text += wiki_text.split(FEATURE_START).last
67
+ cuke_text += "#{wiki_link}\n\n"
50
68
 
51
- # remove the double pipes used for table headers in Confluence
52
- cuke_text.gsub!('||', '|')
69
+ raise "couldn't find start of acceptance criteria in #{title}" unless wiki_text.match(START_INDICATOR)
53
70
 
54
- # remove other noise
55
- cuke_text.gsub!('\\', '')
71
+ cuke_text += wiki_text.split(START_INDICATOR).last
56
72
 
57
- # remove any unwanted headers
58
- cuke_text.gsub!(/h\d\. /, '')
73
+ # remove the double pipes used for table headers in Confluence
74
+ cuke_text.gsub!('||', '|')
59
75
 
60
- # remove an other confluence markup
61
- cuke_text.gsub!(/\{.*\}/, '')
76
+ # remove other noise
77
+ cuke_text.gsub!('\\', '')
62
78
 
63
- # check features folder exists
64
- raise "features folder not found" unless File.exists?('features')
79
+ # remove any unwanted headers
80
+ cuke_text.gsub!(/h\d\. /, '')
65
81
 
66
- file_path = "features/#{value}.feature"
67
- dir_path = File.dirname(file_path)
82
+ # remove an other confluence markup
83
+ cuke_text.gsub!(/\{.*\}/, '')
68
84
 
69
- unless File.exists?(dir_path)
70
- Dir.mkdir(dir_path)
71
- end
85
+ # check features folder exists
86
+ raise "features folder not found" unless File.exists?('features')
72
87
 
73
- File.open(file_path, 'w') do |f|
74
- puts "Writing #{file_path}"
75
- f.puts cuke_text
76
- end
88
+ file_path = "features/#{value}.feature"
89
+ dir_path = File.dirname(file_path)
77
90
 
91
+ unless File.exists?(dir_path)
92
+ Dir.mkdir(dir_path)
78
93
  end
79
94
 
80
- # clean up with Cucumber's autoformatter
95
+ File.open(file_path, 'w') do |f|
96
+ puts "Writing #{file_path}"
97
+ f.puts cuke_text
98
+ end
99
+ end
100
+
101
+ def autoformat
81
102
  `cucumber -a . --dry-run -P` unless ENV['SKIP_AUTOFORMAT']
82
-
83
103
  end
104
+
84
105
  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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Waite
@@ -123,6 +123,8 @@ files:
123
123
  - Rakefile
124
124
  - VERSION
125
125
  - bin/cuki
126
+ - cuki.gemspec
127
+ - cuki.yaml.sample
126
128
  - lib/cuki.rb
127
129
  - test/helper.rb
128
130
  - test/test_cuki.rb