pttool 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 46bde8c87b5aec081f9f3a0f878ed45256cd2c82
4
+ data.tar.gz: b993ffd40473bd7f71886073359e10f48aa3c884
5
+ SHA512:
6
+ metadata.gz: fe3f1cb985008c0daef484bd7816953083414b3158001fc64647b5c3922a3a51a053178bc7afa9db8c26ddd162523cd9160230d2e57b8807e71b051affadea27
7
+ data.tar.gz: 6e6a2924e480801c73597d60629f7f796cc08993ca6b84ebe23f5fcf1c4bf2125db1237632c7eb1d41e9c1c7dd1e3d4de36a43885c98d01a735f29d91aac0ebf
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2015, AppFolio, Inc.
2
+ Copyright (c) 2015, Bryce Boe
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # PTTool: Command line tool that interfaces with pivotaltracker
2
+
3
+
4
+ ### Installation
5
+
6
+ gem install pttool
7
+
8
+ ## Usage
9
+
10
+ ### List of PT Projects
11
+
12
+ pttool projects
13
+
14
+ ### Other
15
+
16
+ To see a list of all commands simply run `pttool` or `pttool --help`.
17
+
18
+
19
+ ## Copyright and license
20
+
21
+ Source released under the Simplified BSD License.
22
+
23
+ * Copyright (c), 2015, AppFolio, Inc
24
+ * Copyright (c), 2015, Bryce Boe
data/bin/pttool ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pttool'
3
+ exit PTTool.application.run
@@ -0,0 +1,60 @@
1
+ require 'docopt'
2
+ require_relative 'error'
3
+ require_relative 'version'
4
+
5
+ module PTTool
6
+ # The command line interface to PTTool
7
+ class Application
8
+ DOC = <<-DOC
9
+ pttool: A tool that interfaces with pivotal tracker.
10
+
11
+ Usage:
12
+ pttool projects [--sort=<key>] [--members]
13
+ pttool -h | --help
14
+ pttool --version
15
+
16
+ Options:
17
+ --members Output the number of members [default: false].
18
+ --sort=<key> Sort output by name or id [default: name].
19
+ -h --help Show this information.
20
+ --version Show the pttool version (#{VERSION}).
21
+ DOC
22
+
23
+ def initialize
24
+ @exit_status = 0
25
+ end
26
+
27
+ def cmd_projects(members, sort)
28
+ unless %w(name id).include?(sort)
29
+ raise Docopt::Exit, 'invalid sort option'
30
+ end
31
+ PTTool.client.projects.sort_by { |k| k.send(sort) }.each do |project|
32
+ member_extra = " (#{project.memberships.size} members)" if members
33
+ puts format("%8s: #{project.name}#{member_extra}", project.id)
34
+ end
35
+ end
36
+
37
+ def run
38
+ opt = Docopt.docopt(DOC, version: VERSION)
39
+ if opt['projects']
40
+ cmd_projects(opt['--members'], opt['--sort'])
41
+ else
42
+ commands = opt.find_all { |x| x[1] == true }.map { |x| x[0] }
43
+ puts "Unhandled command(s): #{commands}"
44
+ @exit_status = 2
45
+ end
46
+ @exit_status
47
+ rescue Docopt::Exit => exc
48
+ exit_with_status(exc.message, exc.class.usage != '')
49
+ rescue => exc
50
+ exit_with_status(exc.message)
51
+ end
52
+
53
+ private
54
+
55
+ def exit_with_status(msg, condition = true)
56
+ puts msg
57
+ @exit_status == 0 && condition ? 1 : @exit_status
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ require 'tracker_api'
2
+ require_relative 'error'
3
+
4
+ module PTTool
5
+ # Provides access to the TrackerApi client.
6
+ class Client
7
+ class << self
8
+ def get
9
+ unless ENV['PT_TOKEN']
10
+ @exit_status = 1
11
+ raise Error, 'PT_TOKEN environment variable must be set'
12
+ end
13
+ begin
14
+ TrackerApi::Client.new(token: ENV['PT_TOKEN']).tap(&:me)
15
+ rescue TrackerApi::Error
16
+ raise Error, 'Could not connect to pivotaltracker'
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module PTTool
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'application'
2
+ require_relative 'client'
3
+
4
+ # PTTool
5
+ module PTTool
6
+ class << self
7
+ def application
8
+ @application ||= PTTool::Application.new
9
+ end
10
+
11
+ def client
12
+ @client ||= PTTool::Client.get
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ # PTTool
2
+ module PTTool
3
+ VERSION = '0.0.1'
4
+ end
data/lib/pttool.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'pttool/application'
2
+ require 'pttool/pttool_module'
3
+ require 'pttool/version'
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pttool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bryce Boe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: docopt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tracker_api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ description:
42
+ email: bryce.boe@appfolio.com
43
+ executables:
44
+ - pttool
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.txt
49
+ - README.md
50
+ - bin/pttool
51
+ - lib/pttool.rb
52
+ - lib/pttool/application.rb
53
+ - lib/pttool/client.rb
54
+ - lib/pttool/error.rb
55
+ - lib/pttool/pttool_module.rb
56
+ - lib/pttool/version.rb
57
+ homepage: https://github.com/bboe/pttool
58
+ licenses:
59
+ - Simplified BSD
60
+ metadata: {}
61
+ post_install_message: Thanks for installing!
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Command line tool that interfaces with pivotaltracker
81
+ test_files: []