Module: Redminerb

Defined in:
lib/redminerb.rb,
lib/redminerb/cli.rb,
lib/redminerb/users.rb,
lib/redminerb/client.rb,
lib/redminerb/config.rb,
lib/redminerb/issues.rb,
lib/redminerb/version.rb,
lib/redminerb/projects.rb,
lib/redminerb/template.rb,
lib/redminerb/cli/users.rb,
lib/redminerb/cli/issues.rb,
lib/redminerb/cli/projects.rb

Overview

Copyright © The Cocktail Experience S.L. (2015)

Defined Under Namespace

Modules: Cli Classes: CLI, Client, Config, Issues, NotFoundError, Projects, Template, UninitializedError, Users

Constant Summary collapse

VERSION =
'0.7.2'

Class Method Summary collapse

Class Method Details

.bottomObject



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

def bottom
  '' + separator[0..-3] + ''
end

.clientObject



50
51
52
53
# File 'lib/redminerb.rb', line 50

def client
  init_required!
  @client
end

.configObject



45
46
47
48
# File 'lib/redminerb.rb', line 45

def config
  init_required!
  @config
end

.end!Object

NOTICE: method needed by the build. Clean the module for the next test.



31
32
33
34
35
# File 'lib/redminerb.rb', line 31

def end!
  @initialized = false
  @config = nil
  @client = nil
end

.fill_with_spaces(string) ⇒ Object



85
86
87
# File 'lib/redminerb.rb', line 85

def fill_with_spaces(string)
  ' ' * (max_length - string.size)
end

.init!Object

Module initialization needed before doing anything. It looks ~/.redminerb.yml to get the authentication info to connect with the Redmine REST API.

Example:

>> Reminerb.init!
=> true


24
25
26
27
28
# File 'lib/redminerb.rb', line 24

def init!
  @initialized = true
  @config = Redminerb::Config.new
  @client = Redminerb::Client.new(@config)
end

.init_required!Object



41
42
43
# File 'lib/redminerb.rb', line 41

def init_required!
  fail(UninitializedError, 'call Redminerb.init! first') unless @initialized
end

.initialized?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/redminerb.rb', line 37

def initialized?
  @initialized
end

.line(string) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/redminerb.rb', line 76

def line(string)
  uncolorized = string.uncolorize
  if uncolorized.size > max_length
    "#{string[0..(max_length - 1)]} │\n#{line(string[max_length..-1])}" if string
  else
    "#{string}#{fill_with_spaces(uncolorized)}"
  end
end

.max_lengthObject



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

def max_length
  TermInfo.screen_columns - 4
end

.middleObject



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

def middle
  '' + separator[0..-3] + ''
end

.separatorObject

ASCII old-school box’s part output functions



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

def separator
  @separator ||= '' * TermInfo.screen_columns
end

.topObject



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

def top
  '' + separator[0..-3] + ''
end