ogam 1.1.0 → 1.3.2

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: 01aa2307589a72f9316e069ea9d7980dccc74c52c2cc8deb87d5eea2a71da94f
4
- data.tar.gz: fa83f2d5035bceae5b3f9d389f6b4ec9ccc65eb5d40316a0ee13d3b97dea3e94
3
+ metadata.gz: b41adf475cb00cb57164e2bbb0e330d3b7d0401abd7725cc4ddc39325e2e8e9f
4
+ data.tar.gz: 8519c7e4f82dfcdd87e2efde8fa0651841984d136fe6f4853bf85e042e1bdf1c
5
5
  SHA512:
6
- metadata.gz: 8e55ca322c7c97c468a810ead4bd530d034a29151cb0a02b15923fcf658173f331124b26cae58e0271709bae70c6ef6f69e0b35385365e60abb2a87c62aaefdc
7
- data.tar.gz: 3e8a1f8844d692da9093da34ac1a28c4bf82182df32ba8406ddcbd381c203490aa07d98ddb10055fef3148072fe1982453d73e08be3f15c4271dceeb8f987cf3
6
+ metadata.gz: 1d05195e69269c8700c50806953046a7676b9f380658d2168292795759c6b5be139b594362313fe2e378e192a6f4d2e8fd71efa6d43375fed08339b2ebdd1da6
7
+ data.tar.gz: 4ac972b6caf6c6b3f37f1ebd37f47fb8e76b12526394aa8c9d00bdd8ca6b58b4902b54be22780d7750a1f67de35e6d69bb8669363929edd8f168ff42d4fa1f71
@@ -1,24 +1,21 @@
1
1
  inherit_from:
2
2
  - .rubocop_todo.yml
3
- - .rubocop_metrics_todo.yml
4
3
 
5
4
  inherit_gem:
6
5
  rubocop-ogat:
7
6
  - config/default.yml
8
7
 
8
+ inherit_mode:
9
+ merge:
10
+ - 'Include'
11
+
9
12
  AllCops:
10
13
  TargetRubyVersion: 2.6
11
-
12
- Layout/LineLength:
13
- Max: 120
14
-
15
- Metrics/BlockLength:
14
+ Include:
15
+ - 'bin/ogam'
16
16
  Exclude:
17
- - 'spec/**/*.rb'
18
- - 'ogatstyle.gemspec'
19
-
20
- Rails/Output:
21
- Enabled: false
17
+ - 'bin/console'
18
+ - 'vendor/bundle/**/*'
22
19
 
23
- Rails/SaveBang:
20
+ Rails:
24
21
  Enabled: false
@@ -1,7 +1,52 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config --exclude-limit 1000 --no-offense-counts --no-auto-gen-timestamp`
3
- # using RuboCop version 0.80.0.
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000 --no-offense-counts --no-auto-gen-timestamp`
3
+ # using RuboCop version 0.82.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Configuration parameters: IgnoredMethods, Max.
10
+ Metrics/AbcSize:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+ - 'db/migrate/*'
14
+ - 'config/routes.rb'
15
+ - 'config/environments/*.rb'
16
+ - 'lib/ogam/group_assigner.rb'
17
+
18
+ # Configuration parameters: CountComments, Max.
19
+ Metrics/ClassLength:
20
+ Exclude:
21
+ - 'spec/**/*'
22
+ - 'db/migrate/*'
23
+ - 'config/routes.rb'
24
+ - 'config/environments/*.rb'
25
+ - 'lib/ogam/group_assigner.rb'
26
+
27
+ # Configuration parameters: IgnoredMethods, Max.
28
+ Metrics/CyclomaticComplexity:
29
+ Exclude:
30
+ - 'spec/**/*'
31
+ - 'db/migrate/*'
32
+ - 'config/routes.rb'
33
+ - 'config/environments/*.rb'
34
+ - 'lib/ogam/group_assigner.rb'
35
+
36
+ # Configuration parameters: CountComments, Max, ExcludedMethods.
37
+ Metrics/MethodLength:
38
+ Exclude:
39
+ - 'spec/**/*'
40
+ - 'db/migrate/*'
41
+ - 'config/routes.rb'
42
+ - 'config/environments/*.rb'
43
+ - 'lib/ogam/group_assigner.rb'
44
+
45
+ # Configuration parameters: IgnoredMethods, Max.
46
+ Metrics/PerceivedComplexity:
47
+ Exclude:
48
+ - 'spec/**/*'
49
+ - 'db/migrate/*'
50
+ - 'config/routes.rb'
51
+ - 'config/environments/*.rb'
52
+ - 'lib/ogam/group_assigner.rb'
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
data/bin/ogam CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'ogam'
6
- require 'thor'
7
- require 'shellwords'
4
+ require "bundler/setup"
5
+ require "ogam"
6
+ require "thor"
7
+ require "shellwords"
8
8
 
