github_sniffer 0.0.2

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: 0106e108fd4cff86564d4b074c4a2bc0bc13ff6a
4
+ data.tar.gz: 2b411657af22f859b28bc85aa01808b2f8647882
5
+ SHA512:
6
+ metadata.gz: 6d111d786794dc84bdb46845ea2f840d4360f4baf1d7505c7c07209efd9ffb63778fdbba67a24657e05a83da44288c52ec2407c6e0733ccae763cf54322f29f9
7
+ data.tar.gz: 2658c11807203aa0349f02b5c5bbaa62f723d40646af52b59ba9e1cfe9f2f14af7b88cefed78cf1fb1212f081f3da5ba6ce0ee573a2165a32a12fe222b899a6a
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .byebug_history
11
+ **/.DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
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.3
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in github_sniffer.gemspec
4
+ gemspec
5
+ gem 'aruba', '~> 0.14.1'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 rails-kung-foo
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
+ # GithubSniffer
2
+
3
+ Simple command line tool with github api to display github users most used languages.
4
+
5
+ run `bundle exec bin/github_sniffer dominant_language USERNAME` to display users preferred language.
6
+ `dl` is an alias for `dominant_language`.
7
+
8
+ run `bin/console` for an interactive prompt.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'github_sniffer'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install github_sniffer
25
+
26
+ ## Development
27
+
28
+ run `rspec spec` and `cucumber` for tests.
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rails-kung-foo/github_sniffer.
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
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber/rake/task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "github_sniffer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'github_sniffer'
4
+
5
+ GithubSniffer::Cli::Application.start(ARGV)
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
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'github_sniffer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'github_sniffer'
8
+ spec.version = GithubSniffer::VERSION
9
+ spec.authors = ['rails-kung-foo']
10
+ spec.email = ['rails.kung.foo@gmail.com']
11
+
12
+ spec.summary = 'Simple command line tool to display user prefered language.'
13
+ spec.description = 'Simple command line tool to look at Github profiles.'
14
+ spec.homepage = 'https://github.com/rails-kung-foo/github-sniffer'
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = 'bin'
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_dependency 'thor', '~> 0.18'
32
+ spec.add_dependency 'github_api', '~> 0.14.0'
33
+ spec.add_development_dependency 'bundler', '~> 1.12'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.0'
36
+ spec.add_development_dependency 'byebug'
37
+ spec.add_development_dependency 'aruba'
38
+ spec.add_development_dependency 'cucumber'
39
+ end
@@ -0,0 +1,28 @@
1
+ require 'thor'
2
+
3
+ module GithubSniffer
4
+ module Cli
5
+ class Application < Thor
6
+
7
+ desc 'dominant_language USERNAME', 'Returns users mosed used programming language.'
8
+ def dominant_language(username)
9
+ prefered_lang = Github.new(user: username).repos.dominant_language
10
+
11
+ dominant_language_response(username: username, prefered_lang: prefered_lang)
12
+ rescue Github::Error::NotFound
13
+ p "#{username} not found!"
14
+ end
15
+
16
+ map dl: :dominant_language
17
+
18
+ no_tasks do
19
+ def dominant_language_response(username:, prefered_lang:)
20
+ return p "#{username} has no repos." if prefered_lang.nil?
21
+
22
+ p "#{username} has #{prefered_lang[0].join(', ')} as main language/s in #{prefered_lang[1]} repo/s."
23
+ end
24
+ end # no_task
25
+
26
+ end # Application
27
+ end # Cli
28
+ end # GithubSniffer
@@ -0,0 +1,34 @@
1
+ module GithubSniffer
2
+ module GithubExtension
3
+
4
+ # We add our own method to the api.
5
+ # Github.new.repos.class returns our desired class to extend
6
+ Github::Client::Repos.class_eval do
7
+
8
+ # returns dominant language from all repositories.
9
+ # Github.new(user: NAME).repos.dominant_language
10
+ # [['ruby', 'c++'], count]
11
+ def dominant_language
12
+ languages = {}
13
+
14
+ # Cycle through repos and sum up the main language
15
+ self.list.each do |repo|
16
+ next if repo.language.nil?
17
+
18
+ repo_language = repo.language.downcase!
19
+
20
+ languages[repo_language] = 0 if languages[repo_language].nil?
21
+ languages[repo_language] += 1
22
+ end
23
+
24
+ count = languages.values.max
25
+
26
+ # send nil back if user has no repos
27
+ return nil if count.nil?
28
+
29
+ # possible that multiple languages have the same number.
30
+ [languages.select{ |_k, value| value == count }.keys, count]
31
+ end
32
+ end # Github::Client::Repos
33
+ end # GithubExtension
34
+ end # GithubSniffer
@@ -0,0 +1,3 @@
1
+ module GithubSniffer
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'github_api'
2
+ require 'github_sniffer/cli/application'
3
+ require 'github_sniffer/version'
4
+ require 'github_sniffer/github_extension'
5
+
6
+ module GithubSniffer
7
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_sniffer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - rails-kung-foo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: github_api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.14.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.14.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: aruba
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cucumber
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Simple command line tool to look at Github profiles.
126
+ email:
127
+ - rails.kung.foo@gmail.com
128
+ executables:
129
+ - console
130
+ - github_sniffer
131
+ - setup
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - ".gitignore"
136
+ - ".rspec"
137
+ - ".travis.yml"
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - bin/console
143
+ - bin/github_sniffer
144
+ - bin/setup
145
+ - github_sniffer.gemspec
146
+ - lib/github_sniffer.rb
147
+ - lib/github_sniffer/cli/application.rb
148
+ - lib/github_sniffer/github_extension.rb
149
+ - lib/github_sniffer/version.rb
150
+ homepage: https://github.com/rails-kung-foo/github-sniffer
151
+ licenses:
152
+ - MIT
153
+ metadata:
154
+ allowed_push_host: https://rubygems.org
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.5.1
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Simple command line tool to display user prefered language.
175
+ test_files: []