Class: Toolshed::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/toolshed/client.rb

Constant Summary collapse

GITHUB_BASE_API_URL =
"https://api.github.com/"
PIVOTAL_TRACKER_BASE_API_URL =
"https://www.pivotaltracker.com/services/v5/"

Class Method Summary collapse

Class Method Details

.config_pathObject



237
238
239
# File 'lib/toolshed/client.rb', line 237

def self.config_path
  ENV['TOOLSHED_CONFIG'] || '~/.toolshedrc'
end

.credentials_loaded?Boolean

Returns:

  • (Boolean)


272
273
274
# File 'lib/toolshed/client.rb', line 272

def self.credentials_loaded?
  (@credentials_loaded ||= false)
end

.debug=(debug) ⇒ Object



14
15
16
# File 'lib/toolshed/client.rb', line 14

def self.debug=(debug)
  @debug = debug
end

.debug?Boolean

debugging options

Returns:

  • (Boolean)


10
11
12
# File 'lib/toolshed/client.rb', line 10

def self.debug?
  @debug
end

.default_pivotal_tracker_project_idObject



135
136
137
# File 'lib/toolshed/client.rb', line 135

def self.default_pivotal_tracker_project_id
  @default_pivotal_tracker_project_id
end

.default_pivotal_tracker_project_id=(default_pivotal_tracker_project_id) ⇒ Object



139
140
141
# File 'lib/toolshed/client.rb', line 139

def self.default_pivotal_tracker_project_id=(default_pivotal_tracker_project_id)
  @default_pivotal_tracker_project_id = default_pivotal_tracker_project_id
end

.default_ticket_tracker_projectObject



159
160
161
# File 'lib/toolshed/client.rb', line 159

def self.default_ticket_tracker_project
  @default_ticket_tracker_project
end

.default_ticket_tracker_project=(default_ticket_tracker_project) ⇒ Object



163
164
165
# File 'lib/toolshed/client.rb', line 163

def self.default_ticket_tracker_project=(default_ticket_tracker_project)
  @default_ticket_tracker_project = default_ticket_tracker_project
end

.git_quietObject



18
19
20
# File 'lib/toolshed/client.rb', line 18

def self.git_quiet
  @git_quiet
end

.git_quiet=(git_quiet) ⇒ Object



22
23
24
# File 'lib/toolshed/client.rb', line 22

def self.git_quiet=(git_quiet)
  @git_quiet = git_quiet
end

.git_toolObject



108
109
110
# File 'lib/toolshed/client.rb', line 108

def self.git_tool
  (@git_tool.nil?) ? Toolshed::Git::DEFAULT_GIT_TOOL : @git_tool
end

.git_tool=(git_tool) ⇒ Object



112
113
114
# File 'lib/toolshed/client.rb', line 112

def self.git_tool=(git_tool)
  @git_tool = git_tool
end

.github_passwordObject



44
45
46
# File 'lib/toolshed/client.rb', line 44

def self.github_password
  @github_password
end

.github_password=(password) ⇒ Object



48
49
50
# File 'lib/toolshed/client.rb', line 48

def self.github_password=(password)
  @github_password = password
end

.github_tokenObject



52
53
54
# File 'lib/toolshed/client.rb', line 52

def self.github_token
  @github_token
end

.github_token=(token) ⇒ Object



56
57
58
# File 'lib/toolshed/client.rb', line 56

def self.github_token=(token)
  @github_token = token
end

.github_usernameObject

github config settings



36
37
38
# File 'lib/toolshed/client.rb', line 36

def self.github_username
  @github_username
end

.github_username=(username) ⇒ Object



40
41
42
# File 'lib/toolshed/client.rb', line 40

def self.github_username=(username)
  @github_username = username
end

.load_credentials(path = config_path) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/toolshed/client.rb', line 241

def self.load_credentials(path = config_path)
  credentials = Client.read_credenials(config_path)
  self.github_username                    ||= credentials['github_username']
  self.github_password                    ||= credentials['github_password']
  self.github_token                       ||= credentials['github_token']
  self.pivotal_tracker_username           ||= credentials['pivotal_tracker_username']
  self.pivotal_tracker_password           ||= credentials['pivotal_tracker_password']
  self.default_pivotal_tracker_project_id ||= credentials['default_pivotal_tracker_project_id']
  self.ticket_tracker_username            ||= credentials['ticket_tracker_username']
  self.ticket_tracker_password            ||= credentials['ticket_tracker_password']
  self.ticket_tracker_owner               ||= credentials['ticket_tracker_owner']
  self.ticket_status_for_complete         ||= credentials['ticket_status_for_complete']
  self.default_ticket_tracker_project     ||= credentials['default_ticket_tracker_project']
  self.pull_from_remote_name              ||= credentials['pull_from_remote_name']
  self.pull_from_repository_user          ||= credentials['pull_from_repository_user']
  self.pull_from_repository_name          ||= credentials['pull_from_repository_name']
  self.push_to_repository_user            ||= credentials['push_to_repository_user']
  self.push_to_remote_name                ||= credentials['push_to_remote_name']
  self.ticket_tracking_tool               ||= credentials['ticket_tracking_tool']
  self.use_git_submodules                 ||= credentials['use_git_submodules']
  self.git_tool                           ||= credentials['git_tool']
  self.time_tracking_username             ||= credentials['time_tracking_username']
  self.time_tracking_password             ||= credentials['time_tracking_password']
  self.time_tracking_owner                ||= credentials['time_tracking_owner']
  self.time_tracking_default_project_id   ||= credentials['time_tracking_default_project_id']
  self.time_tracking_tool                 ||= credentials['time_tracking_tool']
  self.git_quiet                          ||= (credentials['git_quiet']) ? '&> /dev/null' : ''
  self.use_defaults                       ||= credentials['use_defaults']
  @credentials_loaded = true
