ShipIO 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88bf98e62dbfb80204cf20f81077870be3b92fbc
4
+ data.tar.gz: 7a933df22a502d566a1ad25fb8eb28f4dbee7ee8
5
+ SHA512:
6
+ metadata.gz: 818b7e95c83e7d2520ec8b09ef4ef8285b1f1d2710f3a76711660ba312d1a814caefb6f37a586f5fc49e63ac46f5cb2ae5970f9b87d80a8a5fd629ccd61dff12
7
+ data.tar.gz: 534700c57515b85aa64af5965d858ccf0a678919414b88dfad4abc4f1ce04c56fa4d8532b8615517d443964ce79d2063e4cc47e62784a10c80dd664c38846b01
@@ -0,0 +1,24 @@
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
23
+ .idea
24
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ShipIO.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andrew Page
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,11 @@
1
+ # ShipIO
2
+
3
+ The Ship.io API Ruby Wrapper.
4
+
5
+ # Installation
6
+ ```bash
7
+ gem install shipio
8
+ ```
9
+
10
+ # Support
11
+ Email me at andrew@ship.io
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ShipIO/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ShipIO"
8
+ spec.version = ShipIO::VERSION
9
+ spec.authors = ["Andrew Page"]
10
+ spec.email = ["andrew@andrewpage.me"]
11
+ spec.summary = "Ship.IO API Wrapper"
12
+ spec.description = "Ship.IO API Wrapper"
13
+ spec.homepage = "http://www.ship.io"
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 "rest_client"
24
+ spec.add_development_dependency "json"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,10 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+ require 'ShipIO/models/job'
4
+ require 'ShipIO/models/build'
5
+ require 'ShipIO/version'
6
+ require 'ShipIO/client'
7
+
8
+ module ShipIO
9
+ BASE_URL = "https://ship.io"
10
+ end
@@ -0,0 +1,78 @@
1
+ module ShipIO
2
+ class Client
3
+ attr_accessor :api_key
4
+
5
+ def initialize(api_key, options={})
6
+ @api_key = api_key
7
+ end
8
+
9
+ # Returns all the jobs in the user account
10
+ def jobs
11
+ result = get("jobs.json")
12
+ jobs = []
13
+ for json_job in result do
14
+ job = Job.new(self, {
15
+ uuid: json_job["id"],
16
+ name: json_job["name"],
17
+ repository_name: json_job["repository"]["name"],
18
+ repository_branch: json_job["repository"]["selected_branch"],
19
+ repository_url: json_job["repository"]["html_url"]
20
+ })
21
+ jobs << job
22
+ end
23
+ jobs
24
+ end
25
+
26
+ # Returns a build from a Job
27
+ def build(job, build_id)
28
+ json_build = get("jobs/#{job.uuid}/builds/#{build_id}.json")
29
+
30
+ Build.new({
31
+ uuid: json_build["id"],
32
+ build_number: json_build["build_number"],
33
+ commit_sha: json_build["commit_sha"],
34
+ state: json_build["state"],
35
+ log_url: json_build["log_url"],
36
+ successful: json_build["successful"]
37
+ })
38
+ end
39
+
40
+ # Returns all the builds by a User
41
+ def builds(job)
42
+ response = get("jobs/#{job.uuid}/builds.json")
43
+ builds = []
44
+ for json_build in response do
45
+ build = Build.new({
46
+ uuid: json_build["id"],
47
+ build_number: json_build["build_number"],
48
+ commit_sha: json_build["commit_sha"],
49
+ state: json_build["state"],
50
+ log_url: json_build["log_url"],
51
+ successful: json_build["successful"]
52
+ })
53
+ builds << build
54
+ end
55
+ builds
56
+ end
57
+
58
+ # Gets the Pusher channel for a user
59
+ def pusher_channel
60
+ get("user/channel.json")
61
+ end
62
+
63
+ private
64
+ def get(url, params={})
65
+ url = '/' + url if url[0] != '/'
66
+ url = ShipIO::BASE_URL + url
67
+ result = RestClient.get url, {"Authorization" => "Bearer #{api_key}"}
68
+ JSON.parse(result)
69
+ end
70
+
71
+ def post(url, params={})
72
+ url = '/' + url if url[0] != '/'
73
+ url = ShipIO::BASE_URL + url
74
+ result = RestClient.post url, {"Authorization" => "Bearer #{api_key}"}
75
+ JSON.parse(result)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,14 @@
1
+ module ShipIO
2
+ class Build
3
+ attr_accessor :uuid, :build_number, :commit_sha, :state, :successful, :log_url
4
+
5
+ def initialize(options = {})
6
+ @uuid = options[:uuid]
7
+ @build_number = options[:build_number]
8
+ @commit_sha = options[:commit_sha]
9
+ @state = options[:state]
10
+ @successful = options[:successful]
11
+ @log_url = options[:log_url]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module ShipIO
2
+ class Job
3
+ attr_accessor :uuid, :name, :repository_name, :repository_branch, :repository_url
4
+ attr_reader :client
5
+
6
+ def initialize(client, options = {})
7
+ @client = client
8
+
9
+ @uuid = options[:uuid]
10
+ @name = options[:name]
11
+ @repository_name = options[:repository_name]
12
+ @repository_branch = options[:repository_branch]
13
+ @repository_url = options[:repository_url]
14
+ end
15
+
16
+ def builds
17
+ @client.builds(self)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module ShipIO
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe ShipIO::Client do
4
+ before :each do
5
+ @client = ShipIO::Client.new("8g5ruq2s6fqi5f2b0o5r649ipspicqou7")
6
+ end
7
+
8
+ describe "initializing a client" do
9
+ it "should have a base URL of ship.io" do
10
+ expect(ShipIO::BASE_URL).to eq("https://ship.io")
11
+ end
12
+ end
13
+
14
+ describe "using the client" do
15
+ it "should list the jobs" do
16
+ jobs = @client.jobs
17
+
18
+ expect(jobs.count).to be > 0
19
+ end
20
+
21
+ it "should return a pusher channel" do
22
+ response = @client.pusher_channel
23
+
24
+ expect(response["pusher_key"]).to_not be_nil
25
+ expect(response["name"]).to_not be_nil
26
+ end
27
+
28
+ it "should return a list of builds for a job" do
29
+ job = @client.jobs.first
30
+ builds = job.builds
31
+
32
+ expect(builds.count).to be > 0
33
+ end
34
+
35
+ it "should return an individual build based off a build id" do
36
+ job = @client.jobs.first
37
+ uuid = job.builds.first.uuid
38
+
39
+ build = @client.build(job, uuid)
40
+
41
+ expect(build.uuid).to_not be_nil
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ require 'ShipIO'
3
+
4
+ Bundler.setup
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ShipIO
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Page
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-09 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: rest_client
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: json
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Ship.IO API Wrapper
84
+ email:
85
+ - andrew@andrewpage.me
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".idea/.name"
92
+ - ".idea/.rakeTasks"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - ShipIO.gemspec
98
+ - lib/ShipIO.rb
99
+ - lib/ShipIO/client.rb
100
+ - lib/ShipIO/models/build.rb
101
+ - lib/ShipIO/models/job.rb
102
+ - lib/ShipIO/version.rb
103
+ - spec/shipio/client_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: http://www.ship.io
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Ship.IO API Wrapper
129
+ test_files:
130
+ - spec/shipio/client_spec.rb
131
+ - spec/spec_helper.rb