contribute 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +52 -0
- data/.rubocop_todo.yml +7 -0
- data/.token.yml.example +1 -1
- data/.travis.yml +7 -1
- data/Gemfile +1 -0
- data/README.md +32 -9
- data/Rakefile +4 -3
- data/bin/console +4 -3
- data/contribute.gemspec +22 -15
- data/lib/contribute.rb +4 -2
- data/lib/contribute/client.rb +13 -0
- data/lib/contribute/extended_sort.rb +16 -0
- data/lib/contribute/finder.rb +49 -10
- data/lib/contribute/version.rb +2 -1
- metadata +61 -4
- data/lib/contribute/stars.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a81c281627bffc4e01efcd624f0675b7454e5c8
|
4
|
+
data.tar.gz: c742de3a5786dc061446a6de0a1431d024c4538c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e26e990118a288d06b4c2cadfacab0eacf54a5ccff1b0ed5549aa1e7d2f01bdbb15b3febf26eb37febfeb4538d760ac0feba8f3ee282ac2116b6de69f74d6dfb
|
7
|
+
data.tar.gz: 43422079a7b29a06cf11eb80e6ecabd5aeda1c4a4a0f5c5e570ac57755caeb131984dc41f2e9fd910f1d57a0199bead5f663efb0c09c9a4e168ae492a5d1723d
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- .rubocop_todo.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.0
|
6
|
+
Exclude:
|
7
|
+
- tmp/**/*
|
8
|
+
- lib/bundler/vendor/**/*
|
9
|
+
DisplayCopNames: true
|
10
|
+
|
11
|
+
# Lint
|
12
|
+
|
13
|
+
Lint/EndAlignment:
|
14
|
+
AlignWith: variable
|
15
|
+
AutoCorrect: true
|
16
|
+
|
17
|
+
# Style
|
18
|
+
Metrics/LineLength:
|
19
|
+
Max: 100
|
20
|
+
|
21
|
+
Style/AccessModifierIndentation:
|
22
|
+
EnforcedStyle: outdent
|
23
|
+
|
24
|
+
Style/Alias:
|
25
|
+
EnforcedStyle: prefer_alias_method
|
26
|
+
|
27
|
+
Style/AlignParameters:
|
28
|
+
EnforcedStyle: with_fixed_indentation
|
29
|
+
|
30
|
+
Style/Documentation:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/FrozenStringLiteralComment:
|
34
|
+
Enabled: falses
|
35
|
+
|
36
|
+
Style/MultilineOperationIndentation:
|
37
|
+
EnforcedStyle: indented
|
38
|
+
|
39
|
+
# We adopted raise instead of fail.
|
40
|
+
Style/SignalException:
|
41
|
+
EnforcedStyle: only_raise
|
42
|
+
|
43
|
+
Style/StringLiterals:
|
44
|
+
EnforcedStyle: single_quotes
|
45
|
+
|
46
|
+
Style/StringLiteralsInInterpolation:
|
47
|
+
EnforcedStyle: single_quotes
|
48
|
+
|
49
|
+
# Having these make it easier to *not* forget to add one when adding a new
|
50
|
+
# value and you can simply copy the previous line.
|
51
|
+
Style/TrailingCommaInLiteral:
|
52
|
+
EnforcedStyleForMultiline: comma
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-12-28 19:43:39 +0530 using RuboCop version 0.46.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/.token.yml.example
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
token:
|
2
|
-
'your_github_token'
|
2
|
+
'your_github_token'
|
data/.travis.yml
CHANGED
@@ -2,4 +2,10 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
4
|
- 2.3.1
|
5
|
-
before_install:
|
5
|
+
before_install:
|
6
|
+
- gem install bundler -v 1.12.5
|
7
|
+
- cp .token.yml.example .token.yml
|
8
|
+
- echo -e "token:\n $GITHUB_TOKEN" > ./.token.yml
|
9
|
+
script:
|
10
|
+
- RAILS_ENV=test bundle exec rspec
|
11
|
+
- bundle exec rubocop
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
Have you been looking for open source reposotires to contribute? Look no further! You have come to right place. This gem will find active reposotries from github to eat away your weekend time. Say goodbay to fruitless late night research, tiring click surfing and the voice in your head which make you feel guilty for not doing enough. Be warned! Your life will never be same after you have installed this gem. We offer all these unbelievbale features at a never before price of FREE! FREE! FREE!
|
4
4
|
Why are you still waiting? Get your terminals rolling, install this gem and experience the change.
|
5
5
|
|
6
|
+
Disclaim: This gem is WIP. We will be adding exciting features like sorting repos by most newcomer issues and active pulse. Until then you should have a look at http://up-for-grabs.net/#/
|
7
|
+
|
6
8
|
## Installation
|
7
9
|
|
8
10
|
Add this line to your application's Gemfile:
|
@@ -24,7 +26,7 @@ Or install it yourself as:
|
|
24
26
|
You will need you api access token. [Github people have written about how can you get those magic bits](https://github.com/blog/1509-personal-api-tokens).
|
25
27
|
|
26
28
|
Rename `.token.yml.exmaple` to `.token.yml`.
|
27
|
-
|
29
|
+
```
|
28
30
|
cp .token.yml.example .token.yml
|
29
31
|
```
|
30
32
|
|
@@ -32,17 +34,39 @@ Replace `your_github_token` in `.token.yml` with your github token.
|
|
32
34
|
|
33
35
|
### Look at the stars, Look how they shine for you
|
34
36
|
|
35
|
-
|
37
|
+
You can chain various options. For example, following command will return repos with primary language ruby and whose stars are between 1000 and 5000:
|
36
38
|
|
37
39
|
```Ruby
|
38
|
-
Contribute::Finder.stars
|
40
|
+
Contribute::Finder.new.language("ruby").stars(1000,5000).find
|
39
41
|
```
|
40
42
|
|
41
|
-
|
43
|
+
You can also use any search string as per [github documentation](https://help.github.com/articles/searching-code/) to find repos.
|
44
|
+
|
45
|
+
```Ruby
|
46
|
+
Contribute::Finder.new("language:ruby").find
|
47
|
+
```
|
48
|
+
|
49
|
+
#### Finding repos
|
50
|
+
You can filter out repo of your interest using following methods:
|
51
|
+
* `forks`
|
52
|
+
* `stars`
|
53
|
+
* `langauge`
|
54
|
+
|
55
|
+
#### Sorting and ordering
|
56
|
+
Sort repos by calling `sort_by`. Call `order` with `desc` or `asc` to order your repos in descending and ascending order respectively.
|
57
|
+
```Ruby
|
58
|
+
# valid option for sorting: created, updated, stars, forks
|
59
|
+
Contribute::Finder.new("language:ruby").sort_by('stars').order('asc')find
|
60
|
+
```
|
61
|
+
Use `Contribute::ExtendedSort` module if you would like sort by name, size, watchers and issues.
|
62
|
+
```Ruby
|
63
|
+
repos = Contribute::Finder.new("language:ruby").find
|
64
|
+
Contribute::ExtendedSort.sort_by!(repos, 'size')
|
65
|
+
```
|
42
66
|
|
43
67
|
## Development
|
44
68
|
|
45
|
-
Omg Stranger! You very kind for reading this. Contribute needs you! Get your environment loaded with all the gems you will need in your journey ahead:
|
69
|
+
Omg Stranger! You are very kind for reading this. Contribute needs you! Get your environment loaded with all the gems you will need in your journey ahead:
|
46
70
|
|
47
71
|
```sh
|
48
72
|
# In side contribute folder
|
@@ -57,12 +81,11 @@ Make changes to code and test it in terminal:
|
|
57
81
|
```sh
|
58
82
|
# Load copy of your gem in your irb
|
59
83
|
$ irb -Ilib -rcontribute
|
60
|
-
2.3.1 :001 >
|
84
|
+
2.3.1 :001 > Contribute::Finder.new('language:ruby').find
|
85
|
+
```
|
61
86
|
|
62
|
-
Take at look at [
|
63
|
-
Slay many bug, you will. Yes, hmmm.
|
87
|
+
Take at look at [our issues board](https://github.com/NIT-dgp/contribute/issues).
|
64
88
|
|
65
89
|
## License
|
66
90
|
|
67
91
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
68
|
-
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'contribute'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "contribute"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
data/contribute.gemspec
CHANGED
@@ -1,27 +1,34 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'contribute/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'contribute'
|
8
9
|
spec.version = Contribute::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Aditya Prakash']
|
11
|
+
spec.email = ['aditya.prakash132@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
|
15
|
-
spec.
|
13
|
+
spec.summary = 'Contribute finds active repositories on github'
|
14
|
+
spec.description = 'It uses github api to find most active'\
|
15
|
+
'repositories for people to contribute.'
|
16
|
+
spec.homepage = 'https://github.com/NIT-dgp/contribute'
|
17
|
+
spec.license = 'MIT'
|
16
18
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
18
|
-
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
}
|
22
|
+
spec.bindir = 'exe'
|
19
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
24
|
+
spec.require_paths = ['lib']
|
21
25
|
|
22
|
-
spec.add_runtime_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
26
|
+
spec.add_runtime_dependency 'octokit', '~> 4.0'
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
28
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.46.0'
|
32
|
+
spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
33
|
+
spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.1'
|
27
34
|
end
|
data/lib/contribute.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'contribute/version'
|
2
3
|
require 'octokit'
|
3
|
-
require 'pry'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
require 'contribute/finder'
|
7
|
-
require 'contribute/
|
7
|
+
require 'contribute/client'
|
8
|
+
require 'contribute/extended_sort'
|
8
9
|
|
10
|
+
# Main module of the gem
|
9
11
|
module Contribute
|
10
12
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Contribute
|
3
|
+
# Class to find repos with stars
|
4
|
+
class Client
|
5
|
+
attr_reader :octokit
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
token_file = YAML.load_file(File.expand_path('../../.token.yml', __dir__))
|
9
|
+
token = token_file['token']
|
10
|
+
@octokit = Octokit::Client.new access_token: token
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Contribute
|
2
|
+
module ExtendedSort
|
3
|
+
SORT_OPTIONS = %w(name size watchers issues).freeze
|
4
|
+
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def sort_by!(repos, field)
|
8
|
+
raise error_msg unless SORT_OPTIONS.include? field
|
9
|
+
repos.sort! { |a, b| a.send(field) <=> b.send(field) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def error_msg
|
13
|
+
"sort field argument is not valid. Valid inputs: #{SORT_OPTIONS.join(', ')}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/contribute/finder.rb
CHANGED
@@ -1,17 +1,56 @@
|
|
1
1
|
module Contribute
|
2
2
|
class Finder
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
Repo = Struct.new(:full_name, :name, :size, :watchers, :issues)
|
4
|
+
|
5
|
+
SORT_OPTIONS = %w(created updated stars forks).freeze
|
6
|
+
ORDER_OPTIONS = %w(desc asc).freeze
|
7
|
+
|
8
|
+
def initialize(query = '', options = {})
|
9
|
+
@finder_client = Contribute::Client.new.octokit
|
10
|
+
@query = query
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def language(name)
|
15
|
+
query << " language:#{name}"
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def stars(lo = '*', hi = '*')
|
20
|
+
query << " stars:#{lo}..#{hi}"
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def forks(lo = '*', hi = '*')
|
25
|
+
query << " forks:#{lo}..#{hi}"
|
26
|
+
self
|
7
27
|
end
|
8
28
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
29
|
+
def sort_by(field)
|
30
|
+
raise error_msg('sort', SORT_OPTIONS) unless SORT_OPTIONS.include? field
|
31
|
+
options[:sort] = field
|
32
|
+
self
|
12
33
|
end
|
13
34
|
|
14
|
-
|
15
|
-
|
35
|
+
def order(type)
|
36
|
+
raise error_msg('order', ORDER_OPTIONS) unless ORDER_OPTIONS.include? type
|
37
|
+
options[:order] = type
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def find
|
42
|
+
results = finder_client.search_repositories query, options
|
43
|
+
results['items'].map do |r|
|
44
|
+
Repo.new(r['full_name'], r['name'], r['size'], r['watchers'], r['open_issues'])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
attr_reader :finder_client, :query, :options
|
51
|
+
|
52
|
+
def error_msg(type, valid_otions)
|
53
|
+
"'#{type}' field argument is not valid. Valid inputs: #{valid_otions.join(', ')}"
|
54
|
+
end
|
16
55
|
end
|
17
|
-
end
|
56
|
+
end
|
data/lib/contribute/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditya Prakash
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -80,7 +80,61 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.46.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.46.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 3.0.3
|
107
|
+
type: :development
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '3.0'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 3.0.3
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: webmock
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.3'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2.3.1
|
127
|
+
type: :development
|
128
|
+
prerelease: false
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '2.3'
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 2.3.1
|
137
|
+
description: It uses github api to find most activerepositories for people to contribute.
|
84
138
|
email:
|
85
139
|
- aditya.prakash132@gmail.com
|
86
140
|
executables: []
|
@@ -89,6 +143,8 @@ extra_rdoc_files: []
|
|
89
143
|
files:
|
90
144
|
- ".gitignore"
|
91
145
|
- ".rspec"
|
146
|
+
- ".rubocop.yml"
|
147
|
+
- ".rubocop_todo.yml"
|
92
148
|
- ".token.yml.example"
|
93
149
|
- ".travis.yml"
|
94
150
|
- CODE_OF_CONDUCT.md
|
@@ -100,8 +156,9 @@ files:
|
|
100
156
|
- bin/setup
|
101
157
|
- contribute.gemspec
|
102
158
|
- lib/contribute.rb
|
159
|
+
- lib/contribute/client.rb
|
160
|
+
- lib/contribute/extended_sort.rb
|
103
161
|
- lib/contribute/finder.rb
|
104
|
-
- lib/contribute/stars.rb
|
105
162
|
- lib/contribute/version.rb
|
106
163
|
homepage: https://github.com/NIT-dgp/contribute
|
107
164
|
licenses:
|