basico-octakit 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 957c651df76807accaf8c9ac5bf87b6b69a1c5f3
4
+ data.tar.gz: beb5be8125458103905d8c8fd34361481ca3953e
5
+ SHA512:
6
+ metadata.gz: 4eccddf884381fa70f9a7771096325706aa621caf4b0b70de6103618f9c8d64d95f4e605d677b9ab297f639f7602a9664f339909fd0ea67b3647681dd2e65a79
7
+ data.tar.gz: 4272ef3658d2f607f8779f1d5dc5944e6a58a0c203294b5ba4fa535c49cf9bd7a401573559aea481db46063101f922e04959d0916044e6724e9d331bb189dc1c
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 3.3.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 2.0.1"
13
+ gem "simplecov", ">= 0"
14
+ gem "factory_girl"
15
+ gem "pry"
16
+ gem "ffaker"
17
+ end
18
+
19
+ gem "octokit"
20
+ gem "httparty"
21
+ gem "configatron"
22
+ gem "colorize"
23
+ gem "virtus"
24
+ gem "inflecto"
data/Gemfile.lock ADDED
@@ -0,0 +1,134 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.2.4)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.3.8)
11
+ axiom-types (0.1.1)
12
+ descendants_tracker (~> 0.0.4)
13
+ ice_nine (~> 0.11.0)
14
+ thread_safe (~> 0.3, >= 0.3.1)
15
+ builder (3.2.2)
16
+ coderay (1.1.0)
17
+ coercible (1.0.0)
18
+ descendants_tracker (~> 0.0.1)
19
+ colorize (0.7.7)
20
+ configatron (4.5.0)
21
+ descendants_tracker (0.0.4)
22
+ thread_safe (~> 0.3, >= 0.3.1)
23
+ diff-lcs (1.2.5)
24
+ docile (1.1.5)
25
+ equalizer (0.0.11)
26
+ factory_girl (4.5.0)
27
+ activesupport (>= 3.0.0)
28
+ faraday (0.9.1)
29
+ multipart-post (>= 1.2, < 3)
30
+ ffaker (2.1.0)
31
+ git (1.2.9.1)
32
+ github_api (0.12.4)
33
+ addressable (~> 2.3)
34
+ descendants_tracker (~> 0.0.4)
35
+ faraday (~> 0.8, < 0.10)
36
+ hashie (>= 3.4)
37
+ multi_json (>= 1.7.5, < 2.0)
38
+ nokogiri (~> 1.6.6)
39
+ oauth2
40
+ hashie (3.4.2)
41
+ highline (1.7.7)
42
+ httparty (0.13.7)
43
+ json (~> 1.8)
44
+ multi_xml (>= 0.5.2)
45
+ i18n (0.7.0)
46
+ ice_nine (0.11.1)
47
+ inflecto (0.0.2)
48
+ jeweler (2.0.1)
49
+ builder
50
+ bundler (>= 1.0)
51
+ git (>= 1.2.5)
52
+ github_api
53
+ highline (>= 1.6.15)
54
+ nokogiri (>= 1.5.10)
55
+ rake
56
+ rdoc
57
+ json (1.8.3)
58
+ jwt (1.5.1)
59
+ method_source (0.8.2)
60
+ mini_portile (0.6.2)
61
+ minitest (5.8.1)
62
+ multi_json (1.11.2)
63
+ multi_xml (0.5.5)
64
+ multipart-post (2.0.0)
65
+ nokogiri (1.6.6.2)
66
+ mini_portile (~> 0.6.0)
67
+ oauth2 (1.0.0)
68
+ faraday (>= 0.8, < 0.10)
69
+ jwt (~> 1.0)
70
+ multi_json (~> 1.3)
71
+ multi_xml (~> 0.5)
72
+ rack (~> 1.2)
73
+ octokit (4.1.1)
74
+ sawyer (~> 0.6.0, >= 0.5.3)
75
+ pry (0.10.2)
76
+ coderay (~> 1.1.0)
77
+ method_source (~> 0.8.1)
78
+ slop (~> 3.4)
79
+ rack (1.6.4)
80
+ rake (10.4.2)
81
+ rdoc (3.12.2)
82
+ json (~> 1.4)
83
+ rspec (3.3.0)
84
+ rspec-core (~> 3.3.0)
85
+ rspec-expectations (~> 3.3.0)
86
+ rspec-mocks (~> 3.3.0)
87
+ rspec-core (3.3.2)
88
+ rspec-support (~> 3.3.0)
89
+ rspec-expectations (3.3.1)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.3.0)
92
+ rspec-mocks (3.3.2)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.3.0)
95
+ rspec-support (3.3.0)
96
+ sawyer (0.6.0)
97
+ addressable (~> 2.3.5)
98
+ faraday (~> 0.8, < 0.10)
99
+ simplecov (0.10.0)
100
+ docile (~> 1.1.0)
101
+ json (~> 1.8)
102
+ simplecov-html (~> 0.10.0)
103
+ simplecov-html (0.10.0)
104
+ slop (3.6.0)
105
+ thread_safe (0.3.5)
106
+ tzinfo (1.2.2)
107
+ thread_safe (~> 0.1)
108
+ virtus (1.0.5)
109
+ axiom-types (~> 0.1)
110
+ coercible (~> 1.0)
111
+ descendants_tracker (~> 0.0, >= 0.0.3)
112
+ equalizer (~> 0.0, >= 0.0.9)
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ bundler (~> 1.0)
119
+ colorize
120
+ configatron
121
+ factory_girl
122
+ ffaker
123
+ httparty
124
+ inflecto
125
+ jeweler (~> 2.0.1)
126
+ octokit
127
+ pry
128
+ rdoc (~> 3.12)
129
+ rspec (~> 3.3.0)
130
+ simplecov
131
+ virtus
132
+
133
+ BUNDLED WITH
134
+ 1.10.6
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 rickybell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = basico-octakit
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to basico-octakit
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2015 rickybell. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "basico-octakit"
18
+ gem.homepage = "http://github.com/rickybell/basico-octakit"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Github SDK built on top of Octakit}
21
+ gem.description = %Q{A cool Github SDK}
22
+ gem.email = "henrique.belloube@gmail.com, renatodex@gmail.com"
23
+ gem.authors = ["rickybell","renatodex"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "basico-octakit #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
@@ -0,0 +1,25 @@
1
+
2
+ require 'httparty'
3
+ require 'configatron'
4
+ require 'colorize'
5
+ require 'octokit'
6
+ require 'singleton'
7
+ require 'virtus'
8
+ require 'inflecto'
9
+ require 'factory_girl'
10
+ require 'date'
11
+ require 'pry'
12
+
13
+ require 'basico-octokit/initializers/exceptions'
14
+ require 'basico-octokit/config/default'
15
+ require 'basico-octokit/helpers/client_helper'
16
+ require 'basico-octokit/facade/client'
17
+ require 'basico-octokit/facade/issues'
18
+ require 'basico-octokit/models/ticket_label'
19
+ require 'basico-octokit/models/ticket_user'
20
+ require 'basico-octokit/models/ticket'
21
+ require 'basico-octokit/models/summary_label'
22
+ require 'basico-octokit/models/summary_user'
23
+ require 'basico-octokit/models/summary'
24
+ require 'basico-octokit/summary_api/issues'
25
+ require 'basico-octokit/summary_api/summary_collection_array'
@@ -0,0 +1,5 @@
1
+ require 'configatron'
2
+ #configatron.basico_git_token = 'ff51acd475e25cfb3b350cee880877512e93c4fc'
3
+ # configatron.basico_git_token = '60cc57e7f2cea39cb77d87e34552afaf3c5d9fd9'
4
+ # configatron.basico_git_token = '22a86739178ae8cf4643dcfaa6f2cffa6fd24ed5'
5
+ configatron.basico_git_token = 'Insert your token'
@@ -0,0 +1,19 @@
1
+ module BasicoOctokit
2
+ module Facade
3
+ class Client
4
+ include Singleton
5
+ attr_accessor :client
6
+
7
+ def initialize
8
+ self.client = Octokit::Client.new
9
+ end
10
+
11
+ def get(access_token)
12
+ self.client.access_token = access_token
13
+ self.client
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,44 @@
1
+ module BasicoOctokit
2
+ module Facade
3
+ class Issues
4
+ extend BasicoOctokit::Helpers::ClientHelper
5
+
6
+ {
7
+ "opened" => :open,
8
+ "closed" => :closed
9
+ }.each do | key, value|
10
+ define_singleton_method key do | owner_repo|
11
+ self.build owner_repo, value
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def self.build(owner_repo,state)
18
+ issues = self.get owner_repo, state
19
+ self.injection issues
20
+ end
21
+
22
+ def self.get(owner_repo,state)
23
+ self.client.auto_paginate = true
24
+ issues = self.client.issues owner_repo, :state => state
25
+ self.client.auto_paginate = false
26
+ issues
27
+ end
28
+
29
+ def self.injection(issues)
30
+ arr = []
31
+ issues.map { | issue |
32
+ myissue = BasicoOctokit::Models::Ticket.new(issue)
33
+ myissue.ticket_user = BasicoOctokit::Models::TicketUser.new(issue.user)
34
+ issue.labels.each do |label|
35
+ ticket_label = BasicoOctokit::Models::TicketLabel.new(label)
36
+ myissue.ticket_labels << ticket_label
37
+ end
38
+ arr << myissue
39
+ }
40
+ arr
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,9 @@
1
+ module BasicoOctokit
2
+ module Helpers
3
+ module ClientHelper
4
+ def client
5
+ BasicoOctokit::Client.instance.get(configatron.basico_git_token)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module BasicoOctokit
2
+ class NoFilterException < StandardError
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ module BasicoOctokit
2
+ module Models
3
+ class Summary
4
+ include Virtus::Model
5
+
6
+ attribute :date_start, Date
7
+ attribute :date_end, Date
8
+ attribute :total, Float
9
+ attribute :state, String
10
+ attribute :repository, String
11
+ attribute :summary_labels, Array[BasicoOctokit::Models::SummaryLabel]
12
+ attribute :summary_users, Array[BasicoOctokit::Models::SummaryUser]
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module BasicoOctokit
2
+ module Models
3
+ class SummaryLabel
4
+ include Virtus::Model
5
+
6
+ attribute :total, Integer
7
+ attribute :ticket_label, BasicoOctokit::Models::TicketLabel
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BasicoOctokit
2
+ module Models
3
+ class SummaryUser
4
+ include Virtus::Model
5
+
6
+ attribute :total, Integer
7
+ attribute :ticket_user, BasicoOctokit::Models::TicketUser
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module BasicoOctokit
2
+ module Models
3
+ class Ticket
4
+ include Virtus::Model
5
+
6
+ attribute :url, String
7
+ attribute :id, Integer
8
+ attribute :number, Integer
9
+ attribute :title, String
10
+ attribute :state, String
11
+ attribute :created_at, DateTime
12
+ attribute :updated_at, DateTime
13
+ attribute :closed_at, DateTime
14
+ attribute :body, String
15
+ attribute :ticket_labels, Array[BasicoOctokit::Models::TicketLabel]
16
+ attribute :ticket_user, BasicoOctokit::Models::TicketUser
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ module BasicoOctokit
2
+ module Models
3
+ class TicketLabel
4
+ include Virtus::Model
5
+
6
+ attribute :url, String
7
+ attribute :name, String
8
+ attribute :color, String
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module BasicoOctokit
2
+ module Models
3
+ class TicketUser
4
+ include Virtus::Model
5
+
6
+ attribute :login, String
7
+ attribute :avatar_url, String
8
+ attribute :id, Integer
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,61 @@
1
+ module BasicoOctokit
2
+ module SummaryApi
3
+ class Issues
4
+
5
+ ["opened","closed"].each do | value |
6
+ define_singleton_method value do | date_start, date_end, repository, filter_by='created' |
7
+ #get issues
8
+ issues = BasicoOctokit::Facade::Issues.send value, repository
9
+ #Filter date
10
+ method = "#{filter_by}_at"
11
+ begin
12
+ issues.select! { |ticket| ticket.send(method) >= date_start && ticket.send(method) <= date_end }
13
+ rescue NoMethodError
14
+ raise BasicoOctokit::NoFilterException
15
+ end
16
+
17
+ BasicoOctokit::Models::Summary.new(
18
+ date_start: date_start.to_date,
19
+ date_end: date_end.to_date,
20
+ state: value,
21
+ repository: repository,
22
+ total: issues.count,
23
+ summary_labels: self.build_summary_labels(issues),
24
+ summary_users: self.build_summary_users(issues)
25
+ )
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # Agrupamento por ticket_label
32
+ def self.build_summary_labels(tickets)
33
+ tickets.inject(BasicoOctokit::SummaryApi::SummaryCollectionArray.new) do | summary_labels , ticket |
34
+ ticket.ticket_labels.each do | ticket_label |
35
+ ticket_label_found = summary_labels.find_by_label(ticket_label.name)
36
+ if ticket_label_found.nil?
37
+ summary_labels << BasicoOctokit::Models::SummaryLabel.new( :ticket_label => ticket_label, :total => 1 )
38
+ else
39
+ ticket_label_found.total += 1
40
+ end
41
+ end
42
+ summary_labels
43
+ end
44
+ end
45
+
46
+ # Agrupamento por ticket_label
47
+ def self.build_summary_users(tickets)
48
+ tickets.inject(BasicoOctokit::SummaryApi::SummaryCollectionArray.new) do | summary_users , ticket |
49
+ ticket_user = ticket.ticket_user
50
+ ticket_user_found = summary_users.find_by_login(ticket_user.login)
51
+ if ticket_user_found.nil?
52
+ summary_users << BasicoOctokit::Models::SummaryUser.new( :ticket_user => ticket_user, :total => 1 )
53
+ else
54
+ ticket_user_found.total += 1
55
+ end
56
+ summary_users
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,13 @@
1
+ module BasicoOctokit
2
+ module SummaryApi
3
+ class SummaryCollectionArray < Array
4
+ def find_by_label(name)
5
+ self.find { | summary_label | summary_label.ticket_label.name == name }
6
+ end
7
+
8
+ def find_by_login(login)
9
+ self.find { | summary_user | summary_user.ticket_user.login == login}
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "BasicoOctokit" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ FactoryGirl.define do
2
+ factory :summary,:class => BasicoOctokit::Models::Summary do |f|
3
+ f.date_start Date.today - 1
4
+ f.date_end Date.today
5
+ f.state 'opened'
6
+ f.repository 'lojabasico/tickets_ti'
7
+ f.total 10
8
+ f.summary_labels nil
9
+ f.summary_users nil
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :summary_label,
3
+ :class => BasicoOctokit::Models::SummaryLabel do |f|
4
+ f.total 1
5
+ f.ticket_label { FactoryGirl.build(:ticket_label) }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :summary_user,
3
+ :class => BasicoOctokit::Models::SummaryUser do |f|
4
+ f.total 1
5
+ f.ticket_user { FactoryGirl.build(:ticket_user) }
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ FactoryGirl.define do
2
+ factory :ticket,:class => BasicoOctokit::Models::Ticket do |f|
3
+ f.url "http://blalba.com"
4
+ f.id 1
5
+ f.number 1111111
6
+ f.title "loren ipsum"
7
+ f.state "open"
8
+ f.created_at Date.today
9
+ f.updated_at Date.today
10
+ f.body "body fake"
11
+ f.ticket_labels { FactoryGirl.build_list(:ticket_label,1)}
12
+ f.ticket_user { FactoryGirl.build(:ticket_user)}
13
+ end
14
+
15
+ factory :ticket_closed,:class => BasicoOctokit::Models::Ticket do |f|
16
+ f.url "http://blalba.com"
17
+ f.id 1
18
+ f.number 1111111
19
+ f.title "loren ipsum"
20
+ f.state "close"
21
+ f.created_at Date.today
22
+ f.updated_at Date.today
23
+ f.body "body fake"
24
+ f.ticket_labels { FactoryGirl.build_list(:ticket_label,1)}
25
+ f.ticket_user { FactoryGirl.build(:ticket_user)}
26
+ end
27
+
28
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :ticket_label,
3
+ :class => BasicoOctokit::Models::TicketLabel do |f|
4
+ f.url 'http://xpto.com'
5
+ f.name { ["bug","duplicate","issue","critical"].sample }
6
+ f.color '159818'
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :ticket_user,:class => BasicoOctokit::Models::TicketUser do |f|
3
+ f.login { ["brexus","dudaeli","ismil","crisis"].sample }
4
+ f.avatar_url "http://avatar.com/2.jpg"
5
+ f.id {Random.rand(1...100)}
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Issues" do
4
+ describe "#get" do
5
+ it "fails" do
6
+ expect().to eq(nil)
7
+ end
8
+ end
9
+ end
File without changes
@@ -0,0 +1,50 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ require 'simplecov'
4
+ class FakeClient
5
+
6
+ attr_accessor :auto_paginate
7
+
8
+ def issues(a, b)
9
+ end
10
+
11
+ end
12
+
13
+ module SimpleCov::Configuration
14
+ def clean_filters
15
+ @filters = []
16
+ end
17
+ end
18
+
19
+ SimpleCov.configure do
20
+ clean_filters
21
+ load_adapter 'test_frameworks'
22
+ end
23
+
24
+ ENV["COVERAGE"] && SimpleCov.start do
25
+ add_filter "/.rvm/"
26
+ end
27
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
28
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
29
+
30
+ require 'rspec'
31
+ require 'basico-octokit'
32
+
33
+ # Requires supporting files with custom matchers and macros, etc,
34
+ # in ./support/ and its subdirectories.
35
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
36
+
37
+ ['factories/*'].each do |p|
38
+ Dir[File.dirname(__FILE__) + "/#{p}"].each {|file| require file }
39
+ end
40
+
41
+ RSpec.configure do |config|
42
+ # Use color in STDOUT
43
+ config.color = true
44
+
45
+ # Use color not only in STDOUT but also in pagers and files
46
+ config.tty = true
47
+
48
+ # Use the specified formatter
49
+ config.formatter = :documentation # :progress, :html, :textmate
50
+ end
File without changes
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe BasicoOctokit::SummaryApi::Issues do
5
+
6
+ let(:opened) {
7
+ temp = []
8
+ temp.push(FactoryGirl.build(:ticket,{:created_at => Date.today ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "x" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "brexus"}) }))
9
+ temp.push(FactoryGirl.build(:ticket,{:created_at => Date.today - 1 ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "b" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "dudaeli"}) }))
10
+ temp.push(FactoryGirl.build(:ticket,{:created_at => Date.today - 2 ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "c" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "ismil"}) }))
11
+ temp.push(FactoryGirl.build(:ticket,{:created_at => Date.today - 3 ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "d" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "crisis"}) }))
12
+ }
13
+
14
+ let(:closed) {
15
+ temp = []
16
+ temp.push(FactoryGirl.build(:ticket_closed,{:created_at => Date.today ,:closed_at => Date.today ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "x" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "brexus"}) }))
17
+ temp.push(FactoryGirl.build(:ticket_closed,{:created_at => Date.today - 1 ,:closed_at => Date.today - 1 ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "b" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "dudaeli"}) }))
18
+ temp.push(FactoryGirl.build(:ticket_closed,{:created_at => Date.today - 2 ,:closed_at => Date.today - 1 ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "c" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "ismil"}) }))
19
+ temp.push(FactoryGirl.build(:ticket_closed,{:created_at => Date.today - 3 ,:closed_at => Date.today - 2 ,:ticket_labels => [FactoryGirl.build(:ticket_label, { :name => "d" })],:ticket_user => FactoryGirl.build(:ticket_user,{:login => "crisis"}) }))
20
+ }
21
+ let(:repository) { 'lojabasico/tickets_ti' }
22
+
23
+ context "#opened" do
24
+ context "#created_at" do
25
+ it "should return summary" do
26
+
27
+ configatron.basico_git_token = "xxxx"
28
+ expect(BasicoOctokit::Facade::Issues).to receive(:opened).and_return(opened)
29
+ summary = described_class.opened( Date.today - 1, Date.today, repository )
30
+
31
+ expect(summary.date_start).to eq(Date.today - 1)
32
+ expect(summary.date_end).to eq(Date.today)
33
+ expect(summary.repository).to eq(repository)
34
+ expect(summary.summary_labels.count).to eq(2)
35
+ expect(summary.summary_labels.first.total).to eq(1)
36
+ expect(summary.summary_users.count).to eq(2)
37
+
38
+ end
39
+
40
+ it "should filter by date" do
41
+ configatron.basico_git_token = "xxxx"
42
+ expect(BasicoOctokit::Facade::Issues).to receive(:opened).and_return(opened)
43
+ summary = described_class.opened( Date.today - 2, Date.today, repository )
44
+ expect(summary.total).to eq(3)
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ context "#closed" do
51
+ context "#created_at" do
52
+ it "should filter by date" do
53
+ configatron.basico_git_token = "xxxx"
54
+ expect(BasicoOctokit::Facade::Issues).to receive(:closed).and_return(closed)
55
+ summary = described_class.closed( Date.today - 2, Date.today, repository )
56
+ expect(summary.total).to eq(3)
57
+ end
58
+ end
59
+ context "#closed_at" do
60
+ it "should filter by date" do
61
+ configatron.basico_git_token = "xxxx"
62
+ expect(BasicoOctokit::Facade::Issues).to receive(:closed).and_return(closed)
63
+ summary = described_class.closed( Date.today - 2, Date.today, repository, "closed" )
64
+ expect(summary.total).to eq(4)
65
+ end
66
+ end
67
+ context "#DartVader" do
68
+ it "should filter by date" do
69
+ configatron.basico_git_token = "xxxx"
70
+ expect(BasicoOctokit::Facade::Issues).to receive(:closed).and_return(closed)
71
+ expect{described_class.closed( Date.today - 2, Date.today, repository, "dartvader" )}.to raise_error BasicoOctokit::NoFilterException
72
+ end
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,276 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: basico-octakit
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - rickybell
8
+ - renatodex
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-10-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: octokit
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: httparty
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: configatron
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: colorize
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: virtus
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: inflecto
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rspec
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 3.3.0
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 3.3.0
112
+ - !ruby/object:Gem::Dependency
113
+ name: rdoc
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '3.12'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '3.12'
126
+ - !ruby/object:Gem::Dependency
127
+ name: bundler
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '1.0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: jeweler
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: 2.0.1
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: 2.0.1
154
+ - !ruby/object:Gem::Dependency
155
+ name: simplecov
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: factory_girl
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: pry
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: ffaker
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ description: A cool Github SDK
211
+ email: henrique.belloube@gmail.com, renatodex@gmail.com
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files:
215
+ - LICENSE.txt
216
+ - README.rdoc
217
+ files:
218
+ - ".document"
219
+ - ".rspec"
220
+ - Gemfile
221
+ - Gemfile.lock
222
+ - LICENSE.txt
223
+ - README.rdoc
224
+ - Rakefile
225
+ - VERSION
226
+ - lib/basico-octokit.rb
227
+ - lib/basico-octokit/config/default.rb
228
+ - lib/basico-octokit/facade/client.rb
229
+ - lib/basico-octokit/facade/issues.rb
230
+ - lib/basico-octokit/helpers/client_helper.rb
231
+ - lib/basico-octokit/initializers/exceptions.rb
232
+ - lib/basico-octokit/models/summary.rb
233
+ - lib/basico-octokit/models/summary_label.rb
234
+ - lib/basico-octokit/models/summary_user.rb
235
+ - lib/basico-octokit/models/ticket.rb
236
+ - lib/basico-octokit/models/ticket_label.rb
237
+ - lib/basico-octokit/models/ticket_user.rb
238
+ - lib/basico-octokit/summary_api/issues.rb
239
+ - lib/basico-octokit/summary_api/summary_collection_array.rb
240
+ - spec/basico-octokit_spec.rb
241
+ - spec/factories/summary.rb
242
+ - spec/factories/summary_label.rb
243
+ - spec/factories/summary_user.rb
244
+ - spec/factories/ticket.rb
245
+ - spec/factories/ticket_label.rb
246
+ - spec/factories/ticket_user.rb
247
+ - spec/issues_spec.rb
248
+ - spec/label_spec.rb
249
+ - spec/spec_helper.rb
250
+ - spec/sumary_spec.rb
251
+ - spec/summary_api/issues_spec.rb
252
+ homepage: http://github.com/rickybell/basico-octakit
253
+ licenses:
254
+ - MIT
255
+ metadata: {}
256
+ post_install_message:
257
+ rdoc_options: []
258
+ require_paths:
259
+ - lib
260
+ required_ruby_version: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ required_rubygems_version: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ requirements: []
271
+ rubyforge_project:
272
+ rubygems_version: 2.4.6
273
+ signing_key:
274
+ specification_version: 4
275
+ summary: Github SDK built on top of Octakit
276
+ test_files: []