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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18182ea53d8ed6c02f78b5451f1fe9cdf791ee62
4
- data.tar.gz: a04fb247a0c7da8ca1cef0e7f9fbe3055115f5f0
3
+ metadata.gz: 6a81c281627bffc4e01efcd624f0675b7454e5c8
4
+ data.tar.gz: c742de3a5786dc061446a6de0a1431d024c4538c
5
5
  SHA512:
6
- metadata.gz: 145d19cc251ade0084813d8236e7074c8b61106cdd0565fff8a5f852f71c7a9bbfa170c1d7a4715d37e98c9279b7d7e156b401ba90e3708487b911f728a72d23
7
- data.tar.gz: d9171bf9a53ceae58d26df8e5b429edc5ecaf0d799b7e48474532205509410c5f30ad7a63e3c26e6a50533006f64e554acb77149907dccb4dbc3592c4c0fbeb1
6
+ metadata.gz: e26e990118a288d06b4c2cadfacab0eacf54a5ccff1b0ed5549aa1e7d2f01bdbb15b3febf26eb37febfeb4538d760ac0feba8f3ee282ac2116b6de69f74d6dfb
7
+ data.tar.gz: 43422079a7b29a06cf11eb80e6ecabd5aeda1c4a4a0f5c5e570ac57755caeb131984dc41f2e9fd910f1d57a0199bead5f663efb0c09c9a4e168ae492a5d1723d
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .token.yml
11
+ contribute-0.1.0.gem
@@ -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
@@ -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.
@@ -1,2 +1,2 @@
1
1
  token:
2
- 'your_github_token'
2
+ 'your_github_token'
@@ -2,4 +2,10 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
- before_install: gem install bundler -v 1.12.5
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in contribute.gemspec
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
- Find repos with most stars and open issues, while you hum to [Coldplay in background](https://www.youtube.com/watch?v=yKNxeF4KMsY).
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 [what enemies are up to](https://github.com/NIT-dgp/contribute/issues).
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
@@ -1,6 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ task default: :spec
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "contribute"
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 "irb"
14
+ require 'irb'
14
15
  IRB.start
@@ -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 = "contribute"
8
+ spec.name = 'contribute'
8
9
  spec.version = Contribute::VERSION
9
- spec.authors = ["Aditya Prakash"]
10
- spec.email = ["aditya.prakash132@gmail.com"]
10
+ spec.authors = ['Aditya Prakash']
11
+ spec.email = ['aditya.prakash132@gmail.com']
11
12
 
12
- spec.summary = %q{Contribute finds active repositories on github}
13
- spec.description = %q{It uses github api to find most active repositories for people to contribute.}
14
- spec.homepage = "https://github.com/NIT-dgp/contribute"
15
- spec.license = "MIT"
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| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
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 = ["lib"]
24
+ spec.require_paths = ['lib']
21
25
 
22
- spec.add_runtime_dependency "octokit", "~> 4.0"
23
- spec.add_development_dependency "bundler", "~> 1.12"
24
- spec.add_development_dependency "pry", "~> 0.10"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
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
@@ -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/stars'
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
@@ -1,17 +1,56 @@
1
1
  module Contribute
2
2
  class Finder
3
- def initialize
4
- token_file = YAML::load_file(File.expand_path('../../.token.yml', __dir__))
5
- @token = token_file['token']
6
- @finder = Octokit::Client.new access_token: token
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 stars
10
- results = finder.search_repositories(' stars:>10000')
11
- puts results['items'].map { |r| r['full_name'] }
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
- private
15
- attr_reader :token, :finder
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Contribute
2
- VERSION = "0.1.0"
3
+ VERSION = '0.1.1'.freeze
3
4
  end
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.0
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: 2016-11-16 00:00:00.000000000 Z
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
- description: It uses github api to find most active repositories for people to contribute.
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:
@@ -1,5 +0,0 @@
1
- module Contribute
2
- class Stars
3
-
4
- end
5
- end