9
9
  # Signature subcommand cli
10
10
  class SignatureCLI < Thor
11
- desc('user EMAIL', 'Sets the signature for user with primary email EMAIL based on their name, job title, and org')
11
+ desc("user EMAIL", "Sets the signature for user with primary email EMAIL based on their name, job title, and org")
12
12
  def user(email)
13
13
  set_signatures(Ogam::User.active_by_email(email), pretend: parent_options[:pretend])
14
14
  end
15
15
 
16
- desc('domain DOMAIN', 'Sets the signature for all users @DOMAIN based on their name, job title, and org')
16
+ desc("domain DOMAIN", "Sets the signature for all users @DOMAIN based on their name, job title, and org")
17
17
  def domain(domain)
18
18
  set_signatures(Ogam::User.active_for_domain(domain), pretend: parent_options[:pretend])
19
19
  end
@@ -32,38 +32,38 @@ class CLI < Thor
32
32
  class_option :pretend, type: :boolean, default: false
33
33
 
34
34
  desc(
35
- 'assign_to_standard_groups DOMAIN_OR_EMAIL',
36
- 'Assigns users at DOMAIN (e.g. newbold.outwood.com) or EMAIL address to standard groups based on their job title'
35
+ "assign_to_standard_groups DOMAIN_OR_EMAIL",
36
+ "Assigns users at DOMAIN (e.g. newbold.outwood.com) or EMAIL address to standard groups based on their job title"
37
37
  )
38
38
  def assign_to_standard_groups(domain_or_email)
39
- method = domain_or_email.include?('@') ? :for_user : :for_domain
39
+ method = domain_or_email.include?("@") ? :for_user : :for_domain
40
40
  Ogam::GroupAssigner.public_send(method, domain_or_email, pretend: options[:pretend])
41
41
  end
42
42
 
43
43
  desc(
44
- 'populate_titles_and_orgs PATH_TO_CSV',
45
- 'Populates job titles and organisation names from a CSV with columns primary_email, job_title, organisation'
44
+ "populate_titles_and_orgs PATH_TO_CSV",
45
+ "Populates job titles and organisation names from a CSV with columns primary_email, job_title, organisation"
46
46
  )
47
47
  def populate_titles_and_orgs(csv_path)
48
48
  Ogam::Execute.csv_command(
49
49
  csv_path,
50
- 'gam update user ~primary_email organization name ~organisation title ~job_title primary',
50
+ "gam update user ~primary_email organization name ~organisation title ~job_title primary",
51
51
  pretend: options[:pretend]
52
52
  )
53
53
  end
54
54
 
55
- desc('create_shared_mailbox EMAIL NAME', 'Create a shared mailbox')
55
+ desc("create_shared_mailbox EMAIL NAME", "Create a shared mailbox")
56
56
  def create_shared_mailbox(email, name)
57
57
  Ogam::Execute.single(Ogam::Group.create_shared_mailbox_command(email, name), pretend: options[:pretend])
58
58
  end
59
59
 
60
- desc('create_exec_mailbox EMAIL NAME', 'Create an Exec mailbox')
60
+ desc("create_exec_mailbox EMAIL NAME", "Create an Exec mailbox")
61
61
  def create_exec_mailbox(email, name)
62
62
  Ogam::Execute.single(Ogam::Group.create_exec_mailbox_command(email, name), pretend: options[:pretend])
63
63
  end
64
64
 
65
65
  option :moderated, type: :boolean, default: false
66
- desc('create_group EMAIL NAME [--moderated]', 'Create a distribution list group, optionally moderated')
66
+ desc("create_group EMAIL NAME [--moderated]", "Create a distribution list group, optionally moderated")
67
67
  def create_group(email, name)
