slurper 1.1.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f431cd179fd7aebd44ae9faca7dba74728a68d1
4
+ data.tar.gz: e3c062a31514b3a39c73da68b9618ecb1f0388d7
5
+ SHA512:
6
+ metadata.gz: 7248112fd89f8d81bdcae4da1364c2da793e5f0e935e09b1fc57a9a1992e50c5a635b237386e8691e41abfefc90cb8be043e85f13d177f7ab904e85b95892fb9
7
+ data.tar.gz: fb5295fcc2e9033157e871d946d175345b1e6cf0a29e354854ab07d83cfccba4f1fb2deab5a1ed900959b3fe19aa3c5c711ece40d4115453ca1e9d1312a38314
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Hashrocket
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,20 +1,10 @@
1
- = slurper
1
+ = slurper gem
2
2
 
3
3
  Slurper allows you to quickly compose your stories in a text file and import them into Pivotal Tracker.
4
4
 
5
- Works great with slurper.vim! (http://github.com/alowe/vim-slurper)
5
+ Works great with slurper.vim! (http://github.com/adamlowe/vim-slurper)
6
6
 
7
- == Note on Patches/Pull Requests
8
-
9
- * Fork the project.
10
- * Make your feature addition or bug fix.
11
- * Add tests for it. This is important so I don't break it in a
12
- future version unintentionally.
13
- * Commit, do not mess with rakefile, version, or history.
14
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
15
- * Send me a pull request.
16
-
17
- == Setup
7
+ == Install
18
8
 
19
9
  $gem install slurper
20
10
 
@@ -27,7 +17,6 @@ Slurper requires a slurper_config.yml file in your working directory. This file
27
17
  project_id: 1234
28
18
  token: 123abc123abc123abc
29
19
  requested_by: Jane Stakeholder
30
- ssl: true
31
20
 
32
21
  The project_id tells tracker which project to add your stories to. It can be found on the project settings or the url for the project.
33
22
 
@@ -35,9 +24,6 @@ The token can be found on your personal profile page in Pivotal Tracker.
35
24
 
36
25
  The requested_by field should be the name of your project stakeholder exactly as it appears in tracker.
37
26
 
38
- The ssl field should be set to true if you've enabled "Use HTTPS" in Pivotal Tracker.
39
- SSL is being verified by peer using the cacert.pem from (http://curl.haxx.se/ca)
40
-
41
27
  == Usage
42
28
 
43
29
  Create a stories.slurper file and compose your stories in the slurper story format. In your working directory use the slurp command to import your stories from the stories.slurper file into Pivotal Tracker. Slurper looks for a stories.slurper file in your current directory by default, however, you can provide an alternate story source file if necessary.
@@ -45,11 +31,11 @@ Create a stories.slurper file and compose your stories in the slurper story form
45
31
  Default
46
32
 
47
33
  $slurp ~/stories.slurper
48
-
34
+
49
35
  Also valid
50
36
 
51
37
  $slurp ~/special_stories.slurper
52
-
38
+
53
39
  Or even
54
40
 
55
41
  $slurp ~/mystories.txt
@@ -65,7 +51,7 @@ Or even
65
51
  Set up and configure staging environment for approval of stories
66
52
 
67
53
  labels:
68
-
54
+ staging
69
55
  ==
70
56
  story_type:
71
57
  feature
@@ -89,7 +75,7 @@ Or even
89
75
  This release marks a lot of awesome functionality
90
76
 
91
77
  labels:
92
-
78
+ campaign managers
93
79
  ==
94
80
  story_type:
95
81
  bug
@@ -99,10 +85,40 @@ Or even
99
85
  When I do something, another thing is supposed to happen but I see an error screen instead.
100
86
 
101
87
  labels:
102
-
88
+ campaign managers
103
89
 
104
90
  Note: the story source file is whitespace-sensitive. Be sure the value for each key phrase is indented with two spaces beneath each key phrase. Also, start each story with a double-equals on its own line.
105
91
 
106
92
  Your best bet is to leverage slurper.vim and benefit from its auto-indenting goodness.
107
93
 
94
+ === Example advanced_stories.slurper
95
+
96
+ There are some advanced techniques for formatting your stories beyond the simple type, name, description and label fields. See below for some examples.
97
+
98
+ ==
99
+ story_type:
100
+ feature
101
+ name:
102
+ Make the cart accept coupons on checkout
103
+ description:
104
+ When I get to the checkout phase, I want the ability to add an optional coupon code. Use TESTCOUPON to test with.
105
+ labels:
106
+ cart,coupon system,checkout
107
+ estimate:
108
+ 3
109
+ requested_by:
110
+ Joe Developer
111
+
112
+ Note: Any field that is supported by the Pivotal Tracker API should work within reason (i.e file uploads won't work). To get an idea of the fields available see this page (https://www.pivotaltracker.com/help/faq#canstoriesbeimportedfromcsv)
113
+
114
+ == Note on Patches/Pull Requests
115
+
116
+ * Fork the project.
117
+ * Make your feature addition or bug fix.
118
+ * Add tests for it. This is important so I don't break it in a
119
+ future version unintentionally.
120
+ * Commit, do not mess with rakefile, version, or history.
121
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
122
+ * Send me a pull request.
123
+
108
124
  Credit - Wes Gibbs (http://wgibbs.github.com) thought of and wrote slurper as a ruby script. It was later packaged and released as a gem by his fellow Rocketeers after using it and finding it extremely handy.
@@ -0,0 +1,16 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec) do |spec|
3
+ spec.pattern = "spec/**/*_spec.rb"
4
+ end
5
+
6
+ task :default => :spec
7
+
8
+ require 'rdoc/task'
9
+ Rake::RDocTask.new do |rdoc|
10
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
11
+
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = "test #{version}"
14
+ rdoc.rdoc_files.include('README*')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
@@ -1,60 +1,18 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext/object'
1
3
  require 'yaml'
2
- require 'story'
3
- YAML::ENGINE.yamler='syck'
4
4
 
5
+ module Slurper
5
6
 
6
- class Slurper
7
-
8
- attr_accessor :story_file, :stories
7
+ autoload :Client, 'slurper/client'
8
+ autoload :Config, 'slurper/config'
9
+ autoload :Engine, 'slurper/engine'
10
+ autoload :Story, 'slurper/story'
11
+ autoload :User, 'slurper/user'
9
12
 
10
13
  def self.slurp(story_file, reverse)
11
- slurper = new(story_file)
12
- slurper.load_stories
13
- slurper.prepare_stories
14
+ slurper = Engine.new(story_file)
14
15
  slurper.stories.reverse! unless reverse
15
- slurper.create_stories
16
- end
17
-
18
- def initialize(story_file)
19
- self.story_file = story_file
20
- end
21
-
22
- def load_stories
23
- self.stories = YAML.load(yamlize_story_file)
24
- end
25
-
26
- def prepare_stories
27
- stories.each { |story| story.prepare }
16
+ slurper.process
28
17
  end
29
-
30
- def create_stories
31
- puts "Preparing to slurp #{stories.size} stories into Tracker..."
32
- stories.each_with_index do |story, index|
33
- begin
34
- if story.save
35
- puts "#{index+1}. #{story.name}"
36
- else
37
- puts "Slurp failed. #{story.errors.full_messages}"
38
- end
39
- rescue ActiveResource::ConnectionError => e
40
- msg = "Slurp failed on story "
41
- if story.attributes["name"]
42
- msg << story.attributes["name"]
43
- else
44
- msg << "##{options[:reverse] ? index + 1 : stories.size - index }"
45
- end
46
- puts msg + ". Error: #{e}"
47
- end
48
- end
49
- end
50
-
51
- protected
52
-
53
- def yamlize_story_file
54
- IO.read(story_file).
55
- gsub(/^/, " ").
56
- gsub(/ ==.*/, "- !ruby/object:Story\n attributes:").
57
- gsub(/ description:$/, " description: |")
58
- end
59
-
60
18
  end
@@ -0,0 +1,24 @@
1
+ require 'typhoeus'
2
+
3
+ module Slurper
4
+ class Client
5
+ CREATE_STORY_URL = "https://www.pivotaltracker.com/services/v5/projects/#{Slurper::Config.project_id}/stories"
6
+ USERS_URL = "https://www.pivotaltracker.com/services/v5/projects/#{Slurper::Config.project_id}/memberships"
7
+
8
+ def self.create(story)
9
+ Typhoeus.post CREATE_STORY_URL,
10
+ body: story.to_json,
11
+ headers: {
12
+ "Content-Type" => "application/json",
13
+ "X-TrackerToken" => Slurper::Config.token
14
+ }
15
+ end
16
+
17
+ def self.users
18
+ JSON.parse(Typhoeus.get(
19
+ USERS_URL,
20
+ headers: { "X-TrackerToken" => Slurper::Config.token }
21
+ ).try(:body) || '[]')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ module Slurper
2
+
3
+ class Config
4
+
5
+ def self.project_id; @project_id ||= yaml['project_id'] end
6
+ def self.requested_by; @requested_by ||= yaml['requested_by'] end
7
+ def self.token; @token ||= yaml['token'] end
8
+
9
+ private
10
+
11
+ def self.yaml
12
+ YAML.load_file('slurper_config.yml')
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,32 @@
1
+ module Slurper
2
+ class Engine < Struct.new(:story_file)
3
+
4
+ def stories
5
+ @stories ||= YAML.load(yamlize_story_file).map { |attrs| Slurper::Story.new(attrs) }
6
+ end
7
+
8
+ def process
9
+ puts "Validating story content"
10
+ stories.each(&:valid?)
11
+
12
+ puts "Preparing to slurp #{stories.size} stories into Tracker..."
13
+ stories.each_with_index do |story, index|
14
+ if story.save
15
+ puts "#{index+1}. #{story.name}"
16
+ else
17
+ puts "Slurp failed. #{story.error_message}"
18
+ end
19
+ end
20
+ end
21
+
22
+ protected
23
+
24
+ def yamlize_story_file
25
+ IO.read(story_file).
26
+ gsub(/^/, " ").
27
+ gsub(/ ==.*/, "-").# !ruby/object:Slurper::Story\n attributes:").
28
+ gsub(/ description:$/, " description: |")
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,66 @@
1
+ require 'json'
2
+
3
+ module Slurper
4
+ class Story
5
+
6
+ attr_accessor :attributes
7
+ def initialize(attrs={})
8
+ self.attributes = (attrs || {}).symbolize_keys
9
+
10
+ if attributes[:owned_by].present?
11
+ puts "DEPRECATION WARNING: `owned_by` is no longer a supported attribute. Please change to `requested_by`."
12
+ attributes[:requested_by] = attributes[:owned_by]
13
+ end
14
+ end
15
+
16
+ def to_json
17
+ {
18
+ name: name,
19
+ description: description,
20
+ story_type: story_type,
21
+ labels: labels,
22
+ estimate: estimate,
23
+ requested_by_id: requested_by_id
24
+ }.reject { |k,v| v.blank? }.to_json
25
+ end
26
+
27
+ def save
28
+ (@response = Slurper::Client.create(self)).success?
29
+ end
30
+
31
+ def error_message; @response.body end
32
+
33
+ def name; attributes[:name] end
34
+ def estimate; attributes[:estimate] end
35
+ def story_type; attributes[:story_type] end
36
+
37
+ def description
38
+ return nil unless attributes[:description].present?
39
+ attributes[:description].split("\n").map(&:strip).join("\n")
40
+ end
41
+
42
+ def labels
43
+ return [] unless attributes[:labels].present?
44
+ attributes[:labels].split(',').map do |tag|
45
+ {name: tag}
46
+ end
47
+ end
48
+
49
+ def requested_by
50
+ attributes[:requested_by].presence || Slurper::Config.requested_by
51
+ end
52
+
53
+ def requested_by_id
54
+ Slurper::User.find_by_name(requested_by).try(:id) if requested_by.present?
55
+ end
56
+
57
+ def valid?
58
+ if name.blank?
59
+ raise "Name is blank for story:\n#{to_json}"
60
+ elsif !requested_by_id
61
+ raise "Could not find requester \"#{requested_by}\" in project"
62
+ end
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,21 @@
1
+ module Slurper
2
+ class User
3
+ attr_accessor :attributes
4
+ def initialize(attrs={})
5
+ self.attributes = (attrs || {}).symbolize_keys
6
+ end
7
+
8
+ def self.collection
9
+ @collection ||= Slurper::Client.users.map do |attrs|
10
+ Slurper::User.new(attrs['person'])
11
+ end
12
+ end
13
+
14
+ def self.find_by_name(name)
15
+ collection.detect { |user| user.name == name }
16
+ end
17
+
18
+ def name; attributes[:name] end
19
+ def id; attributes[:id] end
20
+ end
21
+ end
metadata CHANGED
@@ -1,67 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slurper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
- - Wes Gibbs
9
7
  - Adam Lowe
10
- - Stephen Caudill
11
- - Tim Pope
8
+ - Paul Elliott
9
+ - Taylor Mock
12
10
  autorequire:
13
11
  bindir: bin
14
12
  cert_chain: []
15
- date: 2011-08-04 00:00:00.000000000Z
13
+ date: 2014-05-08 00:00:00.000000000 Z
16
14
  dependencies:
17
15
  - !ruby/object:Gem::Dependency
18
- name: activeresource
19
- requirement: &70272048833000 !ruby/object:Gem::Requirement
20
- none: false
16
+ name: activesupport
17
+ requirement: !ruby/object:Gem::Requirement
21
18
  requirements:
22
- - - ~>
19
+ - - "~>"
23
20
  - !ruby/object:Gem::Version
24
- version: 3.0.9
21
+ version: '4.1'
25
22
  type: :runtime
26
23
  prerelease: false
27
- version_requirements: *70272048833000
28
- - !ruby/object:Gem::Dependency
29
- name: rspec
30
- requirement: &70272048832060 !ruby/object:Gem::Requirement
31
- none: false
24
+ version_requirements: !ruby/object:Gem::Requirement
32
25
  requirements:
33
- - - ~>
26
+ - - "~>"
34
27
  - !ruby/object:Gem::Version
35
- version: 1.3.0
36
- type: :development
37
- prerelease: false
38
- version_requirements: *70272048832060
28
+ version: '4.1'
39
29
  - !ruby/object:Gem::Dependency
40
- name: ruby-debug19
41
- requirement: &70272048831080 !ruby/object:Gem::Requirement
42
- none: false
30
+ name: typhoeus
31
+ requirement: !ruby/object:Gem::Requirement
43
32
  requirements:
44
- - - ~>
33
+ - - "~>"
45
34
  - !ruby/object:Gem::Version
46
- version: 0.11.6
47
- type: :development
35
+ version: '0.6'
36
+ type: :runtime
48
37
  prerelease: false
49
- version_requirements: *70272048831080
50
- - !ruby/object:Gem::Dependency
51
- name: configuration
52
- requirement: &70272048830160 !ruby/object:Gem::Requirement
53
- none: false
38
+ version_requirements: !ruby/object:Gem::Requirement
54
39
  requirements:
55
- - - ~>
40
+ - - "~>"
56
41
  - !ruby/object:Gem::Version
57
- version: 1.2.0
58
- type: :development
59
- prerelease: false
60
- version_requirements: *70272048830160
61
- description: ! "\n Slurps stories from the given file (stories.slurper by default)
62
- and creates Pivotal Tracker stories from them. Useful during story carding sessions
63
- when you want to capture a number of stories quickly without clicking your way through
64
- the Tracker UI.\n "
42
+ version: '0.6'
43
+ description: Slurps stories from the given file (stories.slurper by default) and creates
44
+ Pivotal Tracker stories from them. Useful during story carding sessions when you
45
+ want to capture a number of stories quickly without clicking your way through the
46
+ Tracker UI.
65
47
  email: dev@hashrocket.com
66
48
  executables:
67
49
  - slurp
@@ -69,38 +51,39 @@ extensions: []
69
51
  extra_rdoc_files:
70
52
  - README.rdoc
71
53
  files:
54
+ - MIT_LICENSE
55
+ - README.rdoc
56
+ - Rakefile
72
57
  - bin/slurp
73
58
  - lib/slurper.rb
74
- - lib/story.rb
75
- - lib/cacert.pem
76
- - README.rdoc
77
- - spec/slurper_spec.rb
78
- - spec/story_spec.rb
59
+ - lib/slurper/client.rb
60
+ - lib/slurper/config.rb
61
+ - lib/slurper/engine.rb
62
+ - lib/slurper/story.rb
63
+ - lib/slurper/user.rb
79
64
  homepage: http://github.com/hashrocket/slurper
80
- licenses: []
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
81
68
  post_install_message:
82
69
  rdoc_options:
83
- - --charset=UTF-8
70
+ - "--charset=UTF-8"
84
71
  require_paths:
85
72
  - lib
86
73
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
74
  requirements:
89
- - - ! '>='
75
+ - - ">="
90
76
  - !ruby/object:Gem::Version
91
77
  version: '0'
92
78
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
79
  requirements:
95
- - - ! '>='
80
+ - - ">="
96
81
  - !ruby/object:Gem::Version
97
- version: 1.3.6
82
+ version: '0'
98
83
  requirements: []
99
84
  rubyforge_project:
100
- rubygems_version: 1.8.6
85
+ rubygems_version: 2.2.2
101
86
  signing_key:
102
- specification_version: 3
87
+ specification_version: 4
103
88
  summary: takes a formatted story file and puts it on Pivotal Tracker
104
- test_files:
105
- - spec/slurper_spec.rb
106
- - spec/story_spec.rb
89
+ test_files: []