peoplegroup-connectors 0.1.3 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb962e9d43875bb0a19ac206165c335097c6147148d23944a4479e97460613f3
4
- data.tar.gz: 521103c3b8289e98752fb6a06f125ed8db47ef5d160030032b00ab478263498d
3
+ metadata.gz: 800a61edd755dd71ab5990d2f53df313a78c42cfac1cc6be206dd9e0f1555cb7
4
+ data.tar.gz: f8213430bfa0fe919aa8e1fcb229d0655ca9514d8827b3c304ff4dbc6047c59a
5
5
  SHA512:
6
- metadata.gz: d52daa4d4fddc9a989dc41e601d208167c6a27c36d1c2a0ba09b164c25a9eb829486bae15f09a64bb6c670f57ea803fc37e25966410761f2fefe11b165206700
7
- data.tar.gz: 472b1e602fb9ae87b5b25fb6987e4d625a31b2b668c24429ab850adc06314980a7dbd8533f518104d475a554df9fe94b16ac87e365247137636acba14dbcf432
6
+ metadata.gz: d9eebb60b4bc441afdfa164a7c911bb58f48e47358ada3fe75595f5cb9102f2d50f0f5f9b8ce164d89aaf8aff8527720950de02075e16b3b62a0ccf2039dc8be
7
+ data.tar.gz: a4a709ad17b6e14fd09117fc15810c9354279780264a7721e785ea11c355dea655ee4054790a3dfa6db20443743d5947832c41e1c5721f4a5fca2b3626f82835
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # PeopleGroup::Connectors
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/peoplegroup/connectors`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ The gem contains wrapper code for all the services we sync with. The reason we bundled this in a separate gem is to not have duplicate code in our different projects.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,10 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ```ruby
24
+ gitlab_client = PeopleGroup::Connectors::GitLab.new
25
+ gitlab_client.find_gitlabber(:email, 'some-email@domain.com')
26
+ ```
26
27
 
27
28
  ## Development
28
29
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  require_relative 'connectors/version'
4
4
  require_relative 'connectors/gitlab'
5
+ require_relative 'connectors/slack'
6
+ require_relative 'connectors/pto_roots'
7
+ require_relative 'connectors/bamboo'
8
+ require_relative 'connectors/greenhouse'
5
9
 
6
10
  module PeopleGroup
7
11
  module Connectors
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bamboozled'
4
+
5
+ module PeopleGroup
6
+ module Connectors
7
+ class Bamboo
8
+ MAX_RETRIES = 3
9
+
10
+ def initialize
11
+ @client = Bamboozled.client(subdomain: 'gitlab', api_key: ENV['BAMBOO_API_KEY'])
12
+ end
13
+
14
+ def get_employee_details(id)
15
+ employees.find { |emp| emp['id'] == id.to_s }
16
+ end
17
+
18
+ def get_employee(id)
19
+ @client.employee.find(id, %w[firstName lastName jobTitle supervisor hireDate country location department division workEmail customCostCenter])
20
+ end
21
+
22
+ def search_employee(name)
23
+ return if name.empty?
24
+
25
+ employees.find { |emp| [emp['displayName'], "#{emp['firstName']} #{emp['lastName']}", "#{emp['preferredName']} #{emp['lastName']}", emp['fullName5']].include?(name) }
26
+ end
27
+
28
+ def search_employee_by_field(field:, value:)
29
+ employees.find { |employee| employee[field] == value.to_s }
30
+ end
31
+
32
+ def create_employee(employee_details_hash)
33
+ @client.employee.add(employee_details_hash)
34
+ end
35
+
36
+ def update_employee(employee_id, employee_details_hash)
37
+ @client.employee.update(employee_id, employee_details_hash)
38
+ end
39
+
40
+ def departments
41
+ meta_fields.detect { |res| res['name'] == 'Department' }.dig('options').each_with_object([]) { |option, array| array << option['name'] if option['archived'] == 'no' } || []
42
+ end
43
+
44
+ def divisions
45
+ meta_fields.detect { |res| res['name'] == 'Division' }.dig('options').each_with_object([]) { |option, array| array << option['name'] if option['archived'] == 'no' } || []
46
+ end
47
+
48
+ def fields
49
+ @fields ||= (Bamboozled::API::FieldCollection.all_names + @client.meta.fields.map { |f| f['alias'] }).compact.uniq
50
+ end
51
+
52
+ def employees
53
+ retries = 0
54
+
55
+ begin
56
+ @employees ||= @client.report.custom(fields, 'JSON').reject { |employee| employee['lastName'] == 'Test-Gitlab' }
57
+ rescue Net::ReadTimeout
58
+ retry if (retries += 1) < MAX_RETRIES
59
+ end
60
+ end
61
+
62
+ def active_employees
63
+ employees.select { |employee| employee['status'] == 'Active' }
64
+ end
65
+ alias_method :active_team_members, :active_employees
66
+
67
+ def add_stock_options(employee_id, data)
68
+ @client.employee.add_table_row(employee_id, 'customEquity', data)
69
+ end
70
+
71
+ def stock_options_data(employee_id)
72
+ @client.employee.table_data(employee_id, 'customEquity')
73
+ end
74
+
75
+ def update_job_details(employee_id, data)
76
+ current_data = job_details(employee_id) # it should only be one row as we just created this user
77
+ row_id = current_data.first.dig('id')
78
+ @client.employee.update_table_row(employee_id, 'jobInfo', row_id, data)
79
+ end
80
+
81
+ def add_compensation_details(employee_id, data)
82
+ @client.employee.add_table_row(employee_id, 'compensation', data)
83
+ end
84
+
85
+ def employment_statuses(employee_id)
86
+ @client.employee.table_data(employee_id, 'employmentStatus')
87
+ end
88
+
89
+ def job_details(employee_id)
90
+ @client.employee.table_data(employee_id, 'jobInfo')
91
+ end
92
+
93
+ def resumes_folder_id(employee_id)
94
+ @resumes_folder_id ||= files(employee_id).dig('categories').find { |folder| folder['name'] == 'Resumes and Applications' }.dig('id')
95
+ end
96
+
97
+ def contract_folder_id(employee_id)
98
+ @contract_folder_id ||= files(employee_id).dig('categories').find { |folder| folder['name'] == 'Contracts & Changes' }.dig('id')
99
+ end
100
+
101
+ def add_file(employee_id, file_name, file, folder_id)
102
+ options = {
103
+ category: folder_id,
104
+ fileName: file_name,
105
+ share: 'yes',
106
+ file: file
107
+ }
108
+ @client.employee.add_file(employee_id, options)
109
+ end
110
+
111
+ def add_employment_status(employee_id, data)
112
+ @client.employee.add_table_row(employee_id, 'employmentStatus', data)
113
+ end
114
+
115
+ def add_currency_conversion(employee_id, data)
116
+ @client.employee.add_table_row(employee_id, 'customCurrencyConversion', data)
117
+ end
118
+
119
+ def add_on_target_earnings(employee_id, data)
120
+ @client.employee.add_table_row(employee_id, 'customOnTargetEarnings', data)
121
+ end
122
+
123
+ def add_signing_bonus(employee_id, data)
124
+ @client.employee.add_table_row(employee_id, 'customBonus', data)
125
+ end
126
+
127
+ def add_family_member(employee_id, data)
128
+ @client.employee.add_table_row(employee_id, 'customFamilyMember', data)
129
+ end
130
+
131
+ def add_additional_data(employee_id, data)
132
+ @client.employee.add_table_row(employee_id, 'customAdditionalInformation1', data)
133
+ end
134
+
135
+ private
136
+
137
+ def meta_fields
138
+ @meta_fields ||= @client.meta.lists
139
+ end
140
+
141
+ def files(employee_id)
142
+ @files ||= @client.employee.files(employee_id)
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'greenhouse_io'
4
+
5
+ module PeopleGroup
6
+ module Connectors
7
+ class Greenhouse
8
+ MAX_RETRIES = 3
9
+
10
+ def initialize(use_users_api_key: false)
11
+ api_key = use_users_api_key ? ENV['GREENHOUSE_API_KEY_USERS'] : ENV['GREENHOUSE_API_KEY']
12
+ @client = GreenhouseIo::Client.new(api_key)
13
+ end
14
+
15
+ def offer_for_application(application_id)
16
+ @client.offers_for_application(application_id)
17
+ end
18
+
19
+ def hired_candidates(updated_since)
20
+ page = 1
21
+ candidates = []
22
+ retries = 0
23
+
24
+ loop do
25
+ begin
26
+ results = @client.candidates(nil, updated_after: updated_since, page: page)
27
+ break if results.empty?
28
+
29
+ results.each do |candidate|
30
+ candidates << candidate if hired_non_active?(candidate)
31
+ end
32
+ rescue GreenhouseIo::Error
33
+ p [updated_since, page]
34
+ retry if (retries += 1) < MAX_RETRIES
35
+ end
36
+ page += 1
37
+ end
38
+
39
+ candidates
40
+ end
41
+
42
+ def candidate(candidate_id)
43
+ @client.candidates(candidate_id)
44
+ end
45
+
46
+ def add_sync_note_to_candidate(candidate_id)
47
+ note = {
48
+ user_id: ENV['GREENHOUSE_AUTHOR_ID'],
49
+ body: "This person was synced at #{Time.now} by the Employee Bot",
50
+ visibility: 'public'
51
+ }
52
+ @client.create_candidate_note(candidate_id, note, ENV['GREENHOUSE_AUTHOR_ID'])
53
+ end
54
+
55
+ def users
56
+ page = 1
57
+ users = []
58
+
59
+ loop do
60
+ results = @client.users(nil, page: page)
61
+ break if results.empty?
62
+
63
+ users += results
64
+ page += 1
65
+ end
66
+
67
+ users
68
+ end
69
+
70
+ private
71
+
72
+ def hired_non_active?(candidate)
73
+ # If the candidate has any application that is active, we don't sync.
74
+ return false if candidate['applications'].any? { |application| application['status'] == 'active' }
75
+
76
+ # Check if candidate is hired for just one of their applications
77
+ candidate['applications'].one? { |application| application['status'] == 'hired' }
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'splinter'
4
+
5
+ module PeopleGroup
6
+ module Connectors
7
+ class PTORoots
8
+ def initialize
9
+ ::Splinter.configure do |config|
10
+ config.api_key = ENV['PTO_ROOTS_API_KEY']
11
+ end
12
+ end
13
+
14
+ def pto(params)
15
+ Splinter::OOOEvents.get_all(params)
16
+ end
17
+
18
+ def pto_type(type)
19
+ pto_types.find { |pto_type| pto_type['name'] == type }
20
+ end
21
+
22
+ private
23
+
24
+ def pto_types
25
+ Splinter::OOOTypes.get_all
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'slack-ruby-client'
4
+
5
+ module PeopleGroup
6
+ module Connectors
7
+ class Slack
8
+ def initialize
9
+ ::Slack.configure do |config|
10
+ config.token = ENV['SLACK_API_TOKEN']
11
+ end
12
+ @client = ::Slack::Web::Client.new
13
+ end
14
+
15
+ def send_message(channel, message)
16
+ @client.chat_postMessage(channel: channel, text: message, as_user: true)
17
+ end
18
+
19
+ def find_user(email)
20
+ @client.users_lookupByEmail(email: email)
21
+ rescue ::Slack::Web::Api::Errors::SlackError
22
+ nil
23
+ end
24
+
25
+ def list_public_channels
26
+ channels = @client.channels_list(exclude_archived: true).channels
27
+ channels.reject(&:is_private)&.map(:name)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PeopleGroup
4
4
  module Connectors
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.9'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peoplegroup-connectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - lien van den steen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-01 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -24,6 +24,62 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: slack-ruby-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: splinter-pto
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bamboozled-gitlab
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.9
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.9
69
+ - !ruby/object:Gem::Dependency
70
+ name: greenhouse_io-gitlab
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.5'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.5'
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: rspec
29
85
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +100,28 @@ dependencies:
44
100
  requirements:
45
101
  - - "~>"
46
102
  - !ruby/object:Gem::Version
47
- version: '0.85'
103
+ version: 0.91.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.91.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: gitlab-styles
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '6.0'
48
118
  type: :development
49
119
  prerelease: false
50
120
  version_requirements: !ruby/object:Gem::Requirement
51
121
  requirements:
52
122
  - - "~>"
53
123
  - !ruby/object:Gem::Version
54
- version: '0.85'
124
+ version: '6.0'
55
125
  - !ruby/object:Gem::Dependency
56
126
  name: rubocop-packaging
57
127
  requirement: !ruby/object:Gem::Requirement
@@ -83,32 +153,19 @@ dependencies:
83
153
  description: Avoid repeating methods in different projects for our connectos.
84
154
  email:
85
155
  - lvandensteen@gitlab.com
86
- executables:
87
- - console
88
- - setup
156
+ executables: []
89
157
  extensions: []
90
158
  extra_rdoc_files: []
91
159
  files:
92
- - ".gitignore"
93
- - ".gitlab-ci.yml"
94
- - ".rspec"
95
- - ".rubocop.yml"
96
- - ".rubocop_todo.yml"
97
- - CODE_OF_CONDUCT.md
98
- - Gemfile
99
- - Gemfile.lock
100
160
  - LICENSE.txt
101
161
  - README.md
102
- - Rakefile
103
- - bin/console
104
- - bin/setup
105
162
  - lib/peoplegroup/connectors.rb
163
+ - lib/peoplegroup/connectors/bamboo.rb
106
164
  - lib/peoplegroup/connectors/gitlab.rb
165
+ - lib/peoplegroup/connectors/greenhouse.rb
166
+ - lib/peoplegroup/connectors/pto_roots.rb
167
+ - lib/peoplegroup/connectors/slack.rb
107
168
  - lib/peoplegroup/connectors/version.rb
108
- - peoplegroup-connectors.gemspec
109
- - spec/peoplegroup/connectors/gitlab_spec.rb
110
- - spec/peoplegroup/connectors_spec.rb
111
- - spec/spec_helper.rb
112
169
  homepage: https://gitlab.com/gitlab-com/people-group/peopleops-eng/connectors-gem
113
170
  licenses:
114
171
  - MIT
@@ -135,7 +192,4 @@ rubygems_version: 3.1.4
135
192
  signing_key:
136
193
  specification_version: 4
137
194
  summary: Library for our shared connectors.
138
- test_files:
139
- - spec/peoplegroup/connectors/gitlab_spec.rb
140
- - spec/peoplegroup/connectors_spec.rb
141
- - spec/spec_helper.rb
195
+ test_files: []
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.gitlab-ci.yml DELETED
@@ -1,20 +0,0 @@
1
- rspec:
2
- stage: test
3
- only:
4
- - merge_requests
5
- script:
6
- - gem install bundler
7
- - bundle install
8
- - bundle exec rspec
9
-
10
- rubocop:
11
- stage: test
12
- only:
13
- - merge_requests
14
- script:
15
- - gem install bundler
16
- - bundle install
17
- - bundle exec rubocop
18
-
19
- include:
20
- template: Dependency-Scanning.gitlab-ci.yml
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,21 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- require:
4
- - rubocop-rspec
5
- - rubocop-packaging
6
-
7
- AllCops:
8
- TargetRubyVersion: 2.7
9
- # Cop names are displayed in offense messages by default. Change behavior
10
- # by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
11
- # option.
12
- DisplayCopNames: true
13
- # Style guide URLs are not displayed in offense messages by default. Change
14
- # behavior by overriding DisplayStyleGuide, or by giving the
15
- # -S/--display-style-guide option.
16
- DisplayStyleGuide: false
17
- # Exclude some GitLab files
18
- NewCops: enable
19
-
20
- Style/Documentation:
21
- Enabled: false
data/.rubocop_todo.yml DELETED
@@ -1,72 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2021-01-29 12:09:47 UTC using RuboCop version 0.93.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- # Configuration parameters: Include.
11
- # Include: **/*.gemspec
12
- Gemspec/RequiredRubyVersion:
13
- Exclude:
14
- - 'peoplegroup-connectors.gemspec'
15
-
16
- # Offense count: 1
17
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
18
- # ExcludedMethods: refine
19
- Metrics/BlockLength:
20
- Max: 104
21
-
22
- # Offense count: 2
23
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
24
- Metrics/MethodLength:
25
- Max: 22
26
-
27
- # Offense count: 2
28
- # Configuration parameters: CountKeywordArgs.
29
- Metrics/ParameterLists:
30
- Max: 6
31
-
32
- # Offense count: 1
33
- Packaging/GemspecGit:
34
- Exclude:
35
- - 'peoplegroup-connectors.gemspec'
36
-
37
- # Offense count: 1
38
- # Configuration parameters: Max.
39
- RSpec/ExampleLength:
40
- Exclude:
41
- - 'spec/peoplegroup/connectors/gitlab_spec.rb'
42
-
43
- # Offense count: 2
44
- # Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
45
- RSpec/FilePath:
46
- Exclude:
47
- - 'spec/peoplegroup/connectors/gitlab_spec.rb'
48
- - 'spec/peoplegroup/connectors_spec.rb'
49
-
50
- # Offense count: 3
51
- RSpec/MultipleExpectations:
52
- Max: 3
53
-
54
- # Offense count: 5
55
- # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
56
- RSpec/VerifiedDoubles:
57
- Exclude:
58
- - 'spec/peoplegroup/connectors/gitlab_spec.rb'
59
-
60
- # Offense count: 2
61
- # Cop supports --auto-correct.
62
- # Configuration parameters: AllowOnConstant.
63
- Style/CaseEquality:
64
- Exclude:
65
- - 'lib/peoplegroup/connectors/gitlab.rb'
66
-
67
- # Offense count: 6
68
- # Cop supports --auto-correct.
69
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
70
- # URISchemes: http, https
71
- Layout/LineLength:
72
- Max: 185
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at lvandensteen@gitlab.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in gl-people-connectors.gemspec
6
- gemspec
7
-
8
- gem 'rake', '~> 12.0'
9
- gem 'rspec', '~> 3.0'
data/Gemfile.lock DELETED
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- peoplegroup-connectors (0.1.2)
5
- gitlab
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- diff-lcs (1.4.4)
12
- gitlab (4.17.0)
13
- httparty (~> 0.18)
14
- terminal-table (~> 1.5, >= 1.5.1)
15
- httparty (0.18.1)
16
- mime-types (~> 3.0)
17
- multi_xml (>= 0.5.2)
18
- mime-types (3.3.1)
19
- mime-types-data (~> 3.2015)
20
- mime-types-data (3.2020.1104)
21
- multi_xml (0.6.0)
22
- parallel (1.20.1)
23
- parser (3.0.0.0)
24
- ast (~> 2.4.1)
25
- rainbow (3.0.0)
26
- rake (12.3.3)
27
- regexp_parser (2.0.3)
28
- rexml (3.2.4)
29
- rspec (3.10.0)
30
- rspec-core (~> 3.10.0)
31
- rspec-expectations (~> 3.10.0)
32
- rspec-mocks (~> 3.10.0)
33
- rspec-core (3.10.1)
34
- rspec-support (~> 3.10.0)
35
- rspec-expectations (3.10.1)
36
- diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.10.0)
38
- rspec-mocks (3.10.2)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.10.0)
41
- rspec-support (3.10.2)
42
- rubocop (0.93.1)
43
- parallel (~> 1.10)
44
- parser (>= 2.7.1.5)
45
- rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.8)
47
- rexml
48
- rubocop-ast (>= 0.6.0)
49
- ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 2.0)
51
- rubocop-ast (1.4.1)
52
- parser (>= 2.7.1.5)
53
- rubocop-packaging (0.5.1)
54
- rubocop (>= 0.89, < 2.0)
55
- rubocop-rspec (1.44.1)
56
- rubocop (~> 0.87)
57
- rubocop-ast (>= 0.7.1)
58
- ruby-progressbar (1.11.0)
59
- terminal-table (1.8.0)
60
- unicode-display_width (~> 1.1, >= 1.1.1)
61
- unicode-display_width (1.7.0)
62
-
63
- PLATFORMS
64
- ruby
65
-
66
- DEPENDENCIES
67
- peoplegroup-connectors!
68
- rake (~> 12.0)
69
- rspec (~> 3.0)
70
- rubocop (~> 0.85)
71
- rubocop-packaging (~> 0.1)
72
- rubocop-rspec (~> 1.39)
73
-
74
- BUNDLED WITH
75
- 2.1.4
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
data/bin/console DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'peoplegroup/connectors'
6
-
7
- def reload!(print: true)
8
- puts 'Reloading ...' if print
9
- # Main project directory.
10
- root_dir = File.expand_path('..', __dir__)
11
- # Directories within the project that should be reloaded.
12
- reload_dirs = %w[lib]
13
- # Loop through and reload every file in all relevant project directories.
14
- reload_dirs.each do |dir|
15
- Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
16
- end
17
- # Return true when complete.
18
- true
19
- end
20
-
21
- # (If you use this, don't forget to add pry to your Gemfile!)
22
- # require "pry"
23
- # Pry.start
24
-
25
- require 'irb'
26
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/peoplegroup/connectors/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'peoplegroup-connectors'
7
- spec.version = PeopleGroup::Connectors::VERSION
8
- spec.authors = ['lien van den steen']
9
- spec.email = ['lvandensteen@gitlab.com']
10
-
11
- spec.summary = 'Library for our shared connectors.'
12
- spec.description = 'Avoid repeating methods in different projects for our connectos.'
13
- spec.homepage = 'https://gitlab.com/gitlab-com/people-group/peopleops-eng/connectors-gem'
14
- spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
-
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = spec.homepage
19
- spec.metadata['changelog_uri'] = spec.homepage
20
-
21
- spec.files = `git ls-files -z`.split("\x0")
22
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
- spec.require_paths = ['lib']
25
-
26
- spec.add_dependency 'gitlab'
27
-
28
- spec.add_development_dependency 'rspec', '~> 3.2'
29
- spec.add_development_dependency 'rubocop', '~> 0.85'
30
- spec.add_development_dependency 'rubocop-packaging', '~> 0.1'
31
- spec.add_development_dependency 'rubocop-rspec', '~> 1.39'
32
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe PeopleGroup::Connectors::GitLab do
4
- let(:gitlab_members) { spy }
5
- let(:gitlab_mock) do
6
- instance_double(
7
- Gitlab::Client,
8
- group_members: gitlab_members,
9
- create_issue: true,
10
- issues: double(auto_paginate: true),
11
- create_issue_note: true,
12
- create_epic: true,
13
- epics: double(auto_paginate: []),
14
- create_branch: true,
15
- create_merge_request: true,
16
- create_commit: true,
17
- create_epic_note: true,
18
- epic_issues: double(auto_paginate: []),
19
- edit_epic: true
20
- )
21
- end
22
-
23
- before do
24
- allow(Gitlab).to receive(:client).and_return(gitlab_mock)
25
- end
26
-
27
- describe '#find_gitlabber' do
28
- context 'when given empty query' do
29
- it 'returns nil' do
30
- expect(described_class.new.find_gitlabber(:username, nil)).to be_nil
31
- end
32
- end
33
-
34
- context 'when given non-empty query' do
35
- it 'calls correct method with proper args' do
36
- described_class.new.find_gitlabber(:name, 'john')
37
-
38
- expect(gitlab_mock).to have_received(:group_members).with('gitlab-com', query: 'john')
39
- expect(gitlab_members).to have_received(:find)
40
- end
41
- end
42
- end
43
-
44
- describe '#create_issue' do
45
- it 'calls correct method with proper args' do
46
- described_class.new.create_issue('foo/bar', 'My Issue Title', assignee_id: 123_456)
47
- expect(gitlab_mock).to have_received(:create_issue).with('foo/bar', 'My Issue Title', assignee_id: 123_456)
48
- end
49
- end
50
-
51
- describe '#get_onboarding_issues' do
52
- it 'uses specified arguments' do
53
- described_class.new.get_onboarding_issues('foo/bar', per_page: 500)
54
-
55
- expect(gitlab_mock).to have_received(:issues).with('foo/bar', per_page: 500)
56
- end
57
- end
58
-
59
- describe '#create_issue_note' do
60
- it 'calls correct method with proper args' do
61
- described_class.new.create_issue_note('foo/bar', 15, 'My issue comment')
62
-
63
- expect(gitlab_mock).to have_received(:create_issue_note).with('foo/bar', 15, 'My issue comment')
64
- end
65
- end
66
-
67
- describe '#find_or_create_epic' do
68
- it 'calls correct method with proper args' do
69
- described_class.new.find_or_create_epic(123, 'My Epic Title', assignee_id: 123_456)
70
- expect(gitlab_mock).to have_received(:create_epic).with(123, 'My Epic Title', { assignee_id: 123_456, confidential: true })
71
- end
72
-
73
- context 'when the epic was closed' do
74
- before do
75
- allow(gitlab_mock).to receive(:epics).and_return(double(auto_paginate: [double(iid: 1, group_id: 2, web_url: 'foo.bar/issues/1', state: 'closed', title: 'Existing Epic')]))
76
- end
77
-
78
- it 'reopens the epic' do
79
- described_class.new.find_or_create_epic(2, 'Existing Epic', assignee_id: 123_456)
80
- expect(gitlab_mock).not_to have_received(:create_epic)
81
- expect(gitlab_mock).to have_received(:edit_epic).with(2, 1, state_event: 'reopen')
82
- end
83
- end
84
- end
85
-
86
- describe '#commit_change_to_new_merge_request' do
87
- it 'calls correct method with proper args' do
88
- described_class.new.commit_change_to_new_merge_request(123, 'my-new-branch', 'foo/bar.md', 'the changed text', 'my commit message')
89
- expect(gitlab_mock).to have_received(:create_branch).with(123, 'my-new-branch', 'master')
90
- action = {
91
- action: 'update',
92
- file_path: 'foo/bar.md',
93
- content: 'the changed text'
94
- }
95
- expect(gitlab_mock).to have_received(:create_commit).with(123, 'my-new-branch', 'my commit message', [action])
96
- expect(gitlab_mock).to have_received(:create_merge_request).with(123, 'my commit message', { source_branch: 'my-new-branch', target_branch: 'master', remove_source_branch: true })
97
- end
98
- end
99
-
100
- describe '#get_epics' do
101
- it 'calls correct method with proper args' do
102
- described_class.new.get_epics(123)
103
- expect(gitlab_mock).to have_received(:epics).with(123, {})
104
- end
105
-
106
- it 'calls correct method with proper args when you add options' do
107
- described_class.new.get_epics(123, state: 'opened')
108
- expect(gitlab_mock).to have_received(:epics).with(123, { state: 'opened' })
109
- end
110
- end
111
-
112
- describe '#get_issue_epics' do
113
- it 'calls correct method with proper args' do
114
- described_class.new.get_issue_epics(123, 7)
115
- expect(gitlab_mock).to have_received(:epic_issues).with(123, 7)
116
- end
117
- end
118
-
119
- describe '#create_epic_note' do
120
- it 'calls correct method with proper args' do
121
- described_class.new.create_epic_note(123, 7, 'My epic note')
122
- expect(gitlab_mock).to have_received(:create_epic_note).with(123, 7, 'My epic note')
123
- end
124
- end
125
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe PeopleGroup::Connectors do
4
- it 'has a version number' do
5
- expect(PeopleGroup::Connectors::VERSION).not_to be nil
6
- end
7
- end
data/spec/spec_helper.rb DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'peoplegroup/connectors'
4
-
5
- RSpec.configure do |config|
6
- # Enable flags like --only-failures and --next-failure
7
- config.example_status_persistence_file_path = '.rspec_status'
8
-
9
- # Disable RSpec exposing methods globally on `Module` and `main`
10
- config.disable_monkey_patching!
11
-
12
- config.filter_run focus: true
13
- config.run_all_when_everything_filtered = true
14
-
15
- config.expect_with :rspec do |c|
16
- c.syntax = :expect
17
- end
18
- end