fantasyhub 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Guardfile +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/bin/console +3 -0
- data/bin/run_test_suite +24 -0
- data/fantasyhub.gemspec +28 -0
- data/id_rsa_fantasyhubber +27 -0
- data/id_rsa_fantasyhubber.pub +1 -0
- data/lib/fantasyhub.rb +36 -0
- data/lib/fantasyhub/event.rb +12 -0
- data/lib/fantasyhub/events.rb +5 -0
- data/lib/fantasyhub/events/commit_comment_event.rb +10 -0
- data/lib/fantasyhub/events/create_event.rb +10 -0
- data/lib/fantasyhub/events/delete_event.rb +10 -0
- data/lib/fantasyhub/events/follow_event.rb +10 -0
- data/lib/fantasyhub/events/fork_event.rb +10 -0
- data/lib/fantasyhub/events/gollumn_event.rb +10 -0
- data/lib/fantasyhub/events/issue_comment_event.rb +10 -0
- data/lib/fantasyhub/events/issues_event.rb +10 -0
- data/lib/fantasyhub/events/member_event.rb +10 -0
- data/lib/fantasyhub/events/pull_request_event.rb +10 -0
- data/lib/fantasyhub/events/pull_request_review_comment_event.rb +10 -0
- data/lib/fantasyhub/events/push_event.rb +11 -0
- data/lib/fantasyhub/events/watch_event.rb +10 -0
- data/lib/fantasyhub/feed.rb +5 -0
- data/lib/fantasyhub/feed/downloader.rb +21 -0
- data/lib/fantasyhub/feed/parser.rb +24 -0
- data/lib/fantasyhub/feed/scorer.rb +25 -0
- data/lib/fantasyhub/version.rb +3 -0
- data/lib/tasks/test.rake +10 -0
- data/test/ci/before_script.sh +0 -0
- data/test/ci/ci_runner.sh +1 -0
- data/test/fantasyhub/events_test.rb +13 -0
- data/test/fantasyhub/feed/downloader_test.rb +14 -0
- data/test/fantasyhub/feed/parser_test.rb +35 -0
- data/test/fantasyhub/feed/scorer_test.rb +65 -0
- data/test/fantasyhub_test.rb +12 -0
- data/test/fixtures/cassettes/tenderlove_activity.yml +4162 -0
- data/test/fixtures/cassettes/tenderlove_activity_feed.yml +4162 -0
- data/test/fixtures/tenderlove.json +1 -0
- data/test/integration_test.rb +12 -0
- data/test/minitest_helper.rb +20 -0
- data/test/support/minitest_reporters.rb +4 -0
- data/test/support/mocha.rb +1 -0
- data/test/support/open_struct.rb +1 -0
- data/test/support/vcr.rb +8 -0
- metadata +224 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c64607b9ec6ccffb1659ee10084757bc058289d
|
4
|
+
data.tar.gz: 303569745a85f624ebf15b7bf935a90815a96937
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01ec01fbd216539c4b01092476874a0540b9cb99dcc88104a03806da208fc74d3aed093c4fa521db26c193751db1f528751491893292b60b325ea2e14bd9c45d
|
7
|
+
data.tar.gz: f0eb8d778cf0a98e155a9b8acb83f832672a103bd32a3eda2cb98c0640aaceb74d348756fe75003ea2910ef529a7426806df410d42a3980ea2f929813dd5526f
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
.env
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard "minitest" do
|
5
|
+
# with Minitest::Spec
|
6
|
+
watch(%r|^test/(.*)_test\.rb|)
|
7
|
+
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
8
|
+
watch(%r|^test/minitest_helper\.rb|) { "test" }
|
9
|
+
watch(%r|^test/support/|) { "test" }
|
10
|
+
|
11
|
+
# Rails 3.2
|
12
|
+
watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
|
13
|
+
watch(%r|^app/mailers/(.*)\.rb|) { |m| "test/mailers/#{m[1]}_test.rb" }
|
14
|
+
watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
|
15
|
+
watch(%r|^app/models/(.*)\.rb|) { |m| "test/models/#{m[1]}_test.rb" }
|
16
|
+
end
|
17
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 thatrubylove
|
2
|
+
|
3
|
+
MIT License
|
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,49 @@
|
|
1
|
+
# Fantasyhub
|
2
|
+
|
3
|
+
This is the business logic behind th web app for PeepCode's PBP Challenge issued to @wycats and @tenderlove, This is my isolated, test driven, functional version.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fantasyhub'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fantasyhub
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
scored_events = Fantasyhub.score_activity_feed(uid)
|
23
|
+
# => [Event, Event, ...]
|
24
|
+
|
25
|
+
scored_events.map{|event| event.score}.reduce(:+)
|
26
|
+
```
|
27
|
+
|
28
|
+
## Running the test suite
|
29
|
+
|
30
|
+
I don't use rake to run Ruby tests. (Sorry Jim)
|
31
|
+
|
32
|
+
Rake in my experience slows down your tests. Not as much as external dependencies to Rails, but still, slow. I have also dropped a log statement in my boot.rb file in a rails app and watched Rake load my env several times before the tests run.
|
33
|
+
|
34
|
+
To solve this, I simply use Ruby these days. You will find the test suite 'runner' in the root, and you can run it like so:
|
35
|
+
|
36
|
+
```
|
37
|
+
./run_test_suite
|
38
|
+
```
|
39
|
+
|
40
|
+
That is all :)
|
41
|
+
|
42
|
+
## Supported Rubies
|
43
|
+
|
44
|
+
I have long disowned 1.8 and 1.9. Run this in 2.0+
|
45
|
+
|
46
|
+
|
47
|
+
## Code Health
|
48
|
+
|
49
|
+
[![Code Climate](https://codeclimate.com/github/thatrubylove/fantasyhub.png)](https://codeclimate.com/github/thatrubylove/fantasyhub) [![Build Status](https://travis-ci.org/thatrubylove/fantasyhub.svg?branch=master)](https://travis-ci.org/thatrubylove/fantasyhub)
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/run_test_suite
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
exit(1) if __FILE__ != $0
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'webmock'
|
6
|
+
|
7
|
+
if ENV.has_key?("SLOW")
|
8
|
+
if ENV.has_key?("CODECLIMATE_REPO_TOKEN")
|
9
|
+
require "codeclimate-test-reporter"
|
10
|
+
|
11
|
+
WebMock.disable_net_connect!(:allow => "codeclimate.com")
|
12
|
+
CodeClimate::TestReporter.start
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift('lib', 'test')
|
17
|
+
|
18
|
+
fast_tests = `find ./test -name *_test.rb -print | xargs grep -l "minitest_helper"`
|
19
|
+
Dir.glob(fast_tests.split("\n")) { |f| puts f; require f }
|
20
|
+
|
21
|
+
exit(0) unless ENV.keys.include?("SLOW")
|
22
|
+
|
23
|
+
slow_tests = `find ./test -name *_test.rb -print | xargs grep -L "minitest_helper"`
|
24
|
+
Dir.glob(slow_tests.split("\n")) { |f| puts f; require f }
|
data/fantasyhub.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fantasyhub/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fantasyhub"
|
8
|
+
spec.version = Fantasyhub::VERSION
|
9
|
+
spec.authors = ["thatrubylove"]
|
10
|
+
spec.email = ["thatrubylove@gmail.com"]
|
11
|
+
spec.summary = %q{Business logic for #peepcode's challenge, the fantasy league of githubbers}
|
12
|
+
spec.homepage = "https://github.com/thatrubylove/fantasyhub"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", ">1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "thincloud-test", "~> 1.0.0"
|
23
|
+
spec.add_development_dependency "formatador"
|
24
|
+
spec.add_development_dependency "vcr"
|
25
|
+
spec.add_development_dependency "dotenv"
|
26
|
+
spec.add_development_dependency "webmock"
|
27
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
2
|
+
MIIEogIBAAKCAQEAtStbI5u+zrprnYERQvBl760gaj5WI7S7bViEQjskRtaFi+cT
|
3
|
+
O6aknof2LWN0M961fCBJMIN738DyDOHdOzpJhA6KclrVBGdOmj21kWLI+dQOEIyU
|
4
|
+
ynfBbvK0lj4xz3qqz8rvG3hNNeb7I+nbrCKwDfaULkVVlyYNJPv7/n3TNS6soXND
|
5
|
+
riBvccxVp6MNOGBAWoakppMNVemN2qtNQ/FfeHb076Hyy//rXikTMp3jEtXG4ubi
|
6
|
+
0I+hIntk+QvvPeJnsw12ZBmBYM29YplnTbXLzc1RjmHc74CzHriCJsG0I2CVwGgi
|
7
|
+
ecplVbZ9bCtyXWMzhLU5HtcdWalucTGZ2qCGGwIDAQABAoIBAA+yN+032yoyAIze
|
8
|
+
184C4fIH/9z0laX2TJ7Gon7SfOwePefHF2V9pJmPkgaQrUqpKvQcH/syCRNztgTj
|
9
|
+
tLUi8aedUuVhdT8ybB705bw44My0UJuicmmwQnQIVxkFPm+JYy8pl9m7bIUVBAEy
|
10
|
+
i7O4NaSgDmq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xOObOs3TqNe9I3T0Zh
|
25
|
+
gm87YmEEO7/uKGNT4E1eyiqnxpYFX4Ge2HHgdm7oep3t/9S7KlV/vmns66XYbiBB
|
26
|
+
Qs/2e4m4nkBOo4FfOMwsfrlOtNmXM5NXt87sA4bdpQwLykNjOko=
|
27
|
+
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1 @@
|
|
1
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1K1sjm77OumudgRFC8GXvrSBqPlYjtLttWIRCOyRG1oWL5xM7pqSeh/YtY3Qz3rV8IEkwg3vfwPIM4d07OkmEDopyWtUEZ06aPbWRYsj51A4QjJTKd8Fu8rSWPjHPeqrPyu8beE015vsj6dusIrAN9pQuRVWXJg0k+/v+fdM1Lqyhc0OuIG9xzFWnow04YEBahqSmkw1V6Y3aq01D8V94dvTvofLL/+teKRMyneMS1cbi5uLQj6Eie2T5C+894mezDXZkGYFgzb1imWdNtcvNzVGOYdzvgLMeuIImwbQjYJXAaCJ5ymVVtn1sK3JdYzOEtTke1x1ZqW5xMZnaoIYb rubylove@MacBook-Pro-de-Jim.local
|
data/lib/fantasyhub.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "fantasyhub/version"
|
2
|
+
|
3
|
+
module Fantasyhub
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def event_scores_sum_for(uid)
|
7
|
+
sum_event_scores(uid)
|
8
|
+
end
|
9
|
+
alias_method :call, :event_scores_sum_for
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def sum_event_scores(uid)
|
14
|
+
scores = score_activity_feed(uid)
|
15
|
+
scores.map {|event| event.score }.reduce(:+)
|
16
|
+
end
|
17
|
+
|
18
|
+
def score_activity_feed(uid)
|
19
|
+
score(parsed(activity_feed(uid)))
|
20
|
+
end
|
21
|
+
|
22
|
+
def activity_feed(uid)
|
23
|
+
Feed::Downloader.(uid)
|
24
|
+
end
|
25
|
+
|
26
|
+
def parsed(feed)
|
27
|
+
Feed::Parser.(feed)
|
28
|
+
end
|
29
|
+
|
30
|
+
def score(feed)
|
31
|
+
Feed::Scorer.(feed)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
require "fantasyhub/feed"
|
36
|
+
require "fantasyhub/events"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Fantasyhub::Event
|
2
|
+
|
3
|
+
attr_reader :actor, :event_type, :repo_url, :score, :created_at
|
4
|
+
|
5
|
+
def initialize(hash)
|
6
|
+
@actor = hash.fetch(:actor)
|
7
|
+
@event_type = hash.fetch(:event_type)
|
8
|
+
@repo_url = hash.fetch(:repo_url)
|
9
|
+
@score = hash.fetch(:score)
|
10
|
+
@created_at = hash.fetch(:created_at)
|
11
|
+
end
|
12
|
+
end
|