teachers_pet 0.3.1 → 0.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
  SHA1:
3
- metadata.gz: 293791f01ea48c84167c90902b2c746751617ac1
4
- data.tar.gz: 33d7f890862a1d527fd265e7882b690807eb9300
3
+ metadata.gz: 813064fc57381e80d03d7c3743cf2b77a295e50c
4
+ data.tar.gz: 8209de5e067d2ae7c97259a9d991dfd49eba4058
5
5
  SHA512:
6
- metadata.gz: 0af8b9fb762e2d8e895bfd6e821392205ef3e789c9f911ad12df226785397b10b52d7cb7b196b050308e817493844807f368378dcf251dc0592cc852ce81e535
7
- data.tar.gz: 76906e2fb2c0e443e21d6b7f9ccd7f493796a1eddaf90aaa397c825637af2052c79b65103ad9538c4d593ab164ac5d482d4fa32a778e8c75a7eeb941e8aa4c87
6
+ metadata.gz: 41e6db46507899a90c0aff59d168b2c4f8091c43fd76fdd5580bddbea563a56b18f353013ab46310ea94fdbc8e50dcfe41210def8942a9eba9beaae21f0b2579
7
+ data.tar.gz: 96e44bd2c0c615688c21803076cc4640dfc8de7d830a75d1c2d63ac025c8bc90e0c42621d73b509187109aac8ace30405ac134b42934a636ac531e280d4c85be
@@ -2,24 +2,25 @@ module TeachersPet
2
2
  module Actions
3
3
  class AddToTeam < Base
4
4
  def read_members_file
5
- file = self.members
5
+ file = self.options[:members]
6
6
  puts "Loading members to add:"
7
7
  read_file(file).keys
8
8
  end
9
9
 
10
10
  def team_name
11
- file = self.members
11
+ file = self.options[:members]
12
12
  File.basename(file, File.extname(file))
13
13
  end
14
14
 
15
15
  def team
16
- teams_by_name = self.client.existing_teams_by_name(self.organization)
17
- teams_by_name[self.team_name] || self.client.create_team(self.organization, team_name)
16
+ org_login = self.options[:organization]
17
+ teams_by_name = self.client.existing_teams_by_name(org_login)
18
+ teams_by_name[self.team_name] || self.client.create_team(org_login, team_name)
18
19
  end
19
20
 
20
21
  def add_members_to_owners
21
22
  member_list = self.read_members_file
22
- self.client.add_users_to_team(organization, self.team, member_list)
23
+ self.client.add_users_to_team(self.options[:organization], self.team, member_list)
23
24
  end
24
25
 
25
26
  def run
@@ -11,29 +11,21 @@ module TeachersPet
11
11
  @options = opts.symbolize_keys
12
12
  end
13
13
 
14
- def method_missing(meth, *args, &block)
15
- # Support boolean options ending, by calling them with '?' at the end
16
- key = meth.to_s.sub(/\?\z/, '').to_sym
17
- if self.options.has_key?(key)
18
- self.options[key]
19
- else
20
- super
21
- end
22
- end
23
-
24
14
  def octokit_config
25
15
  opts = {
26
- api_endpoint: self.api,
27
- web_endpoint: self.web,
28
- login: self.username,
16
+ api_endpoint: self.options[:api],
17
+ web_endpoint: self.options[:web],
18
+ login: self.options[:username],
29
19
  # Organizations can get big, pull in all pages
30
20
  auto_paginate: true
31
21
  }
32
22
 
33
23
  if self.options[:token]
34
- opts[:access_token] = self.token
24
+ opts[:access_token] = self.options[:token]
25
+ elsif self.options[:password]
26
+ opts[:password] = self.options[:password]
35
27
  else
36
- opts[:password] = self.password
28
+ raise Thor::RequiredArgumentMissingError.new("No value provided for option --password or --token")
37
29
  end
38
30
 
39
31
  opts
@@ -77,7 +69,7 @@ module TeachersPet
77
69
  end
78
70
 
79
71
  def read_students_file
80
- student_file = self.students
72
+ student_file = self.options[:students]
81
73
  puts "Loading students:"
82
74
  read_file(student_file)
83
75
  end
@@ -2,8 +2,8 @@ module TeachersPet
2
2
  module Actions
3
3
  class CloneRepos < Base
4
4
  def read_info
5
- @repository = self.repository
6
- @organization = self.organization
5
+ @repository = self.options[:repository]
6
+ @organization = self.options[:organization]
7
7
  end
8
8
 
9
9
  def load_files
@@ -11,7 +11,7 @@ module TeachersPet
11
11
  end
12
12
 
13
13
  def get_clone_method
14
- self.clone_method
14
+ self.options[:clone_method]
15
15
  end
16
16
 
17
17
  def create
@@ -40,11 +40,11 @@ module TeachersPet
40
40
  next
41
41
  end
42
42
 
