ticketlocker-ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/ticketlocker.rb +20 -0
- data/lib/ticketlocker/client.rb +46 -0
- data/lib/ticketlocker/ticket.rb +22 -0
- data/lib/ticketlocker/ticket_collection.rb +29 -0
- data/lib/ticketlocker/version.rb +4 -0
- data/ticketlocker-ruby.gemspec +31 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c101c560fe421232d9ec59bd08c9fe86f3995b2e
|
4
|
+
data.tar.gz: aa024e0390c762885fe983278f001d390740398b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a768aef3a1cb655e4eda092154f5e0b60f76e605d7ce4565dbf5ec93234a0657bfbc143f8225e3f763fad1d334c0d300d9854e65b731ae1222880d32de349c6
|
7
|
+
data.tar.gz: 075b119a70215a5cbd7087238a78e246f4c3db7c59615522f3ac63d7f4a3549cbf69f8d236bdb6cba1deec06743ce73b73297f2d8a510e6c854291ae48cbeedd
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Michael Stock
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Ticketlocker::Ruby
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ticketlocker-ruby'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ticketlocker-ruby
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/ticketlocker-ruby/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/ticketlocker.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "ticketlocker/client"
|
2
|
+
require "ticketlocker/ticket"
|
3
|
+
require "ticketlocker/ticket_collection"
|
4
|
+
require "ticketlocker/version"
|
5
|
+
require "active_support/inflector"
|
6
|
+
|
7
|
+
require "pry"
|
8
|
+
|
9
|
+
module Ticketlocker
|
10
|
+
class << self
|
11
|
+
attr_accessor :client, :api_key, :connection
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.setup
|
15
|
+
self.client = Ticketlocker::Client.new(token: api_key || "58990f3c290da63b95513fee9b0b526f",
|
16
|
+
base_url: "http://localhost:3000")
|
17
|
+
self.connection = client.conn
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module Ticketlocker
|
6
|
+
class Client
|
7
|
+
attr_reader :conn
|
8
|
+
|
9
|
+
def initialize(args)
|
10
|
+
@token = args[:token]
|
11
|
+
@base_url = args.fetch(:base_url, 'http://ticketocker.io/api')
|
12
|
+
@conn = Faraday.new(url: base_url) do |faraday|
|
13
|
+
faraday.request :json
|
14
|
+
|
15
|
+
faraday.response :mashify
|
16
|
+
faraday.response :json
|
17
|
+
faraday.response :logger
|
18
|
+
|
19
|
+
faraday.token_auth @token
|
20
|
+
faraday.headers['User-Agent'] = "ticketlocker-ruby/#{Ticketlocker::VERSION}"
|
21
|
+
|
22
|
+
faraday.adapter Faraday.default_adapter
|
23
|
+
end
|
24
|
+
|
25
|
+
if valid?
|
26
|
+
return
|
27
|
+
else
|
28
|
+
raise Ticketlocker::Ruby::BadTokenError
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate
|
33
|
+
response = conn.get('/api/validate')
|
34
|
+
response.success?
|
35
|
+
end
|
36
|
+
|
37
|
+
alias :valid? :validate
|
38
|
+
|
39
|
+
private
|
40
|
+
attr_reader :token, :base_url
|
41
|
+
end
|
42
|
+
|
43
|
+
class Error < StandardError; end
|
44
|
+
class BadTokenError < Error; end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "virtus"
|
2
|
+
|
3
|
+
module Ticketlocker
|
4
|
+
class Ticket
|
5
|
+
include Virtus.model
|
6
|
+
|
7
|
+
attribute :id, Integer
|
8
|
+
attribute :title, String
|
9
|
+
attribute :description, String
|
10
|
+
attribute :engineer_estimate, Integer
|
11
|
+
attribute :name, String
|
12
|
+
|
13
|
+
def self.build
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.all
|
18
|
+
TicketCollection.retrieve
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ticketlocker
|
2
|
+
class TicketCollection
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :@tickets, :[]
|
6
|
+
|
7
|
+
def find(id)
|
8
|
+
tickets.detect { |ticket| ticket.id == id }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve
|
12
|
+
response = Ticketlocker.connection.get('/api/tickets')
|
13
|
+
if response.status == 200
|
14
|
+
tickets = response.body
|
15
|
+
else
|
16
|
+
"It's broken"
|
17
|
+
end
|
18
|
+
new(tickets)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
attr_reader :tickets
|
23
|
+
|
24
|
+
def initialize(tickets)
|
25
|
+
@tickets = tickets.map { |ticket| Ticket.new(ticket) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ticketlocker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ticketlocker-ruby"
|
8
|
+
spec.version = Ticketlocker::VERSION
|
9
|
+
spec.authors = ["Michael Stock"]
|
10
|
+
spec.email = ["mikeastock@gmail.com"]
|
11
|
+
spec.summary = %q{Ticketloker API wrapper gem}
|
12
|
+
spec.description = %q{A ruby wrapper around the Ticketlocker API}
|
13
|
+
spec.homepage = "http://github.com/mikeastock/ticketlocker-ruby"
|
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_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "pry-byebug"
|
25
|
+
spec.add_dependency "faraday"
|
26
|
+
spec.add_dependency "faraday_middleware"
|
27
|
+
spec.add_dependency "hashie"
|
28
|
+
spec.add_dependency "activesupport"
|
29
|
+
spec.add_dependency "virtus"
|
30
|
+
end
|
31
|
+
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ticketlocker-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Stock
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday_middleware
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: hashie
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: virtus
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: A ruby wrapper around the Ticketlocker API
|
140
|
+
email:
|
141
|
+
- mikeastock@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- .gitignore
|
147
|
+
- Gemfile
|
148
|
+
- LICENSE.txt
|
149
|
+
- README.md
|
150
|
+
- Rakefile
|
151
|
+
- lib/ticketlocker.rb
|
152
|
+
- lib/ticketlocker/client.rb
|
153
|
+
- lib/ticketlocker/ticket.rb
|
154
|
+
- lib/ticketlocker/ticket_collection.rb
|
155
|
+
- lib/ticketlocker/version.rb
|
156
|
+
- ticketlocker-ruby.gemspec
|
157
|
+
homepage: http://github.com/mikeastock/ticketlocker-ruby
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.0.3
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: Ticketloker API wrapper gem
|
181
|
+
test_files: []
|