bitrise-client 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ba17bd32401a009fcfce53e1aea475ab478fcb3409facfe3f5ea60a1473b4703
4
+ data.tar.gz: e3cefe0df76ca123b9978ac4935cad2df085f78e421c801507b367facefc7f83
5
+ SHA512:
6
+ metadata.gz: f9a93ee147c25b5fa3951691f262dd826dbc4c7bb8897ca581d654196dc563b0c8ff47544c489eb38acaa9fbfeed8f2a0cbd5e13947d6b225e9ff980b6a2a4cf
7
+ data.tar.gz: 9bbff68c08ae6ee968560a17be4f258c24b4946271274eed9439862472d72d37bb6013d7d90b848be1995d735994fddef98d739d61018558cb7b9413940b813b
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/
10
+ /Gemfile.lock
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,8 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.0
7
+ script:
8
+ - bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bitrise-client.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Takuma Homma
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # Bitrise::Client
2
+
3
+ A ruby client for [Bitrise API](https://devcenter.bitrise.io/#bitrise-api).
4
+
5
+ Now supports [Build Trigger API](https://devcenter.bitrise.io/api/build-trigger/) only.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bitrise-client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bitrise-client
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'bitrise'
27
+
28
+ client = Bitrise::Client.new
29
+ client.trigger_build(
30
+ app_slug = 'your_app_slug', # required
31
+ build_trigger_token = 'your_build_trigger_token', # required
32
+ build_params: {
33
+ # A tag, branch or workflow_id parameter required
34
+ branch: 'branch',
35
+ tag: 'tag',
36
+ workflow_id: 'workflow_id'
37
+ }
38
+ )
39
+ ```
40
+
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bitrise/client"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bitrise/client/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitrise-client"
8
+ spec.version = Bitrise::Client::VERSION
9
+ spec.authors = ["mataku"]
10
+ spec.email = ["nagomimatcha@gmail.com"]
11
+
12
+ spec.summary = %q{A ruby clent for Bitrise API}
13
+ spec.description = %q{A ruby client for Bitrise API}
14
+ spec.homepage = "https://github.com/mataku/bitrise-client"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/mataku/bitrise-client"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_runtime_dependency 'faraday', '~> 0.9'
39
+
40
+ spec.add_development_dependency "bundler"
41
+ spec.add_development_dependency "irb"
42
+ spec.add_development_dependency "rake"
43
+ spec.add_development_dependency "rspec"
44
+ end
@@ -0,0 +1 @@
1
+ require 'bitrise/client'
@@ -0,0 +1,25 @@
1
+ require 'bitrise/client/build'
2
+ require 'faraday'
3
+
4
+ module Bitrise
5
+ class Client
6
+ include Bitrise::Client::Build
7
+
8
+ def initialize(options = {})
9
+ @api_host = options[:host] || 'https://app.bitrise.io'
10
+ @timeout = options[:timeout] || 30
11
+ @open_timeout = options[:open_timeout] || 30
12
+ end
13
+
14
+ def client
15
+ @client ||= Faraday.new(url: @api_host) do |faraday|
16
+ faraday.options.timeout = @timeout
17
+ faraday.options.open_timeout = @open_timeout
18
+ faraday.options.params_encoder = Faraday::FlatParamsEncoder
19
+ faraday.response :logger if ENV['DEBUG']
20
+
21
+ faraday.adapter Faraday.default_adapter
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,44 @@
1
+ require 'json'
2
+
3
+ module Bitrise
4
+ class Client
5
+ module Build
6
+
7
+ # Trigger a build of your bitrise app
8
+ #
9
+ # @param app_slug [String] Your bitrise app slug
10
+ # @param build_trigger_token [String] Build Trigger token of your app
11
+ #
12
+ # See: https://devcenter.bitrise.io/api/build-trigger/
13
+ def trigger_build(app_slug = nil, build_trigger_token = nil, options = {})
14
+ @app_slug = app_slug || raise('App slug required.')
15
+ @build_trigger_token = build_trigger_token || raise('Build trigger token required.')
16
+
17
+ response = client.post do |request|
18
+ request.url "/app/#{@app_slug}/build/start.json"
19
+ request.headers['Content-Type'] = 'application/json'
20
+ request.body = {
21
+ hook_info: {
22
+ type: 'bitrise',
23
+ build_trigger_token: @build_trigger_token
24
+ },
25
+ build_params: options[:build_params]
26
+ }.to_json
27
+ end
28
+
29
+ check_http_status(response)
30
+
31
+ JSON.parse(response.body)
32
+ end
33
+
34
+ def check_http_status(response)
35
+ case response.status
36
+ when 200..299 then
37
+ return
38
+ else
39
+ raise JSON.parse(response.body)['message']
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Bitrise
2
+ class Client
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bitrise-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mataku
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
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: irb
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: rake
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: A ruby client for Bitrise API
84
+ email:
85
+ - nagomimatcha@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - bitrise-client.gemspec
100
+ - lib/bitrise.rb
101
+ - lib/bitrise/client.rb
102
+ - lib/bitrise/client/build.rb
103
+ - lib/bitrise/client/version.rb
104
+ homepage: https://github.com/mataku/bitrise-client
105
+ licenses:
106
+ - MIT
107
+ metadata:
108
+ homepage_uri: https://github.com/mataku/bitrise-client
109
+ source_code_uri: https://github.com/mataku/bitrise-client
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubygems_version: 3.0.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: A ruby clent for Bitrise API
129
+ test_files: []