sauerkraut 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 577b6aad66ddd815b81834540abde09e899b3167
4
- data.tar.gz: 00a5e41606697a7992786eb6a7f047601e7943dd
3
+ metadata.gz: 5bb434c28c53b22154ef383692ef708c1a5915bd
4
+ data.tar.gz: 8ebc4213c01eec7929cb2f70595fb2b2bee617b9
5
5
  SHA512:
6
- metadata.gz: 9e120e4d19f8f350da4a56ec414353df6ecaf12bb9f413fb8ad9e33ca54ee9417366de58ea7f58a6e294ae136b22dff28b534e1db088e02b9062ffdc6b285578
7
- data.tar.gz: b830d10985b13924a6e8c453e12bea41daa07f44d1e79d8333204d6cc729dfa296b44aef9acf38a35f12e9d8874c08ae97685e1816178db112aa2aea407d87a5
6
+ metadata.gz: 6deb022974415c9d5248b43769ecc6033ecb8c20cb45fab0429cb7bce6a43f2d17c1268866fe1c5bd219ec2cb7959784f6044612a5436a6e2b28f56be2e5ab66
7
+ data.tar.gz: 334719a454260a19d48ec0e156cb7457c34cd2c05f3626655eca79108efb12822ead62a0e525ae1e42e1288062d392c0a395d47c40889c71e6c55317de26df9a
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
4
+ - "2.1.1"
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ # uncomment this line if your project needs to run something other than `rake`:
7
+ # script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- # Sauerkraut
1
+ # Sauerkraut ![Build Status](https://travis-ci.org/cartoloupe/sauerkraut.svg?branch=master)
2
+
3
+ Gathers all cucumber step definition source code in one place, in order to refactor cucumber steps.
2
4
 
3
- TODO: Write a gem description
4
5
 
5
6
  ## Installation
6
7
 
@@ -20,7 +21,19 @@ Or install it yourself as:
20
21
 
21
22
  ## Usage
22
23
 
23
- TODO: Write usage instructions here
24
+ On the command line:
25
+ `sauerkraut FEATURE_FILE:N[:M] [-o FILE]`
26
+
27
+ `:N` will gather source code from scenario found at `:N`
28
+
29
+ `:N:M` will gather source code from the range `N-M` of the feature file
30
+
31
+ `-o FILE` will output to a file instead of the terminal
32
+
33
+
34
+ ## Warnings
35
+ When `FEATURE_FILE:N` is a Scenario Outline, it probably won't work yet.
36
+
24
37
 
25
38
  ## Contributing
26
39
 
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/bin/sauerkraut CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
2
3
  require 'sauerkraut'