43
-
44
- sshEndpoint = self.web.gsub("https://","git@").gsub("/",":")
43
+ web = self.options[:web]
44
+ sshEndpoint = web.gsub("https://","git@").gsub("/",":")
45
45
  command = "git clone #{sshEndpoint}#{@organization}/#{repo_name}.git"
46
46
  if cloneMethod.eql?('https')
47
- command = "git clone #{self.web}#{@organization}/#{repo_name}.git"
47
+ command = "git clone #{web}#{@organization}/#{repo_name}.git"
48
48
  end
49
49
  puts " --> Cloning: '#{command}'"
50
50
  self.execute(command)
@@ -2,9 +2,9 @@ module TeachersPet
2
2
  module Actions
3
3
  class CreateRepos < Base
4
4
  def read_info
5
- @repository = self.repository
6
- @organization = self.organization
7
- @public_repos = self.public?
5
+ @repository = self.options[:repository]
6
+ @organization = self.options[:organization]
7
+ @public_repos = self.options[:public]
8
8
  end
9
9
 
10
10
  def load_files
@@ -2,7 +2,8 @@ module TeachersPet
2
2
  module Actions
3
3
  class CreateStudentTeams < Base
4
4
  def create_student_teams
5
- teams_by_name = self.client.existing_teams_by_name(self.organization)
5
+ org_login = self.options[:organization]
6
+ teams_by_name = self.client.existing_teams_by_name(org_login)
6
7
 
7
8
  students_list = self.read_students_file
8
9
  students_list.each do |key, value|
@@ -18,11 +19,11 @@ module TeachersPet
18
19
 
19
20
  team = teams_by_name[team_name]
20
21
  if team
21
- puts "Team @#{organization}/#{team_name} already exists."
22
+ puts "Team @#{org_login}/#{team_name} already exists."
22
23
  else
23
- team = self.client.create_team(organization, team_name)
24
+ team = self.client.create_team(org_login, team_name)
24
25
  end
25
- self.client.add_users_to_team(organization, team, usernames)
26
+ self.client.add_users_to_team(org_login, team, usernames)
26
27
  end
27
28
  end
28
29
 
@@ -1,6 +1,10 @@
1
1
  module TeachersPet
2
2
  module Actions
3
3
  class ForkCollab < Base
4
+ def repository
5
+ self.options[:repository]
6
+ end
7
+
4
8
  def get_forks
5
9
  self.client.forks(self.repository)
6
10
  end
@@ -11,7 +15,7 @@ module TeachersPet
11
15
  forks.each do |fork|
12
16
  login = fork.owner.login
13
17
  if fork.owner.type == "User"
14
- unless self.dry_run?
18
+ unless self.options[:dry_run]
15
19
  result = self.client.add_collab(self.repository, login)
16
20
  end
17
21
  puts "#{login} - #{result}"
@@ -2,16 +2,16 @@ module TeachersPet
2
2
  module Actions
3
3
  class OpenIssue < Base
4
4
  def read_info
5
- @repository = self.repository
6
- @organization = self.organization
5
+ @repository = self.options[:repository]
6
+ @organization = self.options[:organization]
7
7
 
8
8
  @issue = {
9
- title: self.title,
9
+ title: self.options[:title],
10
10
  options: {
11
- labels: self.labels
11
+ labels: self.options[:labels]
12
12
  }
13
13
  }
14
- @issue_file = self.body
14
+ @issue_file = self.options[:body]
15
15
  end
16
16
 
17
17
  def load_files
@@ -2,9 +2,9 @@ module TeachersPet
2
2
  module Actions
3
3
  class PushFiles < Base
4
4
  def read_info
5
- @repository = self.repository
6
- @organization = self.organization
7
- @sshEndpoint = self.ssh
5
+ @repository = self.options[:repository]
6
+ @organization = self.options[:organization]
7
+ @sshEndpoint = self.options[:ssh]
8
8
  end
9
9
 
10
10
  def load_files
@@ -1,3 +1,3 @@
1
1
  module TeachersPet
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -1,6 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe TeachersPet::Actions::Base do
4
+ describe '#octokit_config' do
5
+ it "complains if the password and token are missing" do
6
+ action = TeachersPet::Actions::Base.new
7
+ expect {
8
+ action.octokit_config
9
+ }.to raise_error(Thor::RequiredArgumentMissingError, /--password.+--token/)
10
+ end
11
+
12
+ it "uses the password if provided" do
13
+ action = TeachersPet::Actions::Base.new(password: 'abc123')
14
+ expect(action.octokit_config[:password]).to eq('abc123')
15
+ end
16
+
17
+ it "uses the token if provided" do
18
+ action = TeachersPet::Actions::Base.new(token: 'abc123')
19
+ expect(action.octokit_config[:access_token]).to eq('abc123')
20
+ end
21
+ end
22
+
4
23
  describe '#read_file' do
5
24
  it "returns a hash of usernames by team name" do
6
25
  action = TeachersPet::Actions::Base.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teachers_pet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Britton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport