Class: GitGraph::GitHub::Client
- Inherits:
-
Object
- Object
- GitGraph::GitHub::Client
- Includes:
- Enumerable
- Defined in:
- lib/gitGraph/github/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #add_user(user) ⇒ Object (also: #<<, #+)
- #change_chart_type(graphable_object_name, chart_type) ⇒ Object
- #compare_languages(chart, **options) ⇒ Object
- #each ⇒ Object
- #get_user(key) ⇒ Object (also: #[])
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #remove_user(user) ⇒ Object (also: #-)
- #render(path) ⇒ Object
- #user_count ⇒ Object (also: #user_size)
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitGraph/github/client.rb', line 13 def initialize @client = Octokit::Client.new( login: GitGraph::Configuration.username, password: GitGraph::Configuration.password ) @stored_users = { GitGraph::Configuration.username => @client.user } @data_to_graph = {} end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/gitGraph/github/client.rb', line 10 def client @client end |
Instance Method Details
#add_user(user) ⇒ Object Also known as: <<, +
32 33 34 35 |
# File 'lib/gitGraph/github/client.rb', line 32 def add_user(user) user_to_add = @client.user(user) @stored_users[user_to_add.login] = user_to_add end |
#change_chart_type(graphable_object_name, chart_type) ⇒ Object
49 50 51 |
# File 'lib/gitGraph/github/client.rb', line 49 def change_chart_type(graphable_object_name, chart_type) @data_to_graph[graphable_object_name].chart_type = chart_type end |
#compare_languages(chart, **options) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/gitGraph/github/client.rb', line 57 def compare_languages(chart, **) ||= {} title = .delete(:title) || "Kilobytes Written per Language" data = GitGraph::GitHub::Feature.send(:compare_languages, self) graphable = GitGraph::GitHub::GraphableObject.new(data, chart, , title) @data_to_graph[:languages] = graphable end |
#each ⇒ Object
53 54 55 |
# File 'lib/gitGraph/github/client.rb', line 53 def each @stored_users.each { |name, user| yield(name, user) } end |
#get_user(key) ⇒ Object Also known as: []
27 28 29 |
# File 'lib/gitGraph/github/client.rb', line 27 def get_user(key) @stored_users.fetch(key) end |
#remove_user(user) ⇒ Object Also known as: -
39 40 41 |
# File 'lib/gitGraph/github/client.rb', line 39 def remove_user(user) @stored_users.delete(user) end |
#render(path) ⇒ Object
65 66 67 68 |
# File 'lib/gitGraph/github/client.rb', line 65 def render(path) @data_to_graph.each { |key, data| GitGraph::Renderer.render(data, key, path) } GitGraph::Renderer.copy_files(path) end |
#user_count ⇒ Object Also known as: user_size
44 45 46 |
# File 'lib/gitGraph/github/client.rb', line 44 def user_count @stored_users.count end |