Class: Gitomator::Service::Hosting

Inherits:
BaseService show all
Defined in:
lib/gitomator/service/hosting.rb

Instance Attribute Summary

Attributes inherited from BaseService

#provider

Instance Method Summary collapse

Methods inherited from BaseService

#after_each_service_call, #before_each_service_call, #on_service_call_error, #service_call

Constructor Details

#initialize(provider, opts = {}) ⇒ Hosting

Returns a new instance of Hosting.



9
10
11
12
13
# File 'lib/gitomator/service/hosting.rb', line 9

def initialize(provider, opts = {})
  super(provider, opts)
  @name_resolver = Gitomator::Util::Repo::NameResolver.new(
    provider.respond_to?(:namespace) ? provider.namespace : nil)
end

Instance Method Details

#close_pull_request(dst_repo, id) ⇒ Object



179
180
181
# File 'lib/gitomator/service/hosting.rb', line 179

def close_pull_request(dst_repo, id)
  service_call(__callee__, dst_repo, id)
end

#create_pull_request(src, dst, opts = {}) ⇒ Object



157
158
159
# File 'lib/gitomator/service/hosting.rb', line 157

def create_pull_request(src, dst, opts = {})
  service_call(__callee__, src, dst, opts)
end

#create_repo(name, opts = {}) ⇒ Object

———————– CRUD operations on repos ———————–



31
32
33
# File 'lib/gitomator/service/hosting.rb', line 31

def create_repo(name, opts={})
  service_call(__callee__, name, opts)
end

#create_team(name, opts = {}) ⇒ Object

———————– CRUD operations on teams ———————



53
54
55
# File 'lib/gitomator/service/hosting.rb', line 53

def create_team(name, opts={})
  service_call(__callee__, name, opts)
end

#create_team_membership(team_name, user_name, role = nil) ⇒ Object

Parameters:

  • team_name (String)
  • user_name (String)
  • role (String) (defaults to: nil)


87
88
89
90
91
92
93
94
95
96
# File 'lib/gitomator/service/hosting.rb', line 87

def create_team_membership(team_name, user_name, role=nil)
  # The if/else block is here so that different providers can implement
  # the `create_team_membership` with a default value for the role argument.
  if role.nil?
    service_call(__callee__, team_name, user_name)
  else
    service_call(__callee__, team_name, user_name, role)
  end

end

#delete_pull_request(dst_repo, id) ⇒ Object



197
198
199
# File 'lib/gitomator/service/hosting.rb', line 197

def delete_pull_request(dst_repo, id)
  service_call(__callee__, dst_repo, id)
end

#delete_repo(name) ⇒ Object



43
44
45
# File 'lib/gitomator/service/hosting.rb', line 43

def delete_repo(name)
  service_call(__callee__, name)
end

#delete_team(name) ⇒ Object



65
66
67
# File 'lib/gitomator/service/hosting.rb', line 65

def delete_team(name)
  service_call(__callee__, name)
end

#delete_team_membership(team_name, user_name) ⇒ Object

Parameters:

  • team_name (String)
  • user_name (String)


121
122
123
# File 'lib/gitomator/service/hosting.rb', line 121

def delete_team_membership(team_name, user_name)
  service_call(__callee__, team_name, user_name)
end

#merge_pull_request(dst_repo, id, message = '') ⇒ Object



175
176
177
# File 'lib/gitomator/service/hosting.rb', line 175

def merge_pull_request(dst_repo, id, message='')
  service_call(__callee__, dst_repo, id, message)
end

#open_pull_request(dst_repo, id) ⇒ Object



183
184
185
# File 'lib/gitomator/service/hosting.rb', line 183

def open_pull_request(dst_repo, id)
  service_call(__callee__, dst_repo, id)
end

#read_pull_request(dst_repo, id) ⇒ Object



163
164
165
# File 'lib/gitomator/service/hosting.rb', line 163

def read_pull_request(dst_repo, id)
  service_call(__callee__, dst_repo, id)
end

#read_pull_requests(dst_repo, opts = {}) ⇒ Object



