repo_parser 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +1 -1
- data/Rakefile +3 -4
- data/bin/{repo-parser → repo_parser} +1 -1
- data/lib/repo_parser.rb +27 -14
- data/lib/repo_parser/version.rb +4 -1
- data/repo_parser.gemspec +2 -3
- data/spec/repo_parser_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdeffd4817a0819085de78226f215116fbf5508f
|
4
|
+
data.tar.gz: f68e267c32a89bb45ccf96c5ff33e671f4aea70b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0bdc0d141b26ccfe5e13a50eae2624e0f2b115d0f005e270222b869679b81becf5338ce26eb9486fa8b5b2362d32dfcb4f7349fec573dc25eef05b7966eea2b
|
7
|
+
data.tar.gz: cbc6ad84326cf79da1480ba907684d463cc24ae47c23fffea1fb9e8297cf6456e62557fc2065a595e9d901738e7de15681487a1a943e8d57dc7c67d06b3a46a2
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/repo_parser.rb
CHANGED
@@ -6,13 +6,24 @@ require 'httparty'
|
|
6
6
|
# and sorting it.
|
7
7
|
module RepoParser
|
8
8
|
def self.run
|
9
|
-
repos =
|
10
|
-
|
11
|
-
Result.new(sorted)
|
9
|
+
repos = chain(Fetcher, Parser, Filterer, Sorter)
|
10
|
+
Result.new(repos)
|
12
11
|
end
|
13
12
|
|
13
|
+
def self.chain(*processors)
|
14
|
+
# the first is called with no args
|
15
|
+
value = processors.shift.call
|
16
|
+
|
17
|
+
processors.each do |proc|
|
18
|
+
value = proc.call(value)
|
19
|
+
end
|
20
|
+
|
21
|
+
value
|
22
|
+
end
|
23
|
+
|
24
|
+
# Result stores the result of a parsing
|
14
25
|
class Result < Struct.new(:repositories)
|
15
|
-
def
|
26
|
+
def to_s
|
16
27
|
lines = []
|
17
28
|
|
18
29
|
lines << <<-STRING
|
@@ -20,15 +31,7 @@ module RepoParser
|
|
20
31
|
==========
|
21
32
|
STRING
|
22
33
|
|
23
|
-
repositories.
|
24
|
-
lines << <<-STRING
|
25
|
-
#{repo.name}:
|
26
|
-
name: #{repo.name}
|
27
|
-
url: #{repo.url}
|
28
|
-
owner: #{repo.owner}
|
29
|
-
----------
|
30
|
-
STRING
|
31
|
-
end
|
34
|
+
lines += repositories.map(&:to_s)
|
32
35
|
|
33
36
|
lines << <<-STRING
|
34
37
|
Total: #{repositories.length}
|
@@ -58,7 +61,17 @@ module RepoParser
|
|
58
61
|
end
|
59
62
|
|
60
63
|
# Repository represents a repository
|
61
|
-
Repository
|
64
|
+
class Repository < Struct.new(:name, :url, :owner, :fork)
|
65
|
+
def to_s
|
66
|
+
<<-STRING
|
67
|
+
#{name}:
|
68
|
+
name: #{name}
|
69
|
+
url: #{url}
|
70
|
+
owner: #{owner}
|
71
|
+
----------
|
72
|
+
STRING
|
73
|
+
end
|
74
|
+
end
|
62
75
|
|
63
76
|
# Filterer filters non-matching repositories
|
64
77
|
class Filterer
|
data/lib/repo_parser/version.rb
CHANGED
data/repo_parser.gemspec
CHANGED
@@ -9,13 +9,12 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Matthew Rudy Jacobs']
|
10
10
|
spec.email = ['matthewrudyjacobs@gmail.com']
|
11
11
|
spec.summary = 'RepoParser is a code example'
|
12
|
-
spec.description = 'Take the github repositories list, and filter it to ruby libraries.'
|
13
12
|
spec.homepage = 'https://github.com/matthewrudy/repo_parser'
|
14
13
|
spec.license = 'MIT'
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(
|
18
|
-
spec.test_files = spec.files.grep(
|
16
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
19
18
|
spec.require_paths = ['lib']
|
20
19
|
|
21
20
|
spec.add_dependency 'httparty', '~> 0.13.3'
|
data/spec/repo_parser_spec.rb
CHANGED
@@ -28,4 +28,12 @@ RSpec.describe RepoParser do
|
|
28
28
|
|
29
29
|
expect(ruby_names).to eq names
|
30
30
|
end
|
31
|
+
|
32
|
+
it 'returns only non-forked repositories' do
|
33
|
+
repositories = RepoParser.run.repositories
|
34
|
+
|
35
|
+
forked = repositories.select(&:fork)
|
36
|
+
|
37
|
+
expect(forked).to be_empty
|
38
|
+
end
|
31
39
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repo_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Rudy Jacobs
|
@@ -66,22 +66,23 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- matthewrudyjacobs@gmail.com
|
72
72
|
executables:
|
73
|
-
-
|
73
|
+
- repo_parser
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
+
- ".rubocop.yml"
|
79
80
|
- ".travis.yml"
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE.txt
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|
84
|
-
- bin/
|
85
|
+
- bin/repo_parser
|
85
86
|
- lib/repo_parser.rb
|
86
87
|
- lib/repo_parser/version.rb
|
87
88
|
- repo_parser.gemspec
|