fue 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: 5fd514e2bbe05ce162d9d7b260ff91307419d7cc
4
+ data.tar.gz: b9aeb1d8ea34f127c610f3287597b1ba0d366149
5
+ SHA512:
6
+ metadata.gz: e0fa226b7581601e4fd81932001945c222d37011ce3a2ecf59a6ef195533c05ba81df4ecc091bc64a67d62210bd019bf8bf1e29e05cddb91e66f0f9b15b9e35b
7
+ data.tar.gz: 027792f0c9651167dbda104386c00d9fce63094895c969f25a748942d5182e0453600cbb4619d52a2a9cb89aca9685950b48ef2a258aef3557b0a2f72c7fba97
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ### 0.1.0 (2018/8/14)
2
+
3
+ * Initial public release, with help from [@orta](https://github.com/orta) - [@dblock](https://github.com/dblock).
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,125 @@
1
+ # Contributing to Fue
2
+
3
+ This project is work of [many contributors](https://github.com/dblock/fue/graphs/contributors).
4
+
5
+ You're encouraged to submit [pull requests](https://github.com/dblock/fue/pulls), [propose features and discuss issues](https://github.com/dblock/fue/issues).
6
+
7
+ In the examples below, substitute your Github username for `contributor` in URLs.
8
+
9
+ ### Fork the Project
10
+
11
+ Fork the [project on Github](https://github.com/dblock/fue) and check out your copy.
12
+
13
+ ```
14
+ git clone https://github.com/contributor/fue.git
15
+ cd fue
16
+ git remote add upstream https://github.com/dblock/fue.git
17
+ ```
18
+
19
+ ### Bundle Install and Test
20
+
21
+ Ensure that you can build the project and run tests.
22
+
23
+ ```
24
+ bundle install
25
+ bundle exec rake
26
+ ```
27
+
28
+ ## Contribute Code
29
+
30
+ ### Create a Topic Branch
31
+
32
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
33
+
34
+ ```
35
+ git checkout master
36
+ git pull upstream master
37
+ git checkout -b my-feature-branch
38
+ ```
39
+
40
+ ### Write Tests
41
+
42
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to [spec](spec).
43
+
44
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
45
+
46
+ ### Write Code
47
+
48
+ Implement your feature or bug fix.
49
+
50
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.
51
+
52
+ Make sure that `bundle exec rake` completes without errors.
53
+
54
+ ### Write Documentation
55
+
56
+ Document any external behavior in the [README](README.md).
57
+
58
+ ### Update Changelog
59
+
60
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Don't remove *Your contribution here*.
61
+
62
+ Make it look like every other line, including a link to the issue being fixed, your name and link to your Github account.
63
+
64
+ ### Commit Changes
65
+
66
+ Make sure git knows your name and email address:
67
+
68
+ ```
69
+ git config --global user.name "Your Name"
70
+ git config --global user.email "contributor@example.com"
71
+ ```
72
+
73
+ Writing good commit logs is important. A commit log should describe what changed and why.
74
+
75
+ ```
76
+ git add ...
77
+ git commit
78
+ ```
79
+
80
+ ### Push
81
+
82
+ ```
83
+ git push origin my-feature-branch
84
+ ```
85
+
86
+ ### Make a Pull Request
87
+
88
+ Go to https://github.com/contributor/fue and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
89
+
90
+ ### Update CHANGELOG Again
91
+
92
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
93
+
94
+ ```
95
+ * [#123](https://github.com/dblock/fue/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
96
+ ```
97
+
98
+ Amend your previous commit and force push the changes.
99
+
100
+ ```
101
+ git commit --amend
102
+ git push origin my-feature-branch -f
103
+ ```
104
+
105
+ ### Rebase
106
+
107
+ If you've been working on a change for a while, rebase with upstream/master.
108
+
109
+ ```
110
+ git fetch upstream
111
+ git rebase upstream/master
112
+ git push origin my-feature-branch -f
113
+ ```
114
+
115
+ ### Check on Your Pull Request
116
+
117
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
118
+
119
+ ### Be Patient
120
+
121
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
122
+
123
+ ## Thank You
124
+
125
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Daniel Doubrovkine.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ Fue
2
+ ===
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/fue.svg)](https://badge.fury.io/rb/fue)
5
+ [![Build Status](https://travis-ci.org/dblock/fue.svg)](https://travis-ci.org/dblock/fue)
6
+
7
+ Find an e-mail address of a Github user from their commit log.
8
+
9
+ ## Usage
10
+
11
+ ```
12
+ gem install fue
13
+ ```
14
+
15
+ #### Get a Github Access Token
16
+
17
+ Obtain a Github access token from [here](https://github.com/settings/tokens) with `public_repo` permissions. See [help](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) for more information. Set the token as `GITHUB_ACCESS_TOKEN`.
18
+
19
+ #### Find Someone's Email
20
+
21
+ The `find` command looks through user's initial repo commits.
22
+
23
+ ```
24
+ GITHUB_ACCESS_TOKEN=token fue find defunkt
25
+
26
+ Chris Wanstrath <chris@ozmm.org>
27
+ Chris Wanstrath <chris@github.com>
28
+ ```
29
+
30
+ #### Specify More Depth
31
+
32
+ By default the code looks at the last 10 repos. You can have more depth.
33
+
34
+ ```
35
+ GITHUB_ACCESS_TOKEN=token fue find --depth=100 defunkt
36
+
37
+ Chris Wanstrath <chris@ozmm.org>
38
+ Chris Wanstrath <chris@github.com>
39
+ defunkt <chris@ozmm.org>
40
+ ```
41
+
42
+ #### Get Help
43
+
44
+ ```
45
+ fue help
46
+ ```
47
+
48
+ Displays additional options.
49
+
50
+ ## Contributing
51
+
52
+ There're [a few feature requests and known issues](https://github.com/dblock/fue/issues). Please contribute! See [CONTRIBUTING](CONTRIBUTING.md).
53
+
54
+ ## Copyright and License
55
+
56
+ Copyright (c) 2018, Daniel Doubrovkine, [Artsy](http://artsy.github.io), with help from [Orta](https://github.com/orta).
57
+
58
+ This project is licensed under the [MIT License](LICENSE.md).
data/bin/fue ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ require 'fue'
4
+ require 'graphlient'
5
+
6
+ class App
7
+ extend GLI::App
8
+
9
+ program_desc "Find a Github user's e-mail address."
10
+
11
+ switch %i[v verbose], desc: 'Produce verbose output.', default_value: false
12
+
13
+ arguments :strict
14
+ subcommand_option_handling :normal
15
+
16
+ pre do |global_options, _command, options, _args|
17
+ options = global_options.dup
18
+ token = options.delete(:token)
19
+ $fue = Fue::Finder.new(token, options)
20
+ end
21
+
22
+ default_command :help
23
+
24
+ desc "Find a Github user's e-mail address."
25
+ arg 'username'
26
+ command :find do |c|
27
+ c.flag %i[d depth], desc: 'Maximum search depth.', default_value: 10
28
+ c.flag %i[t token], required: true, desc: 'Github access token.', default_value: ENV['GITHUB_ACCESS_TOKEN']
29
+ c.action do |global_options, options, args|
30
+ username = args.first
31
+ puts "Searching for e-mail address for '#{username}' at max depth of #{options[:depth]} ..." if global_options[:verbose]
32
+ puts $fue.emails(options.merge(username: username))
33
+ exit_now! nil, 0
34
+ end
35
+ end
36
+ end
37
+
38
+ exit App.run(ARGV)
data/lib/fue/finder.rb ADDED
@@ -0,0 +1,74 @@
1
+ module Fue
2
+ class Finder
3
+ attr_reader :token
4
+
5
+ def initialize(token, _options = {})
6
+ @token = token
7
+ end
8
+
9
+ def author_id(username)
10
+ query = <<-GRAPHQL
11
+ query($login: String!) {
12
+ user(login: $login) {
13
+ id
14
+ }
15
+ }
16
+ GRAPHQL
17
+ graphql_client.query(query, login: username).data.user.id
18
+ end
19
+
20
+ def emails(options = {})
21
+ query = <<-GRAPHQL
22
+ query($login: String!, $author_id: ID!, $depth: Int!) {
23
+ user(login: $login) {
24
+ repositories(last: $depth, isFork:false, privacy: PUBLIC) {
25
+ edges {
26
+ node {
27
+ defaultBranchRef {
28
+ target {
29
+ ... on Commit {
30
+ history(first: 1, author: { id: $author_id }) {
31
+ nodes {
32
+ author {
33
+ email
34
+ name
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ GRAPHQL
47
+
48
+ query_options = {
49
+ login: options[:username],
50
+ author_id: author_id(options[:username]),
51
+ depth: (options[:depth] || 10).to_i
52
+ }
53
+
54
+ graphql_client.query(query, query_options).data.user.repositories.edges.map do |edge|
55
+ next unless edge.node.default_branch_ref
56
+ edge.node.default_branch_ref.target.history.nodes.map do |node|
57
+ "#{node.author.name} <#{node.author.email}>"
58
+ end
59
+ end.flatten.compact.uniq
60
+ end
61
+
62
+ private
63
+
64
+ def graphql_client
65
+ @graphql_client ||= Graphlient::Client.new(
66
+ 'https://api.github.com/graphql',
67
+ headers: {
68
+ 'Authorization' => "Bearer #{token}",
69
+ 'Content-Type' => 'application/json'
70
+ }
71
+ )
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module Fue
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/lib/fue.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'fue/version'
2
+ require 'fue/finder'
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Doubrovkine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: graphlient
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.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.3.0
41
+ description:
42
+ email: dblock@dblock.org
43
+ executables:
44
+ - fue
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CHANGELOG.md
49
+ - CONTRIBUTING.md
50
+ - LICENSE.md
51
+ - README.md
52
+ - bin/fue
53
+ - lib/fue.rb
54
+ - lib/fue/finder.rb
55
+ - lib/fue/version.rb
56
+ homepage: http://github.com/dblock/fue
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.6
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.6.12
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Find an e-mail address of a Github user.
80
+ test_files: []