gitlab_ci 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ class Gitlab::CI::Client
2
+ # Defines methods related to repositories.
3
+ # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/repositories.md
4
+ module Runners
5
+ # Used to get information about all runners registered on the GitLab CI instance.
6
+ #
7
+ # @example
8
+ # Gitlab::CI.runners
9
+ #
10
+ # @param [Hash] options A customizable set of options.
11
+ # @option options [Integer] :page The page number.
12
+ # @option options [Integer] :per_page The number of results per page.
13
+ # @return [Array<Gitlab::ObjectifiedHash>]
14
+ def runners(options={})
15
+ get("/runners", query: options)
16
+ end
17
+
18
+ # Used to make GitLab CI aware of available runners.
19
+ #
20
+ # @example
21
+ # Gitlab::CI.register_runner
22
+ #
23
+ # @param [Hash] options A customizable set of options.
24
+ # @option options [String] token (required) - The registration token. It is 2 types of token you can pass here.
25
+ # 1. Shared runner registration token
26
+ # 2. Project specific registration token
27
+ # @return [Array<Gitlab::ObjectifiedHash>]
28
+ def register_runner(token)
29
+ post("/runners/register", body: { token: token })
30
+ end
31
+
32
+ # Used to remove runners.
33
+ #
34
+ # @example
35
+ # Gitlab::CI.delete_runner
36
+ #
37
+ # @param [Hash] options A customizable set of options.
38
+ # @option options [String] token (required) - The runner token.
39
+ # @return [Array<Gitlab::ObjectifiedHash>]
40
+ def delete_runner(token)
41
+ delete("/runners/delete", body: { token: token })
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,94 @@
1
+ require 'gitlab/ci'
2
+ require 'gitlab/ci/cli_helpers'
3
+
4
+ module Gitlab::CI::Help
5
+ extend Gitlab::CI::CLI::Helpers
6
+
7
+ class << self
8
+ # Returns the (modified) help from the 'ri' command or returns an error.
9
+ #
10
+ # @return [String]
11
+ def get_help(cmd)
12
+ cmd_namespace = namespace cmd
13
+
14
+ if cmd_namespace
15
+ ri_output = `#{ri_cmd} -T #{cmd_namespace} 2>&1`.chomp
16
+
17
+ if $CHILD_STATUS == 0
18
+ change_help_output! cmd, ri_output
19
+ yield ri_output if block_given?
20
+
21
+ ri_output
22
+ else
23
+ "Ri docs not found for #{cmd}, please install the docs to use 'help'."
24
+ end
25
+ else
26
+ "Unknown command: #{cmd}."
27
+ end
28
+ end
29
+
30
+ # Finds the location of 'ri' on a system.
31
+ #
32
+ # @return [String]
33
+ def ri_cmd
34
+ which_ri = `which ri`.chomp
35
+ if which_ri.empty?
36
+ fail "'ri' tool not found in $PATH. Please install it to use the help."
37
+ end
38
+
39
+ which_ri
40
+ end
41
+
42
+ # A hash map that contains help topics (Branches, Groups, etc.)
43
+ # and a list of commands that are defined under a topic (create_branch,
44
+ # branches, protect_branch, etc.).
45
+ #
46
+ # @return [Hash<Array>]
47
+ def help_map
48
+ @help_map ||= begin
49
+ actions.each_with_object({}) do |action, hsh|
50
+ key = client.method(action).
51
+ owner.to_s.gsub(/Gitlab::CI::(?:Client::)?/, '')
52
+ hsh[key] ||= []
53
+ hsh[key] << action.to_s
54
+ end
55
+ end
56
+ end
57
+
58
+ # Table with available commands.
59
+ #
60
+ # @return [Terminal::Table]
61
+ def actions_table(topic=nil)
62
+ rows = topic ? help_map[topic] : help_map.keys
63
+ table do |t|
64
+ t.title = topic || "Help Topics"
65
+
66
+ # add_row expects an array and we have strings hence the map.
67
+ rows.sort.map { |r| [r] }.each_with_index do |row, index|
68
+ t.add_row row
69
+ t.add_separator unless rows.size - 1 == index
70
+ end
71
+ end
72
+ end
73
+
74
+ # Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd)
75
+ def namespace(cmd)
76
+ method_owners.select { |method| method[:name] === cmd }.
77
+ map { |method| method[:owner] + '.' + method[:name] }.
78
+ shift
79
+ end
80
+
81
+ # Massage output from 'ri'.
82
+ def change_help_output!(cmd, output_str)
83
+ output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
84
+ output_str.gsub!(/\,[\s]*/, ' ')
85
+
86
+ # Ensure @option descriptions are on a single line
87
+ output_str.gsub!(/\n\[/, " \[")
88
+ output_str.gsub!(/\s(@)/, "\n@")
89
+ output_str.gsub!(/(\])\n(\:)/, '\1 \2')
90
+ output_str.gsub!(/(\:.*)(\n)(.*\.)/, '\1 \3')
91
+
92
+ end
93
+ end # class << self
94
+ end
@@ -0,0 +1,4 @@
1
+ module GitlabCi
2
+ # gitlab_ci version
3
+ VERSION = "0.1.3"
4
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'gitlab_ci'
3
+
4
+ describe GitlabCi do
5
+ it "should have a VERSION constant" do
6
+ expect(subject.const_get('VERSION')).to_not be_empty
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec'
2
+ require 'gitlab_ci/version'
3
+
4
+ include GitlabCi
data/update.sh ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cd .
4
+ #. ~/.rvm/scripts/rvm
5
+ git add -A
6
+ git commit -m "$1"
7
+ git push
8
+ #bundle exec rake build
9
+ rake build
10
+ mv pkg/gitlab_ci-0.*.gem ../repo/gems/
11
+ cd ../repo
12
+ gem generate_index .
13
+ gcp hd-build
14
+
15
+ gsutil rsync -d -r ./ gs://gems.build.olt.homedepot.com/
16
+ gsutil acl ch -r -u All:READ gs://gems.build.olt.homedepot.com
17
+
18
+ cd -
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitlab_ci
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Christo De Lange
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gitlab
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.6'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.6.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.6'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.6.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.10'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.10'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubygems-tasks
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.2'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.2'
89
+ description: Gitlab is a Ruby wrapper and CLI for the [GitLab-CI API](https://gitlab.com/gitlab-org/gitlab-ee/tree/master/doc/ci/api).
90
+ email: rubygems@dldinternet.com
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - ".rakeTasks"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - ChangeLog.md
100
+ - Gemfile
101
+ - Gemfile.lock
102
+ - LICENSE
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - gitlab_ci.gemspec
107
+ - lib/gitlab/ci.rb
108
+ - lib/gitlab/ci/cli.rb
109
+ - lib/gitlab/ci/cli_helpers.rb
110
+ - lib/gitlab/ci/client.rb
111
+ - lib/gitlab/ci/client/builds.rb
112
+ - lib/gitlab/ci/client/commits.rb
113
+ - lib/gitlab/ci/client/projects.rb
114
+ - lib/gitlab/ci/client/runners.rb
115
+ - lib/gitlab/ci/help.rb
116
+ - lib/gitlab/ci/version.rb
117
+ - spec/gitlab_ci_spec.rb
118
+ - spec/spec_helper.rb
119
+ - update.sh
120
+ homepage: http://github.com/dldinternet/gitlab_ci
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.4.8
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Gitlab is a Ruby wrapper and CLI for the GitLab API
144
+ test_files:
145
+ - spec/gitlab_ci_spec.rb
146
+ - spec/spec_helper.rb