slurper 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slurper.rb +13 -18
- data/lib/story.rb +27 -9
- data/spec/slurper_spec.rb +4 -28
- data/spec/story_spec.rb +96 -0
- metadata +21 -9
data/lib/slurper.rb
CHANGED
@@ -5,7 +5,8 @@ class Slurper
|
|
5
5
|
|
6
6
|
def self.slurp(story_file, reverse)
|
7
7
|
slurper = new(story_file)
|
8
|
-
slurper.
|
8
|
+
slurper.load_stories
|
9
|
+
slurper.prepare_stories
|
9
10
|
slurper.stories.reverse! unless reverse
|
10
11
|
slurper.create_stories
|
11
12
|
end
|
@@ -14,14 +15,12 @@ class Slurper
|
|
14
15
|
self.story_file = story_file
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
self.stories = YAML.load(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
)
|
24
|
-
scrub_descriptions
|
18
|
+
def load_stories
|
19
|
+
self.stories = YAML.load(yamlize_story_file)
|
20
|
+
end
|
21
|
+
|
22
|
+
def prepare_stories
|
23
|
+
stories.each { |story| story.prepare }
|
25
24
|
end
|
26
25
|
|
27
26
|
def create_stories
|
@@ -44,15 +43,11 @@ class Slurper
|
|
44
43
|
|
45
44
|
protected
|
46
45
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
if story.respond_to?(:description) && story.description == ""
|
53
|
-
story.attributes["description"] = nil
|
54
|
-
end
|
55
|
-
end
|
46
|
+
def yamlize_story_file
|
47
|
+
IO.read(story_file).
|
48
|
+
gsub(/^/, " ").
|
49
|
+
gsub(/ ==.*/, "- !ruby/object:Story\n attributes:").
|
50
|
+
gsub(/ description:$/, " description: |")
|
56
51
|
end
|
57
52
|
|
58
53
|
end
|
data/lib/story.rb
CHANGED
@@ -2,15 +2,33 @@ require 'active_resource'
|
|
2
2
|
|
3
3
|
class Story < ActiveResource::Base
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
def self.config
|
6
|
+
@@config ||= YAML.load_file('slurper_config.yml')
|
7
|
+
end
|
8
|
+
|
9
|
+
self.site = "http://www.pivotaltracker.com/services/v3/projects/#{config['project_id']}"
|
10
|
+
headers['X-TrackerToken'] = config.delete("token")
|
11
|
+
|
12
|
+
def prepare
|
13
|
+
scrub_description
|
14
|
+
default_requested_by
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def scrub_description
|
20
|
+
if respond_to?(:description)
|
21
|
+
self.description = description.gsub(" ", "").gsub(" \n", "\n")
|
22
|
+
end
|
23
|
+
if respond_to?(:description) && description == ""
|
24
|
+
self.attributes["description"] = nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_requested_by
|
29
|
+
if (!respond_to?(:requested_by) || requested_by == "") && Story.config["requested_by"]
|
30
|
+
self.attributes["requested_by"] = Story.config["requested_by"]
|
31
|
+
end
|
14
32
|
end
|
15
33
|
|
16
34
|
end
|
data/spec/slurper_spec.rb
CHANGED
@@ -7,23 +7,19 @@ describe Slurper do
|
|
7
7
|
context "deals with leading/trailing whitespace" do
|
8
8
|
before do
|
9
9
|
slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "whitespacey_story.slurper"))
|
10
|
-
slurper.
|
10
|
+
slurper.load_stories
|
11
11
|
@story = slurper.stories.first
|
12
12
|
end
|
13
13
|
|
14
14
|
it "strips whitespace from the name" do
|
15
15
|
@story.name.should == "Profit"
|
16
16
|
end
|
17
|
-
|
18
|
-
it "strips whitespace from the description" do
|
19
|
-
@story.description.should == "In order to do something\nAs a role\nI want to click a thingy\n"
|
20
|
-
end
|
21
17
|
end
|
22
18
|
|
23
19
|
context "given values for all attributes" do
|
24
20
|
before do
|
25
21
|
slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "full_story.slurper"))
|
26
|
-
slurper.
|
22
|
+
slurper.load_stories
|
27
23
|
@story = slurper.stories.first
|
28
24
|
end
|
29
25
|
|
@@ -31,10 +27,6 @@ describe Slurper do
|
|
31
27
|
@story.name.should == "Profit"
|
32
28
|
end
|
33
29
|
|
34
|
-
it "parses the description correctly" do
|
35
|
-
@story.description.should == "In order to do something\nAs a role\nI want to click a thingy\n\nAcceptance:\n- do the thing\n- don't forget the other thing\n"
|
36
|
-
end
|
37
|
-
|
38
30
|
it "parses the label correctly" do
|
39
31
|
@story.labels.should == "money,power,fame"
|
40
32
|
end
|
@@ -47,7 +39,7 @@ describe Slurper do
|
|
47
39
|
context "given only a name" do
|
48
40
|
before do
|
49
41
|
slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "name_only.slurper"))
|
50
|
-
slurper.
|
42
|
+
slurper.load_stories
|
51
43
|
@story = slurper.stories.first
|
52
44
|
end
|
53
45
|
|
@@ -60,7 +52,7 @@ describe Slurper do
|
|
60
52
|
context "given empty attributes" do
|
61
53
|
before do
|
62
54
|
slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "empty_attributes.slurper"))
|
63
|
-
slurper.
|
55
|
+
slurper.load_stories
|
64
56
|
@story = slurper.stories.first
|
65
57
|
end
|
66
58
|
|
@@ -68,25 +60,9 @@ describe Slurper do
|
|
68
60
|
@story.name.should be_nil
|
69
61
|
end
|
70
62
|
|
71
|
-
it "should not set any description" do
|
72
|
-
@story.description.should be_nil
|
73
|
-
end
|
74
|
-
|
75
63
|
it "should not set any labels" do
|
76
64
|
@story.labels.should be_nil
|
77
65
|
end
|
78
66
|
end
|
79
67
|
|
80
|
-
context "given attributes with spaces" do
|
81
|
-
before do
|
82
|
-
slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "quoted_attributes.slurper"))
|
83
|
-
slurper.yamlize_story_file
|
84
|
-
@story = slurper.stories.first
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should set the description correctly" do
|
88
|
-
@story.description.should == "I have a \"quote\"\n"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
68
|
end
|
data/spec/story_spec.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require 'slurper'
|
4
|
+
|
5
|
+
describe Story do
|
6
|
+
|
7
|
+
context "#prepare" do
|
8
|
+
it "scrubs the description" do
|
9
|
+
story = Story.new
|
10
|
+
story.stub!(:default_requested_by)
|
11
|
+
story.should_receive(:scrub_description)
|
12
|
+
story.prepare
|
13
|
+
end
|
14
|
+
|
15
|
+
it "scrubs the defaults the requested_by attribute" do
|
16
|
+
story = Story.new
|
17
|
+
story.stub!(:scrub_description)
|
18
|
+
story.should_receive(:default_requested_by)
|
19
|
+
story.prepare
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "requested_by attribute" do
|
24
|
+
it "uses the default if not given one" do
|
25
|
+
Story.stub!(:config).and_return({"requested_by" => "Mr. Client"})
|
26
|
+
story = Story.new
|
27
|
+
story.send(:default_requested_by)
|
28
|
+
story.requested_by.should == "Mr. Client"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "uses the default if given a blank requested_by" do
|
32
|
+
Story.stub!(:config).and_return({"requested_by" => "Mr. Client"})
|
33
|
+
story = Story.new(:requested_by => "")
|
34
|
+
story.send(:default_requested_by)
|
35
|
+
story.requested_by.should == "Mr. Client"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "uses the name given in the story file if there is one" do
|
39
|
+
Story.stub!(:config).and_return({"requested_by" => "Mr. Client"})
|
40
|
+
story = Story.new(:requested_by => "Mr. Stakeholder")
|
41
|
+
story.send(:default_requested_by)
|
42
|
+
story.requested_by.should == "Mr. Stakeholder"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "scrubs the descriptions correctly" do
|
47
|
+
it "when the description is blank" do
|
48
|
+
story = Story.new(:description => "")
|
49
|
+
story.send(:scrub_description)
|
50
|
+
story.description.should be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it "when there is no description given" do
|
54
|
+
story = Story.new
|
55
|
+
lambda {
|
56
|
+
story.send(:scrub_description)
|
57
|
+
}.should_not raise_error
|
58
|
+
end
|
59
|
+
|
60
|
+
it "when it contains quotes" do
|
61
|
+
desc = <<-STRING
|
62
|
+
I have a "quote"
|
63
|
+
STRING
|
64
|
+
story = Story.new(:description => desc)
|
65
|
+
story.send(:scrub_description)
|
66
|
+
story.description.should == "I have a \"quote\"\n"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "when it is full of whitespace" do
|
70
|
+
desc = <<-STRING
|
71
|
+
In order to do something
|
72
|
+
As a role
|
73
|
+
I want to click a thingy
|
74
|
+
STRING
|
75
|
+
story = Story.new(:description => desc)
|
76
|
+
story.send(:scrub_description)
|
77
|
+
story.description.should == "In order to do something\nAs a role\nI want to click a thingy\n"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "when it contains acceptance criteria" do
|
81
|
+
desc = <<-STRING
|
82
|
+
In order to do something
|
83
|
+
As a role
|
84
|
+
I want to click a thingy
|
85
|
+
|
86
|
+
Acceptance:
|
87
|
+
- do the thing
|
88
|
+
- don't forget the other thing
|
89
|
+
STRING
|
90
|
+
story = Story.new(:description => desc)
|
91
|
+
story.send(:scrub_description)
|
92
|
+
story.description.should == "In order to do something\nAs a role\nI want to click a thingy\n\nAcceptance:\n- do the thing\n- don't forget the other thing\n"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slurper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Wes Gibbs
|
@@ -12,19 +17,23 @@ autorequire:
|
|
12
17
|
bindir: bin
|
13
18
|
cert_chain: []
|
14
19
|
|
15
|
-
date: 2010-02-
|
20
|
+
date: 2010-02-22 00:00:00 -05:00
|
16
21
|
default_executable: slurp
|
17
22
|
dependencies:
|
18
23
|
- !ruby/object:Gem::Dependency
|
19
24
|
name: rspec
|
20
|
-
|
21
|
-
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
27
|
requirements:
|
24
28
|
- - ">="
|
25
29
|
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
26
34
|
version: 1.2.9
|
27
|
-
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
28
37
|
description: "\n Slurps stories from the given file (stories.slurper by default) and creates\n Pivotal Tracker stories from them. Useful during story carding sessions\n when you want to capture a number of stories quickly without clicking\n your way through the Tracker UI.\n "
|
29
38
|
email: info@hashrocket.com
|
30
39
|
executables:
|
@@ -51,20 +60,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
60
|
requirements:
|
52
61
|
- - ">="
|
53
62
|
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
54
65
|
version: "0"
|
55
|
-
version:
|
56
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
67
|
requirements:
|
58
68
|
- - ">="
|
59
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
60
72
|
version: "0"
|
61
|
-
version:
|
62
73
|
requirements: []
|
63
74
|
|
64
75
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.6
|
66
77
|
signing_key:
|
67
78
|
specification_version: 3
|
68
79
|
summary: takes a formatted story file and puts it on Pivotal Tracker
|
69
80
|
test_files:
|
70
81
|
- spec/slurper_spec.rb
|
82
|
+
- spec/story_spec.rb
|