167
168
169
# File 'lib/gitomator/service/hosting.rb', line 167

def read_pull_requests(dst_repo, opts = {})
  service_call(__callee__, dst_repo, opts)
end

#read_repo(name) ⇒ Object



35
36
37
# File 'lib/gitomator/service/hosting.rb', line 35

def read_repo(name)
  service_call(__callee__, name)
end

#read_team(name) ⇒ Object



57
58
59
# File 'lib/gitomator/service/hosting.rb', line 57

def read_team(name)
  service_call(__callee__, name)
end

#read_team_membership(team_name, user_name) ⇒ String

Returns The current role of user_name in team_name, or nil (if the user is not a member of the team).

Parameters:

  • team_name (String)
  • user_name (String)

Returns:

  • (String)

    The current role of user_name in team_name, or nil (if the user is not a member of the team)



104
105
106
# File 'lib/gitomator/service/hosting.rb', line 104

def read_team_membership(team_name, user_name)
  service_call(__callee__, team_name, user_name)
end

#resolve_branch(name) ⇒ Object



25
26
27
# File 'lib/gitomator/service/hosting.rb', line 25

def resolve_branch(name)
  @name_resolver.branch(name)
end

#resolve_namespace(name) ⇒ Object

—————————- Name resolution —————————



17
18
19
# File 'lib/gitomator/service/hosting.rb', line 17

def resolve_namespace(name)
  @name_resolver.namespace(name)
end

#resolve_repo_name(name) ⇒ Object



21
22
23
# File 'lib/gitomator/service/hosting.rb', line 21

def resolve_repo_name(name)
  @name_resolver.name_only(name)
end

#search_repos(query, opts = {}) ⇒ Object



47
48
49
# File 'lib/gitomator/service/hosting.rb', line 47

def search_repos(query, opts={})
  service_call(__callee__, query, opts)
end

#search_teams(query, opts = {}) ⇒ Object



69
70
71
# File 'lib/gitomator/service/hosting.rb', line 69

def search_teams(query, opts={})
  service_call(__callee__, query, opts)
end

#search_users(query, opts = {}) ⇒ Object




75
76
77
# File 'lib/gitomator/service/hosting.rb', line 75

def search_users(query, opts={})
  service_call(__callee__, query, opts)
end

#set_team_permission(team, repo, permission) ⇒ Object

Parameters:

  • user (String)

    username

  • team (String)

    Team name

  • permission (Symbol)

    Either :read or :write or nil



141
142
143
# File 'lib/gitomator/service/hosting.rb', line 141

def set_team_permission(team, repo, permission)
  service_call(__callee__, team, repo, permission)
end

#set_user_permission(user, repo, permission) ⇒ Object

Parameters:

  • user (String)

    username

  • repo (String)

    Repo name (full name, or repo-only)

  • permission (Symbol)

    Either :read or :write or nil



132
133
134
# File 'lib/gitomator/service/hosting.rb', line 132

def set_user_permission(user, repo, permission)
  service_call(__callee__, user, repo, permission)
end

#update_pull_request(dst_repo, id, opts) ⇒ Object

A “general-purpose” update method for pull-requests.



191
192
193
# File 'lib/gitomator/service/hosting.rb', line 191

def update_pull_request(dst_repo, id, opts)
  service_call(__callee__, dst_repo, id)
end

#update_repo(name, opts = {}) ⇒ Object



39
40
41
# File 'lib/gitomator/service/hosting.rb', line 39

def update_repo(name, opts={})
  service_call(__callee__, name, opts)
end

#update_team(name, opts = {}) ⇒ Object



61
62
63
# File 'lib/gitomator/service/hosting.rb', line 61

def update_team(name, opts={})
  service_call(__callee__, name, opts)
end

#update_team_membership(team_name, user_name, role) ⇒ Object

Parameters:

  • team_name (String)
  • user_name (String)
  • role (String)


113
114
115
# File 'lib/gitomator/service/hosting.rb', line 113

def update_team_membership(team_name, user_name, role)
  service_call(__callee__, team_name, user_name, role)
end