3
- Sauerkraut.run
4
+ Sauerkraut.run ARGV
@@ -0,0 +1,110 @@
1
+ Given(/^a glass jar$/) do
2
+ @glass_jar = []
3
+ end
4
+
5
+ Given(/^a (\w+) stone$/) do |stone_weight|
6
+ @stone = {:thing => :stone, :weight => stone_weight}
7
+ end
8
+
9
+ Given(/^salt$/) do
10
+ @salt = true
11
+ end
12
+
13
+ Given(/^(?:some )?vegetables$/) do
14
+ @vegetables = ["cabbage","carrot","onion"]
15
+ end
16
+
17
+ Given(/^a sharp knife$/) do
18
+ @knife = true
19
+ end
20
+
21
+ When(/^start chopping the vegetables$/) do
22
+ @vegetables.each do |v|
23
+ v.chop
24
+ end
25
+ end
26
+
27
+ Then(/^there should be ([\w]+) slices of vegetables$/) do |vegetable_size|
28
+ @vegetables.each do |v|
29
+ expect(v.length).to be >= vegetable_size.length
30
+ end
31
+ end
32
+
33
+ Given(/^([\w]+) slices of vegetables$/) do |vegetable_size|
34
+ @vegetable_slice_size = vegetable_size.to_sym
35
+ end
36
+
37
+ Given(/^a(nother)? layer of vegetables is placed in the jar$/) do |repeat|
38
+ @jar ||= []
39
+ put_vegetables_in_jar
40
+ end
41
+
42
+ Given(/^some more vegetables are placed into the jar$/) do
43
+ put_vegetables_in_jar
44
+ end
45
+
46
+ def put_vegetables_in_jar
47
+ @jar << {:layer_of_vegetables => true}
48
+ end
49
+
50
+ Given(/^then (more )?salt is added$/) do |more|
51
+ @salt = 1
52
+ @salt += 1 if more
53
+ end
54
+
55
+ Given(/^some garlic is chopped up$/) do
56
+ @garlic ||= :some
57
+ @garlic.to_s.chop
58
+ end
59
+
60
+ Given(/^garlic is layered into the jar$/) do
61
+ @jar << {:garlic => true}
62
+ end
63
+
64
+ When(/^the jar is nearly full$/) do
65
+ @jar << {:nearly_full => true}
66
+ end
67
+
68
+ Then(/^a stone should be put on top$/) do
69
+ @jar << {:stone => true}
70
+ end
71
+
72
+ Given(/^a jar full of salted vegetables$/) do
73
+ @jar
74
+ end
75
+
76
+ When(/^a heavy stone is placed on top$/) do
77
+ @jar ||= []
78
+ @jar << {:stone => true, :weight => "heavy"}
79
+ end
80
+
81
+ When(/^eventually the salt draws water out of the vegetables$/) do
82
+ sleep 1
83
+ end
84
+
85
+ Then(/^eventually the water level will be above the vegetables$/) do
86
+ sleep 1
87
+ end
88
+
89
+ Then(/^the vegetables should not be exposed to the air$/) do
90
+ @jar_water_level = 10
91
+ @jar_vegetable_level = 9
92
+ expect(@jar_water_level < @jar_vegetable_level)
93
+ end
94
+
95
+ Given(/^a jar full of salted weighed down vegetables$/) do
96
+ @jar
97
+ end
98
+
99
+ When(/^the jar is left in a cool place between (\d+) and (\d+) degrees F$/) do |arg1, arg2|
100
+ @low_temp = arg1.to_i
101
+ @high_temp = arg2.to_i
102
+ end
103
+
104
+ Given(/^about two to four weeks time$/) do
105
+ sleep 2
106
+ end
107
+
108
+ Then(/^the vegetables should ferment$/) do
109
+ @ready = true
110
+ end
@@ -0,0 +1,39 @@
1
+ @test
2
+ Feature: Some feature
3
+
4
+ Background:
5
+ Given a glass jar
6
+ And a heavy stone
7
+ And salt
8
+
9
+ Scenario: Cutting the vegetables
10
+ Given some vegetables
11
+ Given a sharp knife
12
+ When start chopping the vegetables
13
+ Then there should be small slices of vegetables
14
+
15
+ Scenario: Adding salt and packing
16
+ Given small slices of vegetables
17
+ Given a layer of vegetables is placed in the jar
18
+ And then salt is added
19
+ Given another layer of vegetables is placed in the jar
20
+ And then more salt is added
21
+ Given some garlic is chopped up
22
+ And garlic is layered into the jar
23
+ Given some more vegetables are placed into the jar
24
+ When the jar is nearly full
25
+ Then a stone should be put on top
26
+
27
+ Scenario: Ensuring no exposure to air
28
+ Given a jar full of salted vegetables
29
+ When a heavy stone is placed on top
30
+ And eventually the salt draws water out of the vegetables
31
+ Then eventually the water level will be above the vegetables
32
+ And the vegetables should not be exposed to the air
33
+
34
+ Scenario: Long term plan
35
+ Given a jar full of salted weighed down vegetables
36
+ When the jar is left in a cool place between 60 and 70 degrees F
37
+ Given about two to four weeks time
38
+ Then the vegetables should ferment
39
+
@@ -1,3 +1,3 @@
1
1
  module Sauerkraut
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/sauerkraut.rb CHANGED
@@ -1,6 +1,5 @@
1
- require "sauerkraut/version"
1
+ require 'sauerkraut/version'
2
2
  require 'colorize'
3
- require 'pry'
4
3
 
5
4
  module Sauerkraut
6
5
  # DEFAULT OPTIONS
@@ -16,49 +15,53 @@ module Sauerkraut
16
15
  def self.exit_with_help(message)
17
16
  display_help
18
17
  puts message.red
19
- puts "\t(you specified " + "#{ARGV.join(" ")}".yellow + ")"
18
+ puts "\t(you specified " + "#{@args.join(" ")}".yellow + ")"
20
19
  exit
21
20
  end
22
21
 
23
22
  def self.get_output_file
24
- ARGV[(ARGV.find_index "-o") + 1]
23
+ @args[(@args.find_index "-o") + 1]
25
24
  end
26
25
 
27
26
  def self.output_file?
28
27
  (
29
- (ARGV.include? "-o") &&
30
- (ARGV.last != "-o")
28
+ (@args.include? "-o") &&
29
+ (@args.last != "-o")
31
30
  )
32
31
  end
33
32
 
34
33
  def self.no_output_file_specified?
35
34
  (
36
- (ARGV.include? "-o") &&
37
- (ARGV.last == "-o")
35
+ (@args.include? "-o") &&
36
+ (@args.last == "-o")
38
37
  )
39
38
  end
40
39
 
41
40
  def self.no_feature_file?
42
- ARGV.count == 0
41
+ @args.count == 0
43
42
  end
44
43
 
45
44
  def self.invalid_feature_file?
46
- !(ARGV[0] =~ /\.feature(:\d+)?(:\d+)?/)
45
+ !(@args[0] =~ /\.feature(:\d+)?(:\d+)?/)
46
+ end
47
+
48
+ def self.feature_file_exists?
49
+ File.file? @args.first.split(":").first
47
50
  end
48
51
 
49
52
  def self.no_line_number?
50
- !(ARGV[0].include? ":")
53
+ !(@args[0].include? ":")
51
54
  end
52
55
 
53
56
  def self.invalid_range?
54
57
  (
55
- (ARGV[0] =~ /\.feature:\d+:/) &&
56
- !(ARGV[0] =~ /\.feature(:\d+)(:\d+)/)
58
+ (@args[0] =~ /\.feature:\d+:/) &&
59
+ !(@args[0] =~ /\.feature(:\d+)(:\d+)/)
57
60
  )
58
61
  end
59
62
 
60
63
  def self.range?
61
- ARGV[0] =~ /\.feature(:\d+)(:\d+)/
64
+ @args[0] =~ /\.feature(:\d+)(:\d+)/
62
65
  end
63
66
 
64
67
  def self.is_line_scenario?(line)
@@ -71,7 +74,7 @@ module Sauerkraut
71
74
  end
72
75
 
73
76
  def self.is_def?(line)
74
- line.strip =~ /^def self./
77
+ line.strip =~ /^def /
75
78
  end
76
79
 
77
80
  def self.remove_first_word(line)
@@ -113,10 +116,12 @@ module Sauerkraut
113
116
  f.close
114
117
  end
115
118
 
116
- def self.run
119
+ def self.run(args)
120
+ @args = args
117
121
 
118
122
  exit_with_help("must specify a feature file") if no_feature_file?
119
123
  exit_with_help("must specify a valid feature file") if invalid_feature_file?
124
+ exit_with_help("must specify an existing feature file") if !feature_file_exists?
120
125
  exit_with_help("must specify a line number") if no_line_number?
121
126
  exit_with_help("specify range with :N:M") if invalid_range?
122
127
 
@@ -125,9 +130,9 @@ module Sauerkraut
125
130
 
126
131
 
127
132
  # get feature file
128
- feature_file = ARGV[0].split(":").first
129
- line_number = ARGV[0].split(":")[1].to_i
130
- range_number = range? ? (ARGV[0].split(":").last.to_i) : nil
133
+ feature_file = @args[0].split(":").first
134
+ line_number = @args[0].split(":")[1].to_i
135
+ range_number = range? ? (@args[0].split(":").last.to_i) : nil
131
136
  feature_file_array = IO.readlines feature_file
132
137
 
133
138
 
data/sauerkraut.gemspec CHANGED
@@ -20,5 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3"
23
24
  spec.add_development_dependency "colorize", "~> 0"
25
+ spec.add_development_dependency "pry", "~> 0.10.0"
24
26
  end
