deployment-tracker-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee3443749ac5fc7299f335f7bae763b9b836fb6c
4
+ data.tar.gz: ed9d05c3273fa078bf64cf9e4cf0d1de776f947a
5
+ SHA512:
6
+ metadata.gz: 1f095e9beb7dbfbce8a4d60e19e2f6e7170b8d520391e0a778eac6e3cf5588202e6e05eab57bfa9399493411f56ed2aa678fa0f1c2601a38f51929bdb731b989
7
+ data.tar.gz: d0a215625f27768d47ac861269d01d2a89ff9b86001d7e65c324acf7124fd0d2334c0e14f6bcf2f599793da9441364ba7965bbd2a9a703bb75327133803bf154
data/.gitignore ADDED
@@ -0,0 +1,14 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in deployment-tracker-client.rb.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2015 Cimpress
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # deployment-tracker-client.rb
2
+
3
+ Ruby API Client for [deployment-tracker](https://github.com/Cimpress-MCP/deployment-tracker)
4
+
5
+ This repo will run swagger code generation on an instance of the deployment-tracker running
6
+ locally and then transform the code a bit to make it readily distributable as a gem. There
7
+ appear to be a number of bugs in the swagger codegen ruby generator that have been plastered
8
+ over with a bunch of ugly `gsub!`s in the Rakefile.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'deployment-tracker-client'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install deployment-tracker-client
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require "deployment-tracker-client"
30
+ require "SecureRandom"
31
+ require "pp"
32
+
33
+ SwaggerClient::Swagger.configure do |config|
34
+ config.host = "http://127.0.0.1:8080"
35
+ end
36
+
37
+ api = DeploymentTrackerClient::DefaultApi
38
+ pp api.get_deployments(0, 3) # Print the 3 most recent deployments
39
+
40
+ id = SecureRandom.uuid
41
+ host = `hostname`.chomp
42
+ user = `whoami`.chomp
43
+ deployment = DeploymentTrackerClient::Deployment.new({
44
+ deployment_id: id,
45
+ engine: "deployment_tracker_test_suite",
46
+ engine_version: DeploymentTrackerClient::VERSION,
47
+ user: user,
48
+ host: host,
49
+ environment: "dev",
50
+ package: "my_package",
51
+ version: "1.2.3"
52
+ })
53
+ puts "POSTING DEPLOYMENT #{id}"
54
+ api.post_deployment id, deployment
55
+ pp api.get_deployment id
56
+ ```
57
+
58
+ ## Vesioning
59
+ This ruby client library major.minor version will be API compatible with the
60
+ same major, minor pair of the deployment-tracker service. Older clients will
61
+ remain backward compatible within major releases, but aren't guaranteed to be
62
+ forward compatible. This means that the 0.6.x version of this library should work
63
+ with any version of the service greater than 0.6 but less than 1.0
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/Cimpress-MCP/deployment-tracker-client.rb/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/clean"
3
+
4
+ CLEAN.include("lib/deployment-tracker-client/api", "lib/deployment-tracker-client/models", "lib/swagger_client", "lib/swagger_client.rb")
5
+
6
+ task default: :build
7
+
8
+ desc "Generate swagger codegen code"
9
+ task :gen do
10
+ unless ENV.key?("SWAGGER_CODEGEN_JAR") && File.exist?(ENV["SWAGGER_CODEGEN_JAR"])
11
+ fail "Unable to locate SWAGGER_CODEGEN_JAR at #{ENV['SWAGGER_CODEGEN_JAR']}. \
12
+ Build it from https://github.com/swagger-api/swagger-codegen and set the SWAGGER_CODEGEN_JAR environment variable."
13
+ end
14
+ system("java -jar #{ENV['SWAGGER_CODEGEN_JAR']} generate -i http://127.0.0.1:8080 -l ruby -o . -c codegen_conf.json")
15
+
16
+ # Delete the swagger_client.gemspec, we don't need it
17
+ File.delete("swagger_client.gemspec")
18
+
19
+ %w(api models).each do |dir|
20
+ # Copy folder into the deployment-tracker-client directory
21
+ FileUtils.mv("./lib/swagger_client/#{dir}", "./lib/deployment-tracker-client/#{dir}", force: true)
22
+ Dir.foreach("./lib/deployment-tracker-client/#{dir}") do |file|
23
+ file = File.join("./lib/deployment-tracker-client/#{dir}", file)
24
+ next unless File.file?(file)
25
+ contents = File.read(file)
26
+ contents.gsub!("module SwaggerClient", "module DeploymentTrackerClient")
27
+ contents.gsub!(" Swagger::", "SwaggerClient::Swagger::")
28
+ contents.gsub!("SwaggerClient.const_get", "DeploymentTrackerClient.const_get")
29
+ File.open(file, "w") do |f|
30
+ f.write(contents)
31
+ end
32
+ end
33
+ end
34
+
35
+ # Needs to be require_relative
36
+ contents = File.read("./lib/swagger_client.rb")
37
+ contents.gsub!("require ", "require_relative ")
38
+ contents.gsub!(/# Models.*?module SwaggerClient/m, "module SwaggerClient")
39
+ File.open("./lib/swagger_client.rb", "w") do |f|
40
+ f.write(contents)
41
+ end
42
+
43
+ # Remove empty case statement.
44
+ contents = File.read("./lib/swagger_client/swagger/request.rb")
45
+ contents.gsub!(/case auth_name.*?end/m, "")
46
+ File.open("./lib/swagger_client/swagger/request.rb", "w") do |f|
47
+ f.write(contents)
48
+ end
49
+ end
data/codegen_conf.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "modelPackage":"deployment-tracker-client",
3
+ "apiPackage":"deployment-tracker-client"
4
+ }
@@ -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 "deployment-tracker-client/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "deployment-tracker-client"
8
+ spec.version = DeploymentTrackerClient::VERSION
9
+ spec.authors = ["Cimpress MCP Infrastructure"]
10
+ spec.email = ["mcp_infrastructure@cimpress.com"]
11
+ spec.summary = "Ruby API client for deployment-tracker"
12
+ spec.homepage = "https://github.com/Cimpress-MCP/deployment-tracker-client.rb"
13
+ spec.license = "Apache 2"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ # These were stolen from the swagger_client generated gemspec
21
+ spec.add_runtime_dependency "typhoeus", "~> 0.2", ">= 0.2.1"
22
+ spec.add_runtime_dependency "addressable", "~> 2.2", ">= 2.2.4"
23
+ spec.add_runtime_dependency "json", "~> 1.4", ">= 1.4.6"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
data/examples/basic.rb ADDED
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "deployment-tracker-client"
4
+ require "SecureRandom"
5
+ require "pp"
6
+
7
+ SwaggerClient::Swagger.configure do |config|
8
+ config.host = "http://127.0.0.1:8080"
9
+ end
10
+
11
+ api = DeploymentTrackerClient::DefaultApi
12
+ pp api.get_deployments(0, 3)
13
+
14
+ id = SecureRandom.uuid
15
+ host = `hostname`.chomp
16
+ user = `whoami`.chomp
17
+ deployment = DeploymentTrackerClient::Deployment.new(deployment_id: id,
18
+ engine: "deployment_tracker_test_suite",
19
+ engine_version: DeploymentTrackerClient::VERSION,
20
+ user: user,
21
+ host: host,
22
+ environment: "dev",
23
+ package: "my_package",
24
+ version: "1.2.3")
25
+ puts "POSTING DEPLOYMENT #{id}"
26
+ api.post_deployment id, deployment
27
+ pp api.get_deployment id