end

.load_credentials_if_necessaryObject



233
234
235
# File 'lib/toolshed/client.rb', line 233

def self.load_credentials_if_necessary
  load_credentials unless credentials_loaded?
end

.pivotal_tracker_passwordObject



127
128
129
# File 'lib/toolshed/client.rb', line 127

def self.pivotal_tracker_password
  @pivotal_tracker_password
end

.pivotal_tracker_password=(password) ⇒ Object



131
132
133
# File 'lib/toolshed/client.rb', line 131

def self.pivotal_tracker_password=(password)
  @pivotal_tracker_password = password
end

.pivotal_tracker_usernameObject

ticket tracking information



119
120
121
# File 'lib/toolshed/client.rb', line 119

def self.pivotal_tracker_username
  @pivotal_tracker_username
end

.pivotal_tracker_username=(username) ⇒ Object



123
124
125
# File 'lib/toolshed/client.rb', line 123

def self.pivotal_tracker_username=(username)
  @pivotal_tracker_username = username
end

.pull_from_remote_nameObject



60
61
62
# File 'lib/toolshed/client.rb', line 60

def self.pull_from_remote_name
  @pull_from_remote_name
end

.pull_from_remote_name=(pull_from_remote_name) ⇒ Object



64
65
66
# File 'lib/toolshed/client.rb', line 64

def self.pull_from_remote_name=(pull_from_remote_name)
  @pull_from_remote_name = pull_from_remote_name
end

.pull_from_repository_nameObject



76
77
78
# File 'lib/toolshed/client.rb', line 76

def self.pull_from_repository_name
  @pull_from_repository_name
end

.pull_from_repository_name=(pull_from_repository_name) ⇒ Object



80
81
82
# File 'lib/toolshed/client.rb', line 80

def self.pull_from_repository_name=(pull_from_repository_name)
  @pull_from_repository_name = pull_from_repository_name
end

.pull_from_repository_userObject



68
69
70
# File 'lib/toolshed/client.rb', line 68

def self.pull_from_repository_user
  @pull_from_repository_user
end

.pull_from_repository_user=(pull_from_repository_user) ⇒ Object



72
73
74
# File 'lib/toolshed/client.rb', line 72

def self.pull_from_repository_user=(pull_from_repository_user)
  @pull_from_repository_user = pull_from_repository_user
end

.push_to_remote_nameObject



92
93
94
# File 'lib/toolshed/client.rb', line 92

def self.push_to_remote_name
  @push_to_remote_name
end

.push_to_remote_name=(push_to_remote_name) ⇒ Object



96
97
98
# File 'lib/toolshed/client.rb', line 96

def self.push_to_remote_name=(push_to_remote_name)
  @push_to_remote_name = push_to_remote_name
end

.push_to_repository_userObject



84
85
86
# File 'lib/toolshed/client.rb', line 84

def self.push_to_repository_user
  @push_to_repository_user
end

.push_to_repository_user=(push_to_repository_user) ⇒ Object



88
89
90
# File 'lib/toolshed/client.rb', line 88

def self.push_to_repository_user=(push_to_repository_user)
  @push_to_repository_user = push_to_repository_user
end

.read_credenials(path = Client.config_path) ⇒ Object



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/toolshed/client.rb', line 276

def self.read_credenials(path = Client.config_path)
  begin
    dir = Dir.pwd
    while File.expand_path(dir) != '/' do
      if (File.exists? "#{dir}/.toolshedrc")
        loaded_from_path = "#{dir}/.toolshedrc"
        break
      elsif (File.exists? "#{dir}/.toolshed")
        loaded_from_path = "#{dir}/.toolshed"
        warn "[DEPRECATION] `.toolshed` file is being deprecated.  Please use a `.toolshedrc` file instead."
        break
      end

      dir = File.join dir, '..'
    end

    puts "Credentials loaded from #{File.absolute_path(loaded_from_path)}"
    credentials = YAML.load_file(File.expand_path(loaded_from_path))
  rescue => error
    puts "Error loading your credentials: #{error.message}"
    exit 1
  end
