Class: Gitlab::GoogleCodeImport::Client
- Inherits:
-
Object
- Object
- Gitlab::GoogleCodeImport::Client
- Defined in:
- lib/gitlab/google_code_import/client.rb
Instance Attribute Summary collapse
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Class Method Summary collapse
Instance Method Summary collapse
- #incompatible_repos ⇒ Object
-
#initialize(raw_data) ⇒ Client
constructor
A new instance of Client.
- #repo(id) ⇒ Object
- #repos ⇒ Object
- #user_map ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(raw_data) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/gitlab/google_code_import/client.rb', line 14 def initialize(raw_data) @raw_data = raw_data end |
Instance Attribute Details
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data
6 7 8 |
# File 'lib/gitlab/google_code_import/client.rb', line 6 def raw_data @raw_data end |
Class Method Details
.mask_email(author) ⇒ Object
8 9 10 11 12 |
# File 'lib/gitlab/google_code_import/client.rb', line 8 def self.mask_email() parts = .split("@", 2) parts[0] = "#{parts[0][0...-3]}..." parts.join("@") end |
Instance Method Details
#incompatible_repos ⇒ Object
26 27 28 |
# File 'lib/gitlab/google_code_import/client.rb', line 26 def incompatible_repos @incompatible_repos ||= raw_data["projects"].map { |raw_repo| GoogleCodeImport::Repository.new(raw_repo) }.reject(&:git?) end |
#repo(id) ⇒ Object
30 31 32 |
# File 'lib/gitlab/google_code_import/client.rb', line 30 def repo(id) repos.find { |repo| repo.id == id } end |
#repos ⇒ Object
22 23 24 |
# File 'lib/gitlab/google_code_import/client.rb', line 22 def repos @repos ||= raw_data["projects"].map { |raw_repo| GoogleCodeImport::Repository.new(raw_repo) }.select(&:git?) end |
#user_map ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gitlab/google_code_import/client.rb', line 34 def user_map user_map = Hash.new { |hash, user| hash[user] = self.class.mask_email(user) } repos.each do |repo| next unless repo.valid? && repo.issues repo.issues.each do |raw_issue| # Touching is enough to add the entry and masked email. user_map[raw_issue["author"]["name"]] raw_issue["comments"]["items"].each do |raw_comment| user_map[raw_comment["author"]["name"]] end end end Hash[user_map.sort] end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/gitlab/google_code_import/client.rb', line 18 def valid? raw_data.is_a?(Hash) && raw_data["kind"] == "projecthosting#user" && raw_data.key?("projects") end |