trello_slurper 0.0.2

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: cab909d42e28fcb28d981625d8309d7d62112417
4
+ data.tar.gz: 6dc7aa379f7b211baa8f89385a07ee5e662a897e
5
+ SHA512:
6
+ metadata.gz: 3911cc851291d7daa1ff52610444b057c4a743efd256e17dc4a8fa26653d7ac41cf72fe406ca5d1227c3c785d594915e7ba43e549e458365ed026b303372b552
7
+ data.tar.gz: 9429210f33294a3433f22ba042049ad45eb8bf4b027fa490ec6140128b10e83b40c51e73f0ddbb096f1a6cca68312b46ab549f941eb9ef18f9070e4d671d6313
@@ -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.
@@ -0,0 +1,81 @@
1
+ = trello_slurper
2
+
3
+ Trello Slurper allows you to quickly compose your stories in a text file and import them as cards into Trello.
4
+
5
+ Works great with slurper.vim! (http://github.com/adamlowe/vim-slurper)
6
+
7
+ This is a highly-altered fork of the original slurper gem (http://github.com/hashrocket/slurper)
8
+
9
+ Disclaimer: This fork is still quite new. Tests are currently broken, but basic functionality works.
10
+
11
+ == Install
12
+
13
+ $gem install trello_slurper
14
+
15
+ == Config
16
+
17
+ Trello Slurper requires a tslurper_config.yml file in your working directory. This file contains your Trello API application key and board id.
18
+
19
+ === Example
20
+
21
+ trello_application_key: 123abc123abc123abc
22
+ trello_board_id: 1234abcd
23
+
24
+ trello_application_key is required to fetch a write token for your user. You can get the key by visiting: https://trello.com/1/appKey/generate
25
+
26
+ trello_board_id is the 8 character id of the board in which you'd like to create cards. You can find the board id immediately after /b/ in the board URL.
27
+ eg. for the board at https://trello.com/b/1234abcd/test-board, the board id is '1234abcd'.
28
+
29
+ == Usage
30
+
31
+ Create a stories.slurper file and compose your stories in the slurper story format. In your working directory use the tslurp 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.
32
+
33
+ Default
34
+
35
+ $tslurp
36
+
37
+ Also valid
38
+
39
+ $tslurp ~/special_stories.slurper
40
+
41
+ Or even
42
+
43
+ $tslurp ~/mystories.txt
44
+
45
+ === Example stories.slurper
46
+
47
+ ==
48
+ name:
49
+ Set Up Staging Environment
50
+ description:
51
+ Set up and configure staging environment for approval of stories
52
+
53
+ ==
54
+ name:
55
+ Campaign Manager Does Something
56
+ description:
57
+ In order to get some value
58
+ As a campaign manager
59
+ I want to do something
60
+
61
+ - can do something
62
+
63
+
64
+ 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.
65
+
66
+ Your best bet is to leverage slurper.vim and benefit from its auto-indenting goodness.
67
+
68
+ Currently, only name and description are supported due to weak label support in the Trello card creation API.
69
+
70
+
71
+ == Note on Patches/Pull Requests
72
+
73
+ * Fork the project.
74
+ * Make your feature addition or bug fix.
75
+ * Add tests for it. This is important so I don't break it in a
76
+ future version unintentionally.
77
+ * Commit, do not mess with rakefile, version, or history.
78
+ (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)
79
+ * Send me a pull request.
80
+
81
+ 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
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Slurps stories from the given file (stories.slurper by default) and creates
4
+ # Pivotal Tracker stories from them. Useful during story carding sessions
5
+ # when you want to capture a number of stories quickly without clicking
6
+ # your way through the Tracker UI.
7
+
8
+ # Default story values and API token information should be provided in a
9
+ # ~/.slurper.yml file.
10
+
11
+ # Note that if you include labels in stories.slurper, they don't appear
12
+ # immediately in Tracker. You'll have to refresh Tracker after a few seconds
13
+ # to see them.
14
+
15
+ $:.unshift(File.join(File.dirname(File.dirname(__FILE__)),'lib'))
16
+ require 'rubygems'
17
+ require 'slurper'
18
+ require 'optparse'
19
+
20
+ options = {}
21
+ OptionParser.new do |opts|
22
+ opts.on("-r", "--reverse", "Reverse story creation order") do |v|
23
+ options[:reverse] = v
24
+ end
25
+ end.parse!
26
+
27
+ story_file = ARGV.empty? ? "stories.slurper" : ARGV[0]
28
+
29
+ Slurper.slurp(story_file, options[:reverse])
@@ -0,0 +1,18 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext/object'
3
+ require 'yaml'
4
+
5
+ module Slurper
6
+
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'
12
+
13
+ def self.slurp(story_file, reverse)
14
+ slurper = Engine.new(story_file)
15
+ slurper.stories.reverse! unless reverse
16
+ slurper.process
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'typhoeus'
2
+
3
+ module Slurper
4
+ class Client
5
+ attr_reader :write_token, :list_id
6
+
7
+ def get_trello_write_token
8
+ url = "https://trello.com/1/authorize?key=#{Slurper::Config.trello_application_key}&name=Slurper%20for%20Trello&expiration=1day&response_type=token&scope=read%2Cwrite"
9
+ puts "You must provide a write-enabled Trello API token."
10
+ puts "Ensure you're logged into Trello, then press the <ENTER> key to open a browser window to fetch this token."
11
+ _ = gets
12
+ `open "#{url}"`
13
+ puts "Please paste your token."
14
+ @write_token = gets.strip
15
+ end
16
+
17
+ def create_list
18
+ url = "https://trello.com/1/boards/#{Slurper::Config.trello_board_id}/lists?key=#{Slurper::Config.trello_application_key}&token=#{write_token}&name=Slurper%20Import"
19
+ @list_id = JSON.parse(Typhoeus.post(url).body)["id"]
20
+ end
21
+
22
+ def create_card(story)
23
+ url = "https://trello.com/1/lists/#{list_id}/cards?key=#{Slurper::Config.trello_application_key}&token=#{write_token}"
24
+ Typhoeus.post url, body: story.to_post_params
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ module Slurper
2
+
3
+ class Config
4
+
5
+ def self.trello_application_key; @trello_application_key ||= yaml['trello_application_key'] end
6
+ def self.trello_board_id; @trello_board_id ||= yaml['trello_board_id'] end
7
+
8
+ private
9
+
10
+ def self.yaml
11
+ YAML.load_file('tslurper_config.yml')
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,41 @@
1
+ module Slurper
2
+ class Engine < Struct.new(:story_file)
3
+
4
+ attr :client
5
+
6
+ def initialize(*args)
7
+ super(*args)
8
+ @client = Slurper::Client.new
9
+ @client.get_trello_write_token
10
+ @client.create_list
11
+ end
12
+
13
+ def stories
14
+ @stories ||= YAML.load(yamlize_story_file).map { |attrs| Slurper::Story.new(attrs) }
15
+ end
16
+
17
+ def process
18
+ puts "Validating story content"
19
+ stories.each(&:valid?)
20
+
21
+ puts "Preparing to slurp #{stories.size} stories into Trello..."
22
+ stories.each_with_index do |story, index|
23
+ if client.create_card(story)
24
+ puts "#{index+1}. #{story.name}"
25
+ else
26
+ puts "Slurp failed. #{story.error_message}"
27
+ end
28
+ end
29
+ end
30
+
31
+ protected
32
+
33
+ def yamlize_story_file
34
+ IO.read(story_file).
35
+ gsub(/^/, " ").
36
+ gsub(/ ==.*/, "-").# !ruby/object:Slurper::Story\n attributes:").
37
+ gsub(/ description:$/, " description: |")
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,35 @@
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
+ end
10
+
11
+ def to_post_params
12
+ {
13
+ name: name,
14
+ desc: description,
15
+ due: nil
16
+ }
17
+ end
18
+
19
+ def error_message; @response.body end
20
+
21
+ def name; attributes[:name] end
22
+
23
+ def description
24
+ return nil unless attributes[:description].present?
25
+ attributes[:description].split("\n").map(&:strip).join("\n")
26
+ end
27
+
28
+ def valid?
29
+ if name.blank?
30
+ raise "Name is blank for story:\n#{to_json}"
31
+ end
32
+ end
33
+
34
+ end
35
+ 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 ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trello_slurper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Adam Lowe
8
+ - Paul Elliott
9
+ - Taylor Mock
10
+ - Nickolas Means
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2015-03-26 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: typhoeus
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '0.6'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.6'
44
+ description: Slurps stories from the given file (stories.slurper by default) and creates
45
+ Trello cards from them. Useful during story carding sessions when you want to capture
46
+ a number of stories quickly without clicking your way through the Tracker UI.
47
+ email: dev@wellmatchhealth.com
48
+ executables:
49
+ - tslurp
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README.rdoc
53
+ files:
54
+ - MIT_LICENSE
55
+ - README.rdoc
56
+ - Rakefile
57
+ - bin/tslurp
58
+ - lib/slurper.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
64
+ homepage: http://github.com/nmeans/trello_slurper
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options:
70
+ - "--charset=UTF-8"
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.2.2
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: takes a formatted story file and creates Trello cards
89
+ test_files: []