@@ -0,0 +1,34 @@
1
+ require 'sauerkraut'
2
+ require 'pry'
3
+
4
+ describe "parsing" do
5
+
6
+ it "parses" do
7
+ expect {Sauerkraut.run "blah".split}.to raise_error
8
+ expect {Sauerkraut.run "blah.feature".split}.to raise_error
9
+ expect {Sauerkraut.run "blah.feature:39".split}.to raise_error
10
+ expect {Sauerkraut.run "features/test.feature:39".split}.to raise_error
11
+ expect {Sauerkraut.run "features/test.feature:15".split}.to_not raise_error
12
+ expect {Sauerkraut.run "features/test.feature:15:".split}.to raise_error
13
+ expect {Sauerkraut.run "features/test.feature:15:17".split}.to_not raise_error
14
+ expect {Sauerkraut.run "features/test.feature:15:17 -o ".split}.to raise_error
15
+ expect {Sauerkraut.run "features/test.feature:15:17 -o aaa.text".split}.to_not raise_error
16
+ expect {Sauerkraut.run "features/test.feature:15 -o aaa.text".split}.to_not raise_error
17
+ expect {Sauerkraut.run "features/test.feature:15 -o ".split}.to raise_error
18
+ expect {Sauerkraut.run "features/blah.feature:15".split}.to raise_error
19
+ end
20
+ end
21
+
22
+ describe "output" do
23
+ it "runtest1" do
24
+ Sauerkraut.run "features/test.feature:15 -o a.text".split
25
+ diff=`diff a.text test/runtest1.output`
26
+ expect(diff).to eq("")
27
+ end
28
+ it "runtest2" do
29
+ Sauerkraut.run "features/test.feature:15:18 -o b.text".split
30
+ diff=`diff b.text test/runtest2.output`
31
+ expect(diff).to eq("")
32
+ end
33
+ end
34
+
@@ -0,0 +1,55 @@
1
+ #Given(/^([\w]+) slices of vegetables$/) do |vegetable_size|
2
+ # block vars
3
+ vegetable_size = "small"
4
+ # |
5
+ # V
6
+ @vegetable_slice_size = vegetable_size.to_sym
7
+
8
+ #Given(/^a(nother)? layer of vegetables is placed in the jar$/) do |repeat|
9
+ # block vars
10
+ repeat = ""
11
+ # |
12
+ # V
13
+ @jar ||= []
14
+ put_vegetables_in_jar
15
+
16
+ #Given(/^then (more )?salt is added$/) do |more|
17
+ # block vars
18
+ more = ""
19
+ # |
20
+ # V
21
+ @salt = 1
22
+ @salt += 1 if more
23
+
24
+ #Given(/^a(nother)? layer of vegetables is placed in the jar$/) do |repeat|
25
+ # block vars
26
+ repeat = "nother"
27
+ # |
28
+ # V
29
+ @jar ||= []
30
+ put_vegetables_in_jar
31
+
32
+ #Given(/^then (more )?salt is added$/) do |more|
33
+ # block vars
34
+ more = "more "
35
+ # |
36
+ # V
37
+ @salt = 1
38
+ @salt += 1 if more
39
+
40
+ #Given(/^some garlic is chopped up$/) do
41
+ @garlic ||= :some
42
+ @garlic.to_s.chop
43
+
44
+ #Given(/^garlic is layered into the jar$/) do
45
+ @jar << {:garlic => true}
46
+
47
+ #Given(/^some more vegetables are placed into the jar$/) do
48
+ put_vegetables_in_jar
49
+
50
+ #When(/^the jar is nearly full$/) do
51
+ @jar << {:nearly_full => true}
52
+
53
+ #Then(/^a stone should be put on top$/) do
54
+ @jar << {:stone => true}
55
+
@@ -0,0 +1,31 @@
1
+ #Given(/^([\w]+) slices of vegetables$/) do |vegetable_size|
2
+ # block vars
3
+ vegetable_size = "small"
4
+ # |
5
+ # V
6
+ @vegetable_slice_size = vegetable_size.to_sym
7
+
8
+ #Given(/^a(nother)? layer of vegetables is placed in the jar$/) do |repeat|
9
+ # block vars
10
+ repeat = ""
11
+ # |
12
+ # V
13
+ @jar ||= []
14
+ put_vegetables_in_jar
15
+
16
+ #Given(/^then (more )?salt is added$/) do |more|
17
+ # block vars
18
+ more = ""
19
+ # |
20
+ # V
21
+ @salt = 1
22
+ @salt += 1 if more
23
+
24
+ #Given(/^a(nother)? layer of vegetables is placed in the jar$/) do |repeat|
25
+ # block vars
26
+ repeat = "nother"
27
+ # |
28
+ # V
29
+ @jar ||= []
30
+ put_vegetables_in_jar
31
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauerkraut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasanth Pappu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-19 00:00:00.000000000 Z
11
+ date: 2014-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.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: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: colorize
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.0
55
83
  description: Gathers all step definition source code for a given scenario or range,
56
84
  and outputs it in one place.
57
85
  email:
@@ -62,14 +90,20 @@ extensions: []
62
90
  extra_rdoc_files: []
63
91
  files:
64
92
  - ".gitignore"
93
+ - ".travis.yml"
65
94
  - Gemfile
66
95
  - LICENSE.txt
67
96
  - README.md
68
97
  - Rakefile
69
98
  - bin/sauerkraut
99
+ - features/step_definitions/materials_steps.rb
100
+ - features/test.feature
70
101
  - lib/sauerkraut.rb
71
102
  - lib/sauerkraut/version.rb
72
103
  - sauerkraut.gemspec
104
+ - spec/sauerkraut_spec.rb
105
+ - test/runtest1.output
106
+ - test/runtest2.output
73
107
  homepage: ''
74
108
  licenses:
75
109
  - MIT
@@ -94,4 +128,9 @@ rubygems_version: 2.2.2
94
128
  signing_key:
95
129
  specification_version: 4
96
130
  summary: Helps refactor cucumber steps.
97
- test_files: []
131
+ test_files:
132
+ - features/step_definitions/materials_steps.rb
133
+ - features/test.feature
134
+ - spec/sauerkraut_spec.rb
135
+ - test/runtest1.output
136
+ - test/runtest2.output