end

.ticket_status_for_completeObject



183
184
185
# File 'lib/toolshed/client.rb', line 183

def self.ticket_status_for_complete
  @ticket_status_for_complete
end

.ticket_status_for_complete=(status) ⇒ Object



187
188
189
# File 'lib/toolshed/client.rb', line 187

def self.ticket_status_for_complete=(status)
  @ticket_status_for_complete = status
end

.ticket_tracker_ownerObject



175
176
177
# File 'lib/toolshed/client.rb', line 175

def self.ticket_tracker_owner
  @ticket_tracker_owner
end

.ticket_tracker_owner=(owner) ⇒ Object



179
180
181
# File 'lib/toolshed/client.rb', line 179

def self.ticket_tracker_owner=(owner)
  @ticket_tracker_owner = owner
end

.ticket_tracker_passwordObject



151
152
153
# File 'lib/toolshed/client.rb', line 151

def self.ticket_tracker_password
  @ticket_tracker_password
end

.ticket_tracker_password=(password) ⇒ Object



155
156
157
# File 'lib/toolshed/client.rb', line 155

def self.ticket_tracker_password=(password)
  @ticket_tracker_password = password
end

.ticket_tracker_usernameObject



143
144
145
# File 'lib/toolshed/client.rb', line 143

def self.ticket_tracker_username
  @ticket_tracker_username
end

.ticket_tracker_username=(username) ⇒ Object



147
148
149
# File 'lib/toolshed/client.rb', line 147

def self.ticket_tracker_username=(username)
  @ticket_tracker_username = username
end

.ticket_tracking_toolObject



167
168
169
# File 'lib/toolshed/client.rb', line 167

def self.ticket_tracking_tool
  @ticket_tracking_tool
end

.ticket_tracking_tool=(ticket_tracking_tool) ⇒ Object



171
172
173
# File 'lib/toolshed/client.rb', line 171

def self.ticket_tracking_tool=(ticket_tracking_tool)
  @ticket_tracking_tool = ticket_tracking_tool
end

.time_tracking_default_project_idObject



225
226
227
# File 'lib/toolshed/client.rb', line 225

def self.time_tracking_default_project_id
  @time_tracking_default_project_id
end

.time_tracking_default_project_id=(time_tracking_default_project_id) ⇒ Object



229
230
231
# File 'lib/toolshed/client.rb', line 229

def self.time_tracking_default_project_id=(time_tracking_default_project_id)
  @time_tracking_default_project_id = time_tracking_default_project_id
end

.time_tracking_ownerObject



217
218
219
# File 'lib/toolshed/client.rb', line 217

def self.time_tracking_owner
  @time_tracking_owner
end

.time_tracking_owner=(time_tracking_owner) ⇒ Object



221
222
223
# File 'lib/toolshed/client.rb', line 221

def self.time_tracking_owner=(time_tracking_owner)
  @time_tracking_owner = time_tracking_owner
end

.time_tracking_passwordObject



209
210
211
# File 'lib/toolshed/client.rb', line 209

def self.time_tracking_password
  @time_tracking_password
end

.time_tracking_password=(time_tracking_password) ⇒ Object



213
214
215
# File 'lib/toolshed/client.rb', line 213

def self.time_tracking_password=(time_tracking_password)
  @time_tracking_password = time_tracking_password
end

.time_tracking_toolObject

time tracking configuration



193
194
195
# File 'lib/toolshed/client.rb', line 193

def self.time_tracking_tool
  @time_tracking_tool
end

.time_tracking_tool=(time_tracking_tool) ⇒ Object



197
198
199
# File 'lib/toolshed/client.rb', line 197

def self.time_tracking_tool=(time_tracking_tool)
  @time_tracking_tool = time_tracking_tool
end

.time_tracking_usernameObject



201
202
203
# File 'lib/toolshed/client.rb', line 201

def self.time_tracking_username
  @time_tracking_username
end

.time_tracking_username=(time_tracking_username) ⇒ Object



205
206
207
# File 'lib/toolshed/client.rb', line 205

def self.time_tracking_username=(time_tracking_username)
  @time_tracking_username = time_tracking_username
end

.use_defaultsObject



26
27
28
# File 'lib/toolshed/client.rb', line 26

def self.use_defaults
  @use_defaults
end

.use_defaults=(use_defaults) ⇒ Object



30
31
32
# File 'lib/toolshed/client.rb', line 30

def self.use_defaults=(use_defaults)
  @use_defaults = use_defaults
end

.use_git_submodulesObject



100
101
102
# File 'lib/toolshed/client.rb', line 100

def self.use_git_submodules
  @use_git_submodules
end

.use_git_submodules=(use_git_submodules) ⇒ Object



104
105
106
# File 'lib/toolshed/client.rb', line 104

def self.use_git_submodules=(use_git_submodules)
  @use_git_submodules = use_git_submodules
end