pivotaltracker 0.0.1

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: 61ac8b68150b99a9fcf1d21285a32e8ca34adab1
4
+ data.tar.gz: 42bf2e0a941060432bc9bf5948361a952d372ed7
5
+ SHA512:
6
+ metadata.gz: c00c927724f0d363e919c49157521bce6ad13c1f9543c29cb63d0e1eeed2a8ad0e2ca90039c6bb5fdfae77123b3b075b3786394daa6baf16b00ed6cf69c7672d
7
+ data.tar.gz: 23b76717b114e81e3237f58a33fa607b6e3c158866f81ea5f7d2dc4f686503a292e7cd277c85b40dfaef9a45a89072bee191379911ed63c031d7d400461ec11d
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .rspec
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1
5
+ - 2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pivotaltracker.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alvaro Fernando Lara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Alvaro F. Lara
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # PivotalTracker (*.rb)
2
+
3
+ Pivotal Tracker API v.5 client.
4
+
5
+ [![Code
6
+ Climate](https://codeclimate.com/github/guiman/pivotaltracker/badges/gpa.svg)](https://codeclimate.com/github/guiman/pivotaltracker)
7
+ [![Build
8
+ Status](https://travis-ci.org/guiman/pivotaltracker.svg)](https://travis-ci.org/guiman/pivotaltracker)
9
+ [![Test
10
+ Coverage](https://codeclimate.com/github/guiman/pivotaltracker/badges/coverage.svg)](https://codeclimate.com/github/guiman/pivotaltracker)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'pivotaltracker'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install pivotaltracker
27
+
28
+ ## Usage
29
+
30
+ ```
31
+ api = PivotalTracker::API.new(configuration) do |config|
32
+ config.token = api_token
33
+ end
34
+
35
+ project = PivotalTracker::Project.find(project_id)
36
+
37
+ stories = project.stories
38
+ iterations = project.iterations
39
+
40
+ stories_from_iterations = iterations.first.stories
41
+
42
+ ...
43
+
44
+ api.reset!
45
+ ```
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/[my-github-username]/pivotaltracker/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ require 'pivotaltracker/version'
2
+ require 'pivotaltracker/api'
3
+ require 'pivotaltracker/iteration'
4
+ require 'pivotaltracker/project'
5
+ require 'pivotaltracker/story'
6
+ require 'pivotaltracker/resource'
7
+ require 'faraday'
8
+
9
+ module PivotalTracker
10
+ NoProjectError = Class.new(StandardError) do
11
+ def initialize(project_id)
12
+ @project_id = project_id
13
+ end
14
+
15
+ def inspect
16
+ "No project with id #{@project_id}"
17
+ end
18
+ end
19
+ end
20
+
21
+ begin
22
+ require 'pry'
23
+ rescue LoadError
24
+ end
@@ -0,0 +1,23 @@
1
+ require 'pivotaltracker/api/configuration'
2
+ require 'pivotaltracker/api/client'
3
+ require 'pivotaltracker/api/host'
4
+
5
+ module PivotalTracker
6
+ class API
7
+ def self.configure
8
+ yield(configuration)
9
+ end
10
+
11
+ def self.reset!
12
+ @configuration = Configuration.new
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.build_client
20
+ @configuration.client.new(@configuration.token)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ module PivotalTracker
2
+ class API
3
+ class Client
4
+ def initialize(token, adapter=::Faraday)
5
+ @adapter = adapter
6
+ @token = token
7
+ end
8
+
9
+ def get(endpoint, id, options={})
10
+ endpoint_url = build_url(endpoint, id, options)
11
+ connection = @adapter.new(url: ::PivotalTracker::API::HOST)
12
+ response = connection.get(endpoint_url) { |req| req.headers['X-TrackerToken'] = @token }
13
+ response
14
+ end
15
+
16
+ private
17
+
18
+ def build_url(endpoint, id, options={})
19
+ parsed_endpoint = endpoint.gsub(/:project_id/, id.to_s)
20
+ "services/v5/#{parsed_endpoint}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ module PivotalTracker
2
+ class API
3
+ class Configuration
4
+ attr_accessor :token, :client
5
+
6
+ def initialize(client=PivotalTracker::API::Client)
7
+ @client = client
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module PivotalTracker
2
+ class API
3
+ HOST="https://www.pivotaltracker.com/"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module PivotalTracker
2
+ class Iteration
3
+ ITERATIONS_ENDPOINT= "/projects/:project_id/iterations"
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ require 'json'
2
+
3
+ module PivotalTracker
4
+ class Project
5
+ PROJECT_ENDPOINT = "projects/:project_id"
6
+
7
+ def self.find(id)
8
+ client = PivotalTracker::API.build_client
9
+ response = client.get(PROJECT_ENDPOINT, id)
10
+ raise NoProjectError.new(id) if response.status != 200
11
+ ::PivotalTracker::Resource::Project.new(::JSON.parse(response.body))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'pivotaltracker/resource/iteration'
2
+ require 'pivotaltracker/resource/project'
3
+ require 'pivotaltracker/resource/story'
4
+
5
+ module PivotalTracker
6
+ module Resource
7
+
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module PivotalTracker
2
+ module Resource
3
+ class Iteration
4
+ attr_reader :project_id
5
+
6
+ def initialize(data)
7
+ @project_id = data.fetch("project_id")
8
+ end
9
+
10
+ def project
11
+ ::PivotalTracker::Project.find(project_id)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ module PivotalTracker
2
+ module Resource
3
+ class Project
4
+ include Comparable
5
+
6
+ attr_reader :id
7
+
8
+ def initialize(data)
9
+ @id = data.fetch("id")
10
+ end
11
+
12
+ def stories
13
+ fetch(::PivotalTracker::Story::STORIES_ENDPOINT, ::PivotalTracker::Resource::Story)
14
+ end
15
+
16
+ def iterations
17
+ fetch(::PivotalTracker::Iteration::ITERATIONS_ENDPOINT, ::PivotalTracker::Resource::Iteration)
18
+ end
19
+
20
+ def <=>(another_project)
21
+ id <=> another_project.id
22
+ end
23
+
24
+ private
25
+
26
+ def fetch(endpoint, resource_klass)
27
+ client = PivotalTracker::API.build_client
28
+ response = client.get(endpoint, id)
29
+ raise NoProjectError.new(id) if response.status != 200
30
+ ::JSON.parse(response.body).map do |data|
31
+ resource_klass.new(data)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ module PivotalTracker
2
+ module Resource
3
+ class Story
4
+ def initialize(data)
5
+ @id = data.fetch("id")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module PivotalTracker
2
+ class Story
3
+ STORIES_ENDPOINT = "projects/:project_id/stories"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module PivotalTracker
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pivotaltracker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pivotaltracker"
8
+ spec.version = PivotalTracker::VERSION
9
+ spec.authors = ["Alvaro F. Lara"]
10
+ spec.email = ["alvaro.lara@alliants.com"]
11
+ spec.summary = %q{Pivotal Tracker API v.5 client.}
12
+ spec.description = %q{Pivotal Tracker API v.5 client.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "faraday", "~> 0.9.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "byebug"
25
+ spec.add_development_dependency "codeclimate-test-reporter"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "vcr"
29
+ spec.add_development_dependency "webmock"
30
+ end
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.pivotaltracker.com/services/v5/projects/367813
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ X-Trackertoken:
13
+ - ''
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Status:
28
+ - 200 OK
29
+ X-Tracker-Project-Version:
30
+ - '79039'
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 72e78b7a62b1802202a853340109cd68
37
+ X-Runtime:
38
+ - '0.052844'
39
+ Date:
40
+ - Wed, 25 Feb 2015 08:51:50 GMT
41
+ X-Rack-Cache:
42
+ - miss
43
+ X-Powered-By:
44
+ - Phusion Passenger 4.0.41
45
+ Server:
46
+ - nginx/1.6.0 + Phusion Passenger 4.0.41
47
+ Access-Control-Allow-Origin:
48
+ - "*"
49
+ Access-Control-Allow-Credentials:
50
+ - 'false'
51
+ Access-Control-Allow-Methods:
52
+ - GET, POST, PUT, DELETE, OPTIONS
53
+ Access-Control-Allow-Headers:
54
+ - X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is
55
+ X-Tracker-Client-Pinger-Interval:
56
+ - '8'
57
+ body:
58
+ encoding: ASCII-8BIT
59
+ string: '{"id":367813,"kind":"project","name":"Departments and policy (Dev)","version":79039,"iteration_length":2,"week_start_day":"Wednesday","point_scale":"0,1,2,3,5,8","point_scale_is_custom":false,"bugs_and_chores_are_estimatable":false,"automatic_planning":true,"enable_tasks":true,"time_zone":{"kind":"time_zone","olson_name":"Europe/London","offset":"+00:00"},"velocity_averaged_over":1,"number_of_done_iterations_to_show":12,"has_google_domain":false,"description":"The
60
+ \"departments and policy\" section of GOV.UK, including publishing tools for
61
+ government","enable_incoming_emails":true,"initial_velocity":25,"public":true,"atom_enabled":true,"start_date":"2011-09-14","start_time":"2011-09-13T23:00:00Z","created_at":"2011-09-11T19:50:57Z","updated_at":"2015-01-13T00:06:18Z","account_id":309645,"current_iteration_number":91,"enable_following":true}'
62
+ http_version:
63
+ recorded_at: Wed, 25 Feb 2015 08:51:50 GMT
64
+ recorded_with: VCR 2.9.3