68
68
  Ogam::Execute.single(
69
69
  Ogam::Group.create_distribution_list_command(email, name, options[:moderated]), pretend: options[:pretend]
@@ -72,8 +72,8 @@ class CLI < Thor
72
72
 
73
73
  option :organisation, type: :string
74
74
  desc(
75
- 'set_job_title EMAIL TITLE [--organisation ORG_NAME]',
76
- 'Sets job title for a user, and updates their signature, groups, and organisation name. Optionally override org.'
75
+ "set_job_title EMAIL TITLE [--organisation ORG_NAME]",
76
+ "Sets job title for a user, and updates their signature, groups, and organisation name. Optionally override org."
77
77
  )
78
78
  def set_job_title(email, title)
79
79
  validate_job_title!(title)
@@ -85,8 +85,33 @@ class CLI < Thor
85
85
  set_title_and_org_and_make_changes(email, title, org, pretend: options[:pretend])
86
86
  end
87
87
 
88
- desc('set_signature user/domain EMAIL/DOMAIN', 'Set email signatures for users/domains based on user attributes')
89
- subcommand 'set_signature', SignatureCLI
88
+ desc(
89
+ "add_send_as USER GROUP NAME TITLE ORG_NAME",
90
+ "Adds a sendas address to USER to be able to send as GROUP, and sets the NAME, and signature for sending"
91
+ )
92
+ def add_send_as(user, group, name, title, org_name)
93
+ signature_html = Ogam::Signature.signature_html(name, title, org_name)
94
+ Ogam::Execute.single(Ogam::Group.add_send_as_command(user, group, name, signature_html), pretend: options[:pretend])
95
+ end
96
+
97
+ desc("set_signature user/domain EMAIL/DOMAIN", "Set email signatures for users/domains based on user attributes")
98
+ subcommand "set_signature", SignatureCLI
99
+
100
+ desc("delicense_suspended_ou", "De-licenses GSEfE from all users under /Suspended")
101
+ def delicense_suspended_ou
102
+ Ogam::Execute.single('gam ou "/Suspended" delete license 1010310002', pretend: options[:pretend])
103
+ end
104
+
105
+ desc("offboard USER", "Suspends a user, moves them to /Suspended, removes from groups, and delicenses GSEfE")
106
+ def offboard(user)
107
+ Ogam::Execute.single(
108
+ "gam update user #{user} suspended on org \"/Suspended\"", pretend: options[:pretend]
109
+ )
110
+ Ogam::Execute.single("gam user #{user} delete groups", pretend: options[:pretend])
111
+ puts "Waiting 5 seconds before delicensing..."
112
+ sleep(5)
113
+ Ogam::Execute.single("gam user #{user} delete license 1010310002", pretend: options[:pretend])
114
+ end
90
115
 
91
116
  private
92
117
 
@@ -99,7 +124,7 @@ class CLI < Thor
99
124
  end
100
125
 
101
126
  def validate_organisation!(org, approved_organisations)
102
- org.split(' / ').each do |org_part|
127
+ org.split(" / ").each do |org_part|
103
128
  unless approved_organisations.value?(org_part)
104
129
  raise ArgumentError, "'#{org_part}' is not an approved organisation name."
105
130
  end
@@ -109,7 +134,7 @@ class CLI < Thor
109
134
  def infer_organisation_if_necessary(org, email, approved_organisations)
110
135
  return org if org.present?
111
136
 
112
- approved_organisations.fetch(email.split('@').last, '')
137
+ approved_organisations.fetch(email.split("@").last, "")
113
138
  end
114
139
 
115
140
  def set_title_and_org_and_make_changes(email, title, org, pretend: true)
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/all'
4
- require 'attr_extras'
5
- require 'ogam/version'
6
- require 'ogam/execute'
7
- require 'ogam/group'
8
- require 'ogam/job_title'
9
- require 'ogam/user'
10
- require 'ogam/group_assigner'
11
- require 'ogam/signature'
12
- require 'ogam/organisation'
3
+ require "active_support/all"
4
+ require "attr_extras"
5
+ require "ogam/version"
6
+ require "ogam/execute"
7
+ require "ogam/group"
8
+ require "ogam/job_title"
9
+ require "ogam/user"
10
+ require "ogam/group_assigner"
11
+ require "ogam/signature"
12
+ require "ogam/organisation"
13
13
 
14
14
  module Ogam
15
15
  class Error < StandardError; end
@@ -1,24 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'csv'
4
- require 'tempfile'
5
- require 'English'
3
+ require "csv"
4
+ require "tempfile"
5
+ require "English"
6
6
 
7
7
  module Ogam
8
8
  # Methods to execute GAM commands
9
9
  class Execute
10
10
  def self.single(command, pretend: true)
11
- puts "#{pretend ? '[PRETEND] ' : nil}Executing #{command}"
11
+ puts "#{pretend ? "[PRETEND] " : nil}Executing #{command}"
12
12
  return if pretend
13
13
 
14
- system("~/bin/gam/#{command}", exception: true)
14
+ system("~/bin/gam/#{command.strip}", exception: true)
15
15
  end
16
16
 
17
17
  def self.fetch(command, pretend: true)
18
- puts "#{pretend ? '[PRETEND] ' : nil}Fetching results from #{command}"
18
+ puts "#{pretend ? "[PRETEND] " : nil}Fetching results from #{command}"
19
19
  return if pretend
20
20
 
21
- `~/bin/gam/#{command}`
21
+ `~/bin/gam/#{command.strip}`
22
22
  end
23
23
 
24
24
  def self.fetch_csv(command, pretend: true)
@@ -29,22 +29,25 @@ module Ogam
29
29
  end
30
30
 
31
31
  def self.csv_command(csv_path, command, pretend: true)
32
- single("gam csv #{Shellwords.escape(csv_path)} #{command}", pretend: pretend)
32
+ single("gam csv #{Shellwords.escape(csv_path)} #{command.strip}", pretend: pretend)
33
33
  end
34
34
 
35
+ # rubocop:disable Metrics/MethodLength
35
36
  def self.multiple(commands, pretend: true)
36
37
  return if commands.empty?
37
38
 
38
- puts "#{pretend ? '[PRETEND] ' : nil}Executing multiple commands:"
39
+ puts "#{pretend ? "[PRETEND] " : nil}Executing multiple commands:"
39
40
  commands.each do |command|
40
41
  puts "\t#{command}"
41
42
  end
42
43
  return if pretend
43
44
 
44
- Tempfile.create do |f|
45
- commands.each { |command| f.puts command }
46
- single("gam batch #{f.path}", pretend: pretend)
47
- end
45
+ f = Tempfile.new
46
+ commands.each { |command| f.puts command.strip }
47
+ f.close
48
+ single("gam batch #{f.path}", pretend: pretend)
49
+ f.unlink
48
50
  end
51
+ # rubocop:enable Metrics/MethodLength
49
52
  end
50
53
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'shellwords'
3
+ require "shellwords"
4
4
  module Ogam
5
5
  # Methods relating to groups
6
6
  class Group
7
7
  def self.groups_for_domain(domain)
8
- Ogam::Execute.fetch_csv("gam print groups domain #{domain}", pretend: false).map { |r| r['Email'] }
8
+ Ogam::Execute.fetch_csv("gam print groups domain #{domain}", pretend: false).map { |r| r["Email"] }
9
9
  end
10
10
 
11
11
  def self.add_group_member_command(user:, group:)
12
- "gam update group #{group} add member user #{user}"
12
+ "gam update group #{group} add member user #{Shellwords.escape(user)}"
13
13
  end
14
14
 
15
15
  def self.create_shared_mailbox_command(email_address, name)
@@ -26,7 +26,13 @@ module Ogam
26
26
 
27
27
  def self.create_distribution_list_command(email_address, name, moderated)
28
28
  <<~COMMAND
29
- gam create group #{email_address} name #{Shellwords.escape(name)} allow_external_members false who_can_join invited_can_join primary_language en-GB who_can_view_membership all_in_domain_can_view include_in_global_address_list true is_archived false members_can_post_as_the_group false allow_web_posting false send_message_deny_notification true reply_to reply_to_sender message_moderation_level #{moderated ? 'moderate_all_messages' : 'moderate_none'} who_can_contact_owner all_managers_can_contact who_can_leave_group none_can_leave who_can_add none_can_add who_can_post_message all_in_domain_can_post who_can_invite none_can_invite who_can_view_group all_managers_can_view show_in_group_directory true archive_only false spam_moderation_level moderate
29
+ gam create group #{email_address} name #{Shellwords.escape(name)} allow_external_members false who_can_join invited_can_join primary_language en-GB who_can_view_membership all_in_domain_can_view include_in_global_address_list true is_archived false members_can_post_as_the_group false allow_web_posting false send_message_deny_notification true reply_to reply_to_sender message_moderation_level #{moderated ? "moderate_all_messages" : "moderate_none"} who_can_contact_owner all_managers_can_contact who_can_leave_group none_can_leave who_can_add none_can_add who_can_post_message all_in_domain_can_post who_can_invite none_can_invite who_can_view_group all_managers_can_view show_in_group_directory true archive_only false spam_moderation_level moderate
30
+ COMMAND
31
+ end
32
+
33
+ def self.add_send_as_command(user_email, group_email, name, signature_html)
34
+ <<~COMMAND
35
+ gam user #{user_email} sendas #{group_email} #{Shellwords.escape(name)} treatasalias false signature "#{signature_html}"
30
36
  COMMAND
31
37
  end
32
38
  end
@@ -5,28 +5,28 @@ module Ogam
5
5
  class GroupAssigner
6
6
  static_facade :call, :users, :domain, [pretend: true]
7
7
 
8
- SUBJECT_TEACHER_TITLES = ['Teacher of ', 'Head of ', 'Second in ', 'Third in '].freeze
8
+ SUBJECT_TEACHER_TITLES = ["Teacher of ", "Head of ", "Second in ", "Third in "].freeze
9
9
  SUBJECT_MAPPING = {
10
- 'art-teachers' => ['Art'],
11
- 'business-teachers' => ['Business Studies'],
12
- 'dance-teachers' => ['Dance', 'Performing Arts'],
13
- 'design-technology-teachers' => %w[Technology Engineering],
14
- 'drama-teachers' => ['Drama', 'Music & Drama', 'Performing Arts'],
15
- 'english-teachers' => ['English'],
16
- 'epq-teachers' => [],
17
- 'geography-teachers' => ['Humanities'],
18
- 'guidance-teachers' => [],
19
- 'health-social-care-teachers' => ['Health & Social Care'],
20
- 'history-teachers' => %w[Humanities History],
21
- 'ict-teachers' => ['Computer Science'],
22
- 'law-teachers' => ['Law'],
23
- 'maths-teachers' => ['Maths'],
24
- 'mfl-teachers' => ['MFL'],
25
- 'music-teachers' => ['Music', 'Music & Drama'],
26
- 'pe-teachers' => ['PE'],
27
- 're-life-teachers' => ['Humanities', 'Religious Studies'],
28
- 'science-teachers' => ['Science'],
29
- 'social-sciences-teachers' => ['Social Sciences']
10
+ "art-teachers" => ["Art", "Creative Arts"],
11
+ "business-teachers" => ["Business Studies", "Business & IT"],
12
+ "dance-teachers" => ["Dance", "Performing Arts", "Creative Arts"],
13
+ "design-technology-teachers" => %w[Technology Engineering],
14
+ "drama-teachers" => ["Drama", "Music & Drama", "Performing Arts", "Creative Arts"],
15
+ "english-teachers" => ["English"],
16
+ "epq-teachers" => [],
17
+ "geography-teachers" => ["Humanities"],
18
+ "guidance-teachers" => [],
19
+ "health-social-care-teachers" => ["Health & Social Care"],
20
+ "history-teachers" => %w[Humanities History],
21
+ "ict-teachers" => ["Computer Science", "Business & IT"],
22
+ "law-teachers" => ["Law"],
23
+ "maths-teachers" => ["Maths"],
24
+ "mfl-teachers" => ["MFL"],
25
+ "music-teachers" => ["Music", "Music & Drama", "Creative Arts"],
26
+ "pe-teachers" => ["PE"],
27
+ "re-life-teachers" => ["Humanities", "Religious Studies"],
28
+ "science-teachers" => ["Science"],
29
+ "social-sciences-teachers" => ["Social Sciences"]
30
30
  }.freeze
31
31
 
32
32
  def self.for_domain(domain, pretend: true)
@@ -34,37 +34,38 @@ module Ogam
34
34
  end
35
35
 
36
36
  def self.for_user(email, pretend: true)
37
- call(User.active_by_email(email), email.split('@').last, pretend: pretend)
37
+ call(User.active_by_email(email), email.split("@").last, pretend: pretend)
38
38
  end
39
39
 
40
40
  def self.groups_for_job_title(job_title, entry, domain)
41
41
  groups_domain = "groups.#{domain}"
42
42
 
43
43
  groups = groups_from_entry(entry, groups_domain)
44
- groups += subject_groups(job_title, groups_domain) if entry['Teaching']
44
+ groups += subject_groups(job_title, groups_domain) if entry["Teaching"]
45
45
 
46
- groups << "heads-of-departments@#{groups_domain}" if entry['Teaching'] && job_title.include?('Head of ')
47
- groups << "principal@#{groups_domain}" if entry['SLT'] && ['Principal', 'Acting Principal'].include?(job_title)
46
+ groups << "heads-of-departments@#{groups_domain}" if entry["Teaching"] && job_title.include?("Head of ")
47
+ groups << "principal@#{groups_domain}" if entry["SLT"] && ["Principal", "Acting Principal"].include?(job_title)
48
48
 
49
- groups << "learning-managers@#{groups_domain}" if job_title.include?('Learning Manager')
50
- groups << "academy-council@#{groups_domain}" if job_title.include?('Academy Council')
51
- groups << 'business-managers@trust-wide.outwood.com' if job_title == 'Business Manager'
49
+ groups << "learning-managers@#{groups_domain}" if job_title.include?("Learning Manager")
50
+ groups << "academy-council@#{groups_domain}" if job_title.include?("Academy Council")
51
+ groups << "learning-support@#{groups_domain}" if job_title.include?("Teaching Assistant")
52
+ groups << "business-managers@trust-wide.outwood.com" if job_title == "Business Manager"
52
53
 
53
54
  groups
54
55
  end
55
56
 
56
57
  def self.groups_from_entry(entry, groups_domain)
57
- groups = []
58
- groups << "teaching-staff@#{groups_domain}" if entry['Teaching']
59
- groups << "support-staff@#{groups_domain}" if entry['Support']
60
- if entry['SLT']
58
+ groups = ["all-staff-direct@trust-wide.outwood.com"]
59
+ groups << "teaching-staff@#{groups_domain}" if entry["Teaching"]
60
+ groups << "support-staff@#{groups_domain}" if entry["Support"]
61
+ if entry["SLT"]
61
62
  groups << "slt@#{groups_domain}"
62
63
  groups << "leadership-team@#{groups_domain}"
63
64
  end
64
- groups << 'finance@trust-wide.outwood.com' if entry['Finance']
65
- groups << 'data-exams@trust-wide.outwood.com' if entry['Data and Exams']
66
- groups << 'human-resources@trust-wide.outwood.com' if entry['HR']
67
- groups << 'ict-support@trust-wide.outwood.com' if entry['ICT Support']
65
+ groups << "finance@trust-wide.outwood.com" if entry["Finance"]
66
+ groups << "data-exams@trust-wide.outwood.com" if entry["Data and Exams"]
67
+ groups << "human-resources@trust-wide.outwood.com" if entry["HR"]
68
+ groups << "ict-support@trust-wide.outwood.com" if entry["ICT Support"]
68
69
  groups
69
70
  end
70
71
 
@@ -74,9 +75,9 @@ module Ogam
74
75
  groups = []
75
76
  SUBJECT_MAPPING.each do |group_prefix, subject_words|
76
77
  has_subject =
77
- subject_words.any? do |subject|
78
+ subject_words.any? { |subject|
78
79
  SUBJECT_TEACHER_TITLES.any? { |title| job_title.include? "#{title}#{subject}" }
79
- end
80
+ }
80
81
  next unless has_subject
81
82
 
82
83
  groups << "#{group_prefix}@#{groups_domain}"
@@ -97,7 +98,7 @@ module Ogam
97
98
  end
98
99
 
99
100
  def valid_groups
100
- @valid_groups ||= Group.groups_for_domain("groups.#{domain}") + Group.groups_for_domain('trust-wide.outwood.com')
101
+ @valid_groups ||= Group.groups_for_domain("groups.#{domain}") + Group.groups_for_domain("trust-wide.outwood.com")
101
102
  end
102
103
 
103
104
  def generate_group_assignments
@@ -110,7 +111,7 @@ module Ogam
110
111
 
111
112
  def group_assignments_for_user(user)
112
113
  group_assignments = []
113
- email = user['primaryEmail']
114
+ email = user["primaryEmail"]
114
115
  User.job_titles_for_user(user).each do |job_title|
115
116
  entry = approved_job_titles.fetch(job_title, nil)
116
117
  if entry.nil?
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'open-uri'
4
- require 'csv'
3
+ require "open-uri"
4
+ require "csv"
5
5
 
6
6
  module Ogam
7
7
  # Allows working with a list of approved job titles
8
8
  class JobTitle
9
9
  static_facade :all
10
10
 
11
- CSV_URL = 'https://docs.google.com/spreadsheets/d/12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60/export?format=csv&id=12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60&gid=1604665254'
11
+ CSV_URL = "https://docs.google.com/spreadsheets/d/12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60/export?format=csv&id=12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60&gid=1604665254"
12
12
 
13
13
  def self.job_titles(str)
14
14
  return [] if str.blank?
15
15
 
16
- str.split(' / ')
16
+ str.split(" / ")
17
17
  end
18
18
 
19
19
  def all
@@ -23,16 +23,16 @@ module Ogam
23
23
  private
24
24
 
25
25
  def download
26
- puts 'Fetching list of accepted job titles'
26
+ puts "Fetching list of accepted job titles"
27
27
  URI.parse(CSV_URL).read
28
28
  end
29
29
 
30
30
  def parse(str)
31
31
  data = {}
32
32
  CSV.parse(str, headers: true).each do |row|
33
- next if row['Job Title'].blank?
33
+ next if row["Job Title"].blank?
34
34
 
35
- data[row['Job Title']] = entry_for_row(row)
35
+ data[row["Job Title"]] = entry_for_row(row)
36
36
  end
37
37
 
38
38
  data
@@ -40,8 +40,8 @@ module Ogam
40
40
 
41
41
  def entry_for_row(row)
42
42
  entry = {}
43
- (row.headers - ['Job Title']).each do |col|
44
- entry[col] = row[col] == 'TRUE'
43
+ (row.headers - ["Job Title"]).each do |col|
44
+ entry[col] = row[col] == "TRUE"
45
45
  end
46
46
  entry
47
47
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'open-uri'
4
- require 'csv'
3
+ require "open-uri"
4
+ require "csv"
5
5
 
6
6
  module Ogam
7
7
  # Allows working with a list of approved organisations
8
8
  class Organisation
9
9
  static_facade :all
10
10
 
11
- CSV_URL = 'https://docs.google.com/spreadsheets/d/12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60/export?format=csv&id=12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60&gid=46181347'
11
+ CSV_URL = "https://docs.google.com/spreadsheets/d/12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60/export?format=csv&id=12nl5OBGSmOSsWilzWfflmAHO-8EyfCjVXYLeUDqjB60&gid=46181347"
12
12
 
13
13
  def all
14
14
  @all ||= parse(download)
@@ -17,16 +17,16 @@ module Ogam
17
17
  private
18
18
 
19
19
  def download
20
- puts 'Fetching list of accepted organisations'
20
+ puts "Fetching list of accepted organisations"
21
21
  URI.parse(CSV_URL).read
22
22
  end
23
23
 
24
24
  def parse(str)
25
25
  data = {}
26
26
  CSV.parse(str, headers: true).each do |row|
27
- next if row['Domain'].blank?
27
+ next if row["Domain"].blank?
28
28
 
29
- data[row['Domain'].strip] = row['Organisation Name'].strip
29
+ data[row["Domain"].strip] = row["Organisation Name"].strip
30
30
  end
31
31
 
32
32
  data
@@ -4,11 +4,11 @@ module Ogam
4
4
  # Methods relating to signatures
5
5
  class Signature
6
6
  def self.update_signature_command(user)
7
- email = user.fetch('primaryEmail')
7
+ email = user.fetch("primaryEmail")
8
8
  html = signature_html(
9
- user.fetch('name.fullName', nil),
10
- user.fetch('organizations.0.title', nil),
11
- user.fetch('organizations.0.name', nil)
9
+ user.fetch("name.fullName", nil),
10
+ user.fetch("organizations.0.title", nil),
11
+ user.fetch("organizations.0.name", nil)
12
12
  )
13
13
 
14
14
  "gam user #{email} signature \"#{html}\""
@@ -16,7 +16,7 @@ module Ogam
16
16
 
17
17
  def self.signature_html(name, job_title, organisation)
18
18
  parts = [name, job_title, organisation].reject(&:blank?)
19
- "<p>#{parts.join('<br />')}</p><hr color=#5b3293 />"
19
+ "<p>#{parts.join("<br />")}</p><hr color=#5b3293 />"
20
20
  end
21
21
  end
22
22
  end
@@ -15,7 +15,7 @@ module Ogam
15
15
  end
16
16
 
17
17
  def self.job_titles_for_user(user)
18
- JobTitle.job_titles(user['organizations.0.title'])
18
+ JobTitle.job_titles(user["organizations.0.title"])
19
19
  end
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ogam
4
- VERSION = '1.1.0'
4
+ VERSION = "1.3.2"
5
5
  end
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'ogam/version'
5
+ require "ogam/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'ogam'
9
- spec.version = Ogam::VERSION
10
- spec.authors = ['Elliot Bowes']
11
- spec.email = ['e.bowes@outwood.com']
8
+ spec.name = "ogam"
9
+ spec.version = Ogam::VERSION
10
+ spec.authors = ["Elliot Bowes"]
11
+ spec.email = ["e.bowes@outwood.com"]
12
12
 
13
- spec.summary = "Wrapper around GAM for common tasks with OGAT's G Suite instance."
13
+ spec.summary = "Wrapper around GAM for common tasks with OGAT's G Suite instance."
14
14
  # spec.description = %q{TODO: Write a longer description or delete this line.}
15
- spec.homepage = 'https://github.com/Outwood/ogam'
16
- spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata['source_code_uri'] = 'https://github.com/Outwood/ogam'
15
+ spec.homepage = "https://github.com/Outwood/ogam"
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/Outwood/ogam"
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -22,17 +22,17 @@ Gem::Specification.new do |spec|
22
22
  Dir.chdir(File.expand_path(__dir__)) do
23
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
24
  end
25
- spec.bindir = 'bin'
26
- spec.executables << 'ogam'
27
- spec.require_paths = ['lib']
25
+ spec.bindir = "bin"
26
+ spec.executables << "ogam"
27
+ spec.require_paths = ["lib"]
28
28
 
29
- spec.add_runtime_dependency 'activesupport', '~> 6.0.2'
30
- spec.add_runtime_dependency 'attr_extras', '~> 6.2.3'
31
- spec.add_runtime_dependency 'thor', '~> 1.0.1'
29
+ spec.add_runtime_dependency "activesupport", "~> 6.0.2"
30
+ spec.add_runtime_dependency "attr_extras", "~> 6.2.3"
31
+ spec.add_runtime_dependency "thor", "~> 1.0.1"
32
32
 
33
- spec.add_development_dependency 'bundler', '~> 2.1'
34
- spec.add_development_dependency 'rake', '~> 13.0'
35
- spec.add_development_dependency 'rspec', '~> 3.0'
36
- spec.add_development_dependency 'rubocop-ogat', '~> 1.47.0'
37
- spec.add_development_dependency 'simplecov', '~> 0.18.4'
33
+ spec.add_development_dependency "bundler", "~> 2.1"
34
+ spec.add_development_dependency "rake", "~> 13.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "rubocop-ogat", "~> 2.6.0"
37
+ spec.add_development_dependency "simplecov", "~> 0.18.4"
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ogam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Bowes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-27 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.47.0
103
+ version: 2.6.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.47.0
110
+ version: 2.6.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +133,6 @@ files:
133
133
  - ".gitignore"
134
134
  - ".rspec"
135
135
  - ".rubocop.yml"
136
- - ".rubocop_metrics_todo.yml"
137
136
  - ".rubocop_todo.yml"
138
137
  - ".ruby-version"
139
138
  - ".travis.yml"
@@ -1,59 +0,0 @@
1
- Metrics/AbcSize:
2
- Exclude:
3
- - db/**/*
4
- - spec/**/*
5
- - config/routes.rb
6
- - lib/ogam/group_assigner.rb
7
-
8
- Metrics/BlockLength:
9
- Exclude:
10
- - db/**/*
11
- - spec/**/*
12
- - config/routes.rb
13
-
14
- Metrics/BlockNesting:
15
- Exclude:
16
- - db/**/*
17
- - spec/**/*
18
- - config/routes.rb
19
-
20
- Metrics/ClassLength:
21
- Exclude:
22
- - db/**/*
23
- - spec/**/*
24
- - config/routes.rb
25
- - lib/ogam/group_assigner.rb
26
-
27
- Metrics/CyclomaticComplexity:
28
- Exclude:
29
- - db/**/*
30
- - spec/**/*
31
- - config/routes.rb
32
- - lib/ogam/group_assigner.rb
33
-
34
- Metrics/MethodLength:
35
- Exclude:
36
- - db/**/*
37
- - spec/**/*
38
- - config/routes.rb
39
- - lib/ogam/group_assigner.rb
40
-
41
- Metrics/ModuleLength:
42
- Exclude:
43
- - db/**/*
44
- - spec/**/*
45
- - config/routes.rb
46
-
47
- Metrics/ParameterLists:
48
- Exclude:
49
- - db/**/*
50
- - spec/**/*
51
- - config/routes.rb
52
-
53
- Metrics/PerceivedComplexity:
54
- Exclude:
55
- - db/**/*
56
- - spec/**/*
57
- - config/routes.rb
58
- - lib/ogam/group_assigner.rb
59
-