takoyaki 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61de62f7f98364a4f3f5d3dd4c474dc360e46a7d
4
+ data.tar.gz: 754603899b5cee7ce7cbdc80bd82ac70164665dc
5
+ SHA512:
6
+ metadata.gz: 22e923d8a8f030dc27e92a676823e4d539778bbb9f946295a1677e313f6a46b516586b4b60bb5d7421efbc7dc067451cc3da6308f68fb569d4cd7e82cb66618f
7
+ data.tar.gz: 69d199b6e4191ca498068c0478cd0186502fbbbea190b5bcf248ea79078e3e5cf7732edaf178cd11164e742519892208ed1488744cae8731eeffadebf19aeec2
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,73 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ Exclude:
4
+ DisplayCopNames: true
5
+
6
+ Documentation:
7
+ Enabled: false
8
+
9
+ ######## Lint ########
10
+
11
+ Lint/AssignmentInCondition:
12
+ Enabled: false
13
+
14
+ Lint/HandleExceptions:
15
+ Enabled: false
16
+
17
+ Lint/UnderscorePrefixedVariableName:
18
+ Enabled: false
19
+
20
+ Lint/UnusedBlockArgument:
21
+ Enabled: false
22
+
23
+ Lint/UnusedMethodArgument:
24
+ Enabled: false
25
+
26
+ ######## Style ########
27
+
28
+ Style/AccessorMethodName:
29
+ Enabled: false
30
+
31
+ Style/AsciiComments:
32
+ Enabled: false
33
+
34
+ Style/Documentation:
35
+ Enabled: false
36
+
37
+ Style/DoubleNegation:
38
+ Enabled: false
39
+
40
+ Style/FormatString:
41
+ EnforcedStyle: percent
42
+
43
+ Style/GuardClause:
44
+ MinBodyLength: 4
45
+
46
+ Style/IfUnlessModifier:
47
+ Enabled: false
48
+
49
+ Style/MultilineBlockChain:
50
+ Enabled: false
51
+
52
+ Style/NumericLiterals:
53
+ MinDigits: 7
54
+
55
+ Style/PredicateName:
56
+ NamePrefixBlacklist:
57
+ - "is_"
58
+ - "have_"
59
+
60
+ Style/SignalException:
61
+ EnforcedStyle: only_raise
62
+
63
+ Style/SingleLineBlockParams:
64
+ Enabled: false
65
+
66
+ Style/SpaceAroundOperators:
67
+ AllowForAlignment: true
68
+
69
+ Style/StringLiterals:
70
+ EnforcedStyle: double_quotes
71
+
72
+ Style/TrailingCommaInLiteral:
73
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ # Specify your gem's dependencies in takoyaki.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 nownabe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Takoyaki
2
+ Get GitHub Activities.
3
+
4
+ ## Installation
5
+ ```bash
6
+ gem install takoyaki
7
+ ```
8
+
9
+ ## Usage
10
+ Put configuration file `.takoyaki.yml` into home directory.
11
+
12
+ ```yaml
13
+ ---
14
+ access_token: YOUR_ACCESS_TOKEN
15
+ repositories:
16
+ org1:
17
+ - repo1
18
+ - repo2
19
+ org2:
20
+ - repo3
21
+ - repo4
22
+ ```
23
+
24
+ Run `tkyk` command:
25
+
26
+ ```bash
27
+ $ tkyk activities
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nownabe/takoyaki.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "takoyaki"
6
+
7
+ require "pry"
8
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/takoyaki ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift("../../lib", __FILE__)
4
+ require "takoyaki/runner"
5
+
6
+ Takoyaki::Runner.new(ARGV).run
data/exe/tkyk ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift("../../lib", __FILE__)
4
+ require "takoyaki/runner"
5
+
6
+ Takoyaki::Runner.new(ARGV).run
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takoyaki
4
+ module Commands
5
+ class Activities
6
+ attr_reader :to, :from
7
+
8
+ def initialize
9
+ now = Time.now
10
+ to = now + 24 * 60 * 60
11
+ @to = Time.new(to.year, to.month, to.day)
12
+ from = to - 7 * 24 * 60 * 60
13
+ @from = Time.new(from.year, from.month, from.day)
14
+ end
15
+
16
+ def execute
17
+ events = []
18
+ page = 0
19
+ res = client.user_events(user, per_page: 100, page: page)
20
+ loop do
21
+ res.each do |event|
22
+ if from <= event.created_at && event.created_at < to
23
+ events << event
24
+ end
25
+ end
26
+ break if res.last.created_at < from
27
+ page += 1
28
+ res = client.user_events(user, per_page: 100, page: page)
29
+ end
30
+ repo_events = Hash.new { |h, k| h[k] = {} }
31
+ events.each do |event|
32
+ next unless repositories.include?(event.repo&.name)
33
+ case event.type
34
+ when "IssueCommentEvent", "IssuesEvent"
35
+ repo_events[event.repo.name][event.payload.issue.number] = event
36
+ when "PullRequestReviewCommentEvent", "PullRequestEvent"
37
+ repo_events[event.repo.name][event.payload.pull_request.number] = event
38
+ when "CreateEvent", "DeleteEvent", "PushEvent"
39
+ else
40
+ binding.pry
41
+ end
42
+ end
43
+ repo_events.each do |repo, events|
44
+ puts "### #{repo}"
45
+ events.sort { |a, b| a[0] <=> b[0] }.each do |number, event|
46
+ case event.type
47
+ when /^Issue/
48
+ puts "- [##{number} #{event.payload.issue.title}](#{event.payload.issue.html_url})"
49
+ when /^PullRequest/
50
+ puts "- [##{number} #{event.payload.pull_request.title}](#{event.payload.pull_request.html_url})"
51
+ end
52
+ end
53
+ puts
54
+ end
55
+ end
56
+
57
+ def client
58
+ @client ||= Octokit::Client.new(access_token: config["access_token"])
59
+ end
60
+
61
+ def config
62
+ @config ||= YAML.load_file(File.expand_path("~/.takoyaki.yaml"))
63
+ end
64
+
65
+ def event_types
66
+ @event_types ||=
67
+ %w(
68
+ IssueCommentEvent
69
+ PullRequestReviewCommentEvent
70
+ IssuesEvent
71
+ PullRequestEvent
72
+ )
73
+ end
74
+
75
+ def repositories
76
+ @repositories ||=
77
+ config["repositories"].map do |org, repos|
78
+ repos.map { |repo| "#{org}/#{repo}" }
79
+ end.flatten
80
+ end
81
+
82
+ def user
83
+ client.user.login
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takoyaki
4
+ module Commands
5
+ end
6
+ end
7
+
8
+ require "takoyaki/commands/activities"
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+ require "octokit"
5
+
6
+ require "pry"
7
+
8
+ require "takoyaki/commands"
9
+
10
+ module Takoyaki
11
+ class Runner
12
+ attr_reader :args
13
+
14
+ def initialize(args = [])
15
+ @args = args
16
+ end
17
+
18
+ def run
19
+ case command
20
+ when "activities"
21
+ Commands::Activities.new.execute
22
+ end
23
+ end
24
+
25
+ def command
26
+ args.first
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module Takoyaki
3
+ VERSION = "0.1.0"
4
+ end
data/lib/takoyaki.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ require "takoyaki/version"
3
+
4
+ module Takoyaki
5
+ # Your code goes here...
6
+ end
data/takoyaki.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "takoyaki/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "takoyaki"
9
+ spec.version = Takoyaki::VERSION
10
+ spec.authors = ["nownabe"]
11
+ spec.email = ["nownabe@gmail.com"]
12
+
13
+ spec.summary = "Activities on GitHub"
14
+ spec.homepage = "https://github.com/nownabe/takoyaki"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "pry"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+
27
+ spec.add_dependency "octokit"
28
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: takoyaki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nownabe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octokit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - nownabe@gmail.com
86
+ executables:
87
+ - takoyaki
88
+ - tkyk
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".rubocop.yml"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - exe/takoyaki
103
+ - exe/tkyk
104
+ - lib/takoyaki.rb
105
+ - lib/takoyaki/commands.rb
106
+ - lib/takoyaki/commands/activities.rb
107
+ - lib/takoyaki/runner.rb
108
+ - lib/takoyaki/version.rb
109
+ - takoyaki.gemspec
110
+ homepage: https://github.com/nownabe/takoyaki
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.5.1
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Activities on GitHub
134
+ test_files: []