semaphore_api 0.1.0

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: c52fce9266d2c6df953de18a1e8849bfb2c7543a
4
+ data.tar.gz: 0cf305fe9ca686e7e9f74552e1c2848065872773
5
+ SHA512:
6
+ metadata.gz: b139a8ecb5866a77f2ad2a7c15e685cf9362bf73c502bf2a5493f2b86b31bf7d461ee02ec9c330d2a314d3090d43c8ea85b6f78f311fbfb62b55863560c48340
7
+ data.tar.gz: 215c4adbcb9000d423f59bbb973db3c83e173e6fd81f3f1e3fb04efc1d55e3fd4d6ed3cec1c76be7f27f1eff10b01a8a58879f50cfc7a9a1137c25970d2db270
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in semaphore_api.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # SemaphoreApi
2
+
3
+ Unofficial Ruby wrapper around Semaphore's API
4
+
5
+ ![SemaphoreCI](http://fc04.deviantart.net/fs71/f/2013/081/4/d/futurama__zoidberg__banner_by_daspoony-d5yvo0t.jpg)
6
+
7
+ ## Usage
8
+
9
+ Start by contructing a client
10
+
11
+ ``` rb
12
+ semaphore = SemaphoreApi::Client.new("AUTH_TOKEN")
13
+ ```
14
+
15
+ List your projects on Semaphore
16
+
17
+ ``` rb
18
+ projects = semaphore.projects
19
+ ```
20
+
21
+ Display their names
22
+
23
+ ``` rb
24
+ puts projects.map(&:name)
25
+ ```
26
+
27
+ Find projects via their name
28
+
29
+ ``` rb
30
+ sempahore_api = projects.find { |project| project.name == "semaphore_api" }
31
+ ```
32
+
33
+ Display active branches for a project
34
+
35
+ ``` rb
36
+ semaphore_api.branches.map(&:branch_name) # => ["master", "development"]
37
+ ```
38
+
39
+ List all the webhooks for a project
40
+
41
+ ``` rb
42
+ webhooks = client.webhooks(semaphore_api.hash_id)
43
+ ```
44
+
45
+ Collect information about a build
46
+
47
+ ``` rb
48
+ master = semaphore_api.branches.find { |branch| branch.name == "master" }
49
+
50
+ build = client.build_status(semaphore_api.hash_id, master.branch_id)
51
+ ```
52
+
53
+ ## Development
54
+
55
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
56
+
57
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
58
+
59
+ ## Installation
60
+
61
+ Add this line to your application's Gemfile:
62
+
63
+ ```ruby
64
+ gem 'semaphore_api'
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/shiroyasha/semaphore_api/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "semaphore_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ module SemaphoreApi
2
+ class Client
3
+ module Branches
4
+
5
+ def branches(project_hash_id)
6
+ get "/projects/#{project_hash_id}/branches"
7
+ end
8
+
9
+ def branch_status(project_hash_id, branch_id)
10
+ get "/projects/#{project_hash_id}/#{branch_id}/status"
11
+ end
12
+
13
+ def branch_history(project_hash_id, branch_id)
14
+ get "/projects/#{project_hash_id}/#{branch_id}"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module SemaphoreApi
2
+ class Client
3
+ module Builds
4
+
5
+ def build(project_hash_id, branch_id, build_number)
6
+ get "/projects/#{project_hash_id}/#{branch_id}/builds/#{build_number}"
7
+ end
8
+
9
+ def build_log(project_hash_id, branch_id, build_number)
10
+ get "/projects/#{project_hash_id}/#{branch_id}/builds/#{build_number}/log"
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module SemaphoreApi
2
+ class Client
3
+ module Deploys
4
+
5
+ def deploy(project_hash_id, server_id, depoy_number)
6
+ get "/projects/#{project_hash_id}/servers/#{server_id}/deploys/#{deploy_number}"
7
+ end
8
+
9
+ def deploy_log(project_hash_id, server_id, depoy_number)
10
+ get "/projects/#{project_hash_id}/servers/#{server_id}/deploys/#{deploy_number}/log"
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module SemaphoreApi
2
+ class Client
3
+ module Projects
4
+
5
+ def projects
6
+ get "/projects"
7
+ end
8
+
9
+ def project(project_hash_id)
10
+ projects.find { |project| project.hash_id == project_hash_id }
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module SemaphoreApi
2
+ class Client
3
+ module Servers
4
+
5
+ def servers(project_hash_id)
6
+ get "/projects/#{project_hash_id}/servers"
7
+ end
8
+
9
+ def server_status(project_hash_id, server_id)
10
+ get "/projects/#{project_hash_id}/servers/#{server_id}/status"
11
+ end
12
+
13
+ def server_history(project_hash_id, server_id)
14
+ get "/projects/#{project_hash_id}/servers/#{server_id}"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module SemaphoreApi
2
+ class Client
3
+ module WebHooks
4
+
5
+ def webhooks(project_hash_id)
6
+ get "/projects/#{project_hash_id}/hooks"
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,43 @@
1
+ require "zoid"
2
+
3
+ require "semaphore_api/client/projects"
4
+ require "semaphore_api/client/branches"
5
+ require "semaphore_api/client/webhooks"
6
+ require "semaphore_api/client/builds"
7
+ require "semaphore_api/client/servers"
8
+ require "semaphore_api/client/deploys"
9
+
10
+ module SemaphoreApi
11
+ class Client
12
+ include SemaphoreApi::Client::Projects
13
+ include SemaphoreApi::Client::Branches
14
+ include SemaphoreApi::Client::WebHooks
15
+ include SemaphoreApi::Client::Builds
16
+ include SemaphoreApi::Client::Servers
17
+ include SemaphoreApi::Client::Deploys
18
+
19
+ def initialize(auth_token, end_point=nil)
20
+ @auth_token = auth_token
21
+ @end_point = end_point
22
+ end
23
+
24
+ def get(path, options = {})
25
+ response = agent.get("/api/v1/#{path}", {:auth_token => @auth_token})
26
+
27
+ response.body
28
+ end
29
+
30
+ def agent
31
+ @agent ||= Zoid::Agent.new(end_point)
32
+ end
33
+
34
+ def end_point
35
+ @end_point || "https://semaphoreci.com"
36
+ end
37
+
38
+ # hide auth_token
39
+ def inspect
40
+ super.gsub! @auth_token, "*******"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module SemaphoreApi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "semaphore_api/version"
2
+
3
+ module SemaphoreApi
4
+ require "semaphore_api/client"
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'semaphore_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "semaphore_api"
8
+ spec.version = SemaphoreApi::VERSION
9
+ spec.authors = ["Igor Sarcevic"]
10
+ spec.email = ["igisar@gmail.com"]
11
+ spec.license = "MIT"
12
+
13
+ spec.summary = %q{Unofficial wrapper around SemaphoreCI's API}
14
+ spec.homepage = "https://github.com/shiroyasha/semaphore_api"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "zoid", "~> 0.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.3"
26
+ spec.add_development_dependency "byebug", "~> 5.0"
27
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: semaphore_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Igor Sarcevic
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description:
84
+ email:
85
+ - igisar@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - lib/semaphore_api.rb
98
+ - lib/semaphore_api/client.rb
99
+ - lib/semaphore_api/client/branches.rb
100
+ - lib/semaphore_api/client/builds.rb
101
+ - lib/semaphore_api/client/deploys.rb
102
+ - lib/semaphore_api/client/projects.rb
103
+ - lib/semaphore_api/client/servers.rb
104
+ - lib/semaphore_api/client/webhooks.rb
105
+ - lib/semaphore_api/version.rb
106
+ - semaphore_api.gemspec
107
+ homepage: https://github.com/shiroyasha/semaphore_api
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Unofficial wrapper around SemaphoreCI's API
131
+ test_files: []