kappamaki 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 960f9aaf3f5c2e884699282e0cda5b44b4026b0f
4
+ data.tar.gz: c35b41b43bf956587aba8e0099a064083c925db5
5
+ SHA512:
6
+ metadata.gz: 5344d48ba377716604389d71312859a8a7391fc82989aa85f658a60edc960874199bf09e645b78f9424f668e92af3c05396368714feceb75192b13b51e43b6b6
7
+ data.tar.gz: 23dcd71028f962236686ee2042ee5cbeb4b97f742120654026ba3b7163d24d5bdc563b9cab3e6279766c351cc7868c3b076c052441d344a7006b14202694afe1
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /spec/reports/
7
+ /tmp/
8
+ *.bundle
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm: 2.1.3
4
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kappamaki.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Originate
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.
@@ -0,0 +1,53 @@
1
+ # Kappamaki <a href="https://travis-ci.org/Originate/kappamaki" alt="Build Status" target="_blank"><img src="https://travis-ci.org/Originate/kappamaki.svg?branch=master"></a>
2
+
3
+ _Tools for natural, high-level, sophisticated Cucumber steps._
4
+
5
+ The name comes from the sushi roll filled with pieces of cucumber,
6
+ which adds naturalness and freshness to a meal.
7
+
8
+
9
+ ## Usage
10
+
11
+ Kappamaki provides a number of helper methods that can be used directly
12
+ in your Cucumber step definitions.
13
+ It allows for Cucumber steps that look like this:
14
+
15
+ ```cucumber
16
+ Given I have a dinner with starter: "miso soup" and entree: "sushi"
17
+ ```
18
+
19
+ Your step definition would look like this:
20
+
21
+ ```ruby
22
+ Given /^I have a dinner with (.+)$/ do |dinner_attributes|
23
+
24
+ # dinner_attributes is this string:
25
+ 'starter: "miso soup" and entree: "sushi"'
26
+
27
+ # Let's parse that string using Kappamaki
28
+ dinner_data = Kappamaki.attributes_from_sentence(dinner_attributes)
29
+
30
+ # The result, dinner_data, is this hash:
31
+ { starter: "miso soup",
32
+ entree: "sushi" }
33
+
34
+ # now we can set up our system using this data
35
+ create :dinner, dinner_data
36
+ end
37
+ ```
38
+
39
+
40
+ ## Installation
41
+
42
+ * add `gem 'kappamaki'` to your application's Gemfile
43
+ * run `bundle install`
44
+ * add `require 'kappamaki'` to your `/features/support/env.rb` file
45
+
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/Originate/kappamaki/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create a new Pull Request
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'kappamaki'
7
+ spec.version = '0.0.2'
8
+ spec.authors = ['Kevin Goslar']
9
+ spec.email = ['kevin.goslar@originate.com']
10
+ spec.summary = 'Tools for natural, high-level, sophisticated Cucumber steps'
11
+ spec.homepage = 'https://github.com/Originate/kappamaki'
12
+ spec.license = 'MIT'
13
+ spec.description = <<-EOF
14
+ Kappamaki is a collection of string manipulation methods
15
+ that make parsing high-lever cucumber steps easier.
16
+ EOF
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = []
20
+ spec.test_files = spec.files.grep('spec')
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 0'
24
+ spec.add_development_dependency 'rake', '~> 0'
25
+ spec.add_development_dependency 'rspec', '~> 0'
26
+
27
+ spec.required_ruby_version = '>= 1.9.3'
28
+ end
@@ -0,0 +1,24 @@
1
+ module Kappamaki
2
+
3
+ # Parses a given string containing key-value pairs into a Hash
4
+ #
5
+ # Values must be delimited by double-quotes, like this:
6
+ # key: "value"
7
+ def self.attributes_from_sentence sentence
8
+ attributes = Kappamaki.from_sentence(sentence)
9
+ .map{|piece| piece.split ': '}
10
+ .map{|key, value| [key.to_sym, value]}
11
+ .flatten
12
+ Hash[*attributes]
13
+ end
14
+
15
+
16
+ # Reverse of Rails' to_sentence method
17
+ def self.from_sentence sentence
18
+ sentence.gsub(', and ', ', ')
19
+ .gsub(' and ', ', ')
20
+ .split(', ')
21
+ .map{|s| s.gsub '"', ''}
22
+ end
23
+
24
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'kappamaki'
3
+
4
+
5
+ describe Kappamaki do
6
+
7
+ test_data = {
8
+
9
+ attributes_from_sentence: {
10
+ 'name: "Foo"' => {name: "Foo"},
11
+ 'name: "Foo" and body: "Bar"' => {name: 'Foo', body: 'Bar'},
12
+ 'name: "Foo", body: "Bar" and title: "Baz"' => {name: 'Foo', body: 'Bar', title: "Baz"},
13
+ 'name: "Foo", body: "Bar", and title: "Baz"' => {name: 'Foo', body: 'Bar', title: "Baz"}
14
+ },
15
+
16
+ from_sentence: {
17
+ 'one' => ['one'],
18
+ '"one"' => ['one'],
19
+ 'one and two' => ['one', 'two'],
20
+ '"one" and "two"' => ['one', 'two'],
21
+ 'one, two and three' => ['one', 'two', 'three'],
22
+ '"one", "two" and "three"' => ['one', 'two', 'three'],
23
+ 'one, two, and three' => ['one', 'two', 'three'],
24
+ 'one, two, three and four' => ['one', 'two', 'three', 'four'],
25
+ '"one", "two", "three" and "four"' => ['one', 'two', 'three', 'four']
26
+ }
27
+ }
28
+
29
+ test_data.each do |method_name, expected|
30
+ describe method_name do
31
+ expected.each do |sentence, expected_result|
32
+ it "parses '#{sentence}' into '#{expected_result}'" do
33
+ expect(Kappamaki.send method_name, sentence).to eql expected_result
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,9 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+ require 'kappamaki'
4
+
5
+ RSpec.configure do |config|
6
+ config.color = true
7
+ config.order = 'random'
8
+ config.formatter = 'documentation'
9
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kappamaki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Goslar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: |2
56
+ Kappamaki is a collection of string manipulation methods
57
+ that make parsing high-lever cucumber steps easier.
58
+ email:
59
+ - kevin.goslar@originate.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - kappamaki.gemspec
70
+ - lib/kappamaki.rb
71
+ - spec/kappamaki_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/Originate/kappamaki
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 1.9.3
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Tools for natural, high-level, sophisticated Cucumber steps
97
+ test_files: []