Class: Gitlab::FogbugzImport::Client
- Inherits:
-
Object
- Object
- Gitlab::FogbugzImport::Client
- Defined in:
- lib/gitlab/fogbugz_import/client.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
- #cases(project_id) ⇒ Object
- #categories ⇒ Object
- #get_token ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #repo(id) ⇒ Object
- #repos ⇒ Object
- #user_map ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 8 def initialize( = {}) if [:uri] && [:token] @api = ::Fogbugz::Interface.new() elsif [:uri] && [:email] && [:password] @api = ::Fogbugz::Interface.new() @api.authenticate @api end end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 6 def api @api end |
Instance Method Details
#cases(project_id) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 44 def cases(project_id) project_name = repo(project_id).name res = @api.command(:search, q: "project:'#{project_name}'", cols: 'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events') return [] unless res['cases']['count'].to_i > 0 res['cases']['case'] end |
#categories ⇒ Object
52 53 54 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 52 def categories @api.command(:listCategories) end |
#get_token ⇒ Object
18 19 20 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 18 def get_token @api.token end |
#repo(id) ⇒ Object
40 41 42 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 40 def repo(id) repos.find { |r| r.id.to_s == id.to_s } end |
#repos ⇒ Object
35 36 37 38 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 35 def repos res = @api.command(:listProjects) @repos ||= res['projects']['project'].map { |proj| FogbugzImport::Repository.new(proj) } end |
#user_map ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 26 def user_map users = {} res = @api.command(:listPeople) [res['people']['person']].flatten.each do |user| users[user['ixPerson']] = { name: user['sFullName'], email: user['sEmail'] } end users end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/gitlab/fogbugz_import/client.rb', line 22 def valid? !get_token.blank? end |