papercall 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4741845b46d4545886a11ef1d4f7b4f0975efc08
4
+ data.tar.gz: 4a2d9bfd810267805aacb729273badf7cde964f9
5
+ SHA512:
6
+ metadata.gz: 9c994b057761d1eb3df3b52197bac299fee4e1c8199e312ca991b055c33dec1549d8f036d82b0f8dd0fe4d8429b1bc04e7cc63d2b84e24ffd34ef48d3a627d15
7
+ data.tar.gz: 8cf1d59c4ab15d2f40f33471756185458090747835ae213817b14617179ca455fcb19122635c95d001bbfcee41160466e5bf58061905637241e633a4e10cee56
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /*.json
11
+ /*.rb
12
+ /*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.13.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at joe@statoil.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in papercall.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: 'bundle exec rspec' do
28
+ require 'guard/rspec/dsl'
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
69
+ end
70
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jørn Ølmheim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Papercall
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/papercall`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'papercall'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install papercall
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/papercall. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
7
+
8
+ task check: :rubocop
9
+
10
+ task :rubocop do
11
+ sh 'rubocop'
12
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "papercall"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,98 @@
1
+ module Papercall
2
+ class Analysis
3
+ def initialize submissions
4
+ @analysis = {}
5
+ @analysis['submissions'] = submissions
6
+ @analysis['reviewers'] = {}
7
+ @analysis['talksWithoutReviews'] = []
8
+ @analysis['talksWithLessThanThreeReviews'] = []
9
+ @analysis['talksWithFourOrMoreReviews'] = []
10
+ @analysis['talksWithoutFeedback'] = []
11
+ @analysis['highlyRated'] = []
12
+ @analysis['lowRated'] = []
13
+ @analysis['maybe'] = []
14
+ @analysis['accepted'] = []
15
+ @analysis['waitlist'] = []
16
+ @analysis['rejected'] = []
17
+ @analysis['confirmed'] = []
18
+ end
19
+
20
+ def analyze
21
+ @analysis['submissions'].each do |submission|
22
+ submission["ratings"].each do |rating|
23
+ unless(@analysis['reviewers'].include?(rating["user"]["name"]))
24
+ @analysis['reviewers'][rating["user"]["name"]] = [{:id => rating["submission_id"]}]
25
+ else
26
+ @analysis['reviewers'][rating['user']['name']].push({:id => rating["submission_id"]})
27
+ end
28
+ end
29
+ @analysis['talksWithoutReviews'].push({:id => submission["id"]}) if submission["ratings"].empty?
30
+ @analysis['talksWithFourOrMoreReviews'].push({:id => submission["id"]}) if submission["ratings"].size >= 4
31
+ @analysis['talksWithLessThanThreeReviews'].push({:id => submission["id"]}) if submission["ratings"].size < 3
32
+ @analysis['talksWithoutFeedback'].push({:id => submission["id"]}) if submission["feedback"].empty?
33
+ @analysis['highlyRated'].push({:id => submission["id"], :submission => submission}) if highlyRated? submission
34
+ @analysis['lowRated'].push({:id => submission["id"], :submission => submission}) if lowRated? submission
35
+ @analysis['maybe'].push({:id => submission["id"], :submission => submission}) if maybe? submission
36
+ @analysis['accepted'].push({:id => submission["id"], :submission => submission}) if accepted? submission
37
+ @analysis['waitlist'].push({:id => submission["id"], :submission => submission}) if waitlisted? submission
38
+ @analysis['rejected'].push({:id => submission["id"], :submission => submission}) if rejected? submission
39
+ @analysis['confirmed'].push({:id => submission["id"], :submission => submission}) if confirmed? submission
40
+ end
41
+ @analysis['summary'] = summary
42
+ @analysis
43
+ end
44
+
45
+ private
46
+
47
+ def highlyRated?(submission)
48
+ submission["rating"] >= 75 && review_complete?(submission)
49
+ end
50
+
51
+ def lowRated?(submission)
52
+ submission["rating"] <= 25 && review_complete?(submission)
53
+ end
54
+
55
+ def maybe?(submission)
56
+ !accepted?(submission) && !rejected?(submission) && review_complete?(submission)
57
+ end
58
+
59
+ def review_complete?(submission)
60
+ submission["ratings"].size >= 3
61
+ end
62
+
63
+ def accepted?(submission)
64
+ submission["state"] == "accepted"
65
+ end
66
+
67
+ def rejected?(submission)
68
+ submission["state"] == "rejected"
69
+ end
70
+
71
+ def waitlisted?(submission)
72
+ submission["state"] == "waitlist"
73
+ end
74
+
75
+ def confirmed?(submission)
76
+ accepted?(submission) && submission["confirmed"] == true
77
+ end
78
+
79
+ def summary
80
+ summary = {}
81
+ summary['numSubmissions'] = @analysis['submissions'].size
82
+ summary['numActiveReviewers'] = @analysis['reviewers'].size
83
+ summary['numWithoutFeedback'] = @analysis['talksWithoutFeedback'].size
84
+ summary['numCompleted'] = @analysis['submissions'].size - @analysis['talksWithLessThanThreeReviews'].size
85
+ summary['numHighlyRated'] = @analysis['highlyRated'].size
86
+ summary['numLowRated'] = @analysis['lowRated'].size
87
+ summary['numMaybe'] = @analysis['maybe'].size
88
+ summary['numLessThanThreeReviews'] = @analysis['talksWithLessThanThreeReviews'].size
89
+ summary['numWithFourOrMoreReviews'] = @analysis['talksWithFourOrMoreReviews'].size
90
+ summary['numWithoutReviews'] = @analysis['talksWithoutReviews'].size
91
+ summary['numAccepted'] = @analysis['accepted'].size
92
+ summary['numWaitlisted'] = @analysis['waitlist'].size
93
+ summary['numRejected'] = @analysis['rejected'].size
94
+ summary['numConfirmed'] = @analysis['confirmed'].size
95
+ summary
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,78 @@
1
+ # Module for fetching submissions from the PaperCall.io paper submission system
2
+ # Also providing some analytics
3
+ module Papercall
4
+ METHOD_REGEX = /(.*)_talks$/
5
+
6
+ def self.fetch(from, api_key='', *states)
7
+ if from == :from_file
8
+ @submissions = Papercall::FileFetcher.new('submissions.json')
9
+ elsif from == :from_papercall
10
+ @submissions = Papercall::RestFetcher.new(api_key)
11
+ end
12
+ @submissions.fetch(states)
13
+ @analysis = Papercall::Analysis.new(@submissions.analysis)
14
+ @analysis = @analysis.analyze
15
+ end
16
+
17
+ def self.all
18
+ @submissions.analysis
19
+ end
20
+
21
+ def self.save_to_file(filename)
22
+ ff = File.open(filename, 'w') { |f| f.write(@submissions.all.to_json) }
23
+ puts "All submissions written to file #{filename}." if ff
24
+ end
25
+
26
+ def self.number_of_submissions
27
+ all.length
28
+ end
29
+
30
+ def self.confirmed_talks
31
+ @submissions.accepted.select do |s|
32
+ s['confirmed'] == true
33
+ end
34
+ end
35
+
36
+ def self.active_reviewers
37
+ @analysis['reviewers']
38
+ end
39
+
40
+ def self.submissions_without_feedback
41
+ @analysis['talksWithoutFeedback']
42
+ end
43
+
44
+ def self.submissions_with_enough_reviews
45
+ @analysis['talksWithLessThanThreeReviews']
46
+ end
47
+
48
+ def self.summary
49
+ s = @analysis['summary']
50
+ puts "Number of submissions: #{s['numSubmissions']}"
51
+ puts "Number of active reviewers: #{s['numActiveReviewers']}"
52
+ puts "Number of submitted talks without feedback: #{s['numWithoutFeedback']}"
53
+ puts "Number of talks with three or more reviews: #{s['numCompleted']}"
54
+ puts "Number of highly rated talks: #{s['numHighlyRated']}"
55
+ puts "Number of low rated talks: #{s['numLowRated']}"
56
+ puts "Number of middle rated talks: #{s['numMaybe']}"
57
+ puts "Number of talks with less than three reviews: #{s['numLessThanThreeReviews']}"
58
+ puts "Number of talks with four or more reviews: #{s['numWithFourOrMoreReviews']}"
59
+ puts "Number of talks without reviews: #{s['numWithoutReviews']}"
60
+ puts "Number of accepted talks: #{s['numAccepted']}"
61
+ puts "Number of waitlisted talks: #{s['numWaitlisted']}"
62
+ puts "Number of rejected talks: #{s['numRejected']}"
63
+ puts "Number of confirmed talks: #{s['numConfirmed']}"
64
+ s
65
+ end
66
+
67
+ def self.respond_to_missing?(method_name, _include_private = false)
68
+ METHOD_REGEX.match method_name.to_s
69
+ end
70
+
71
+ def self.method_missing(method_name, *args, &block)
72
+ if METHOD_REGEX.match method_name.to_s
73
+ @submissions.send(Regexp.last_match[1])
74
+ else
75
+ super
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,26 @@
1
+ module Papercall
2
+ # Superclass for fetchers. A fetcher fetches submissions of different
3
+ # categories and stores them in instance variables.
4
+ class Fetcher
5
+ attr_reader :submitted, :accepted, :rejected, :waitlist, :declined
6
+
7
+ def all
8
+ {
9
+ submitted: @submitted,
10
+ accepted: @accepted,
11
+ rejected: @rejected,
12
+ waitlist: @waitlist,
13
+ declined: @declined
14
+ }
15
+ end
16
+
17
+ def analysis
18
+ all = @submitted
19
+ all += @accepted
20
+ all += @rejected
21
+ all += @waitlist
22
+ all += @declined
23
+ all
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+
3
+ module Papercall
4
+ # Fetches submissions from file.
5
+ # Params:
6
+ # +filename+:: File with submissions. JSON format.
7
+ class FileFetcher < Fetcher
8
+ def initialize(filename)
9
+ @filename = filename
10
+ @submitted = []
11
+ @accepted = []
12
+ @rejected = []
13
+ @waitlist = []
14
+ @declined = []
15
+ end
16
+
17
+ def fetch(_)
18
+ file = File.new(@filename, 'r')
19
+ puts "Reading from file (#{file.path})..."
20
+ submissions = JSON.parse file.read if file
21
+ @submitted = submissions['submitted']
22
+ @accepted = submissions['accepted']
23
+ @rejected = submissions['rejected']
24
+ @waitlist = submissions['waitlist']
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,62 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+
4
+ module Papercall
5
+ #Fetches submissions from Papercall REST API
6
+ # Params:
7
+ class RestFetcher < Fetcher
8
+ SUBMISSIONS_URL = 'https://www.papercall.io/api/v1/submissions'.freeze
9
+
10
+ def initialize(api_key)
11
+ @auth_hash = { Authorization: api_key }
12
+ @submitted = []
13
+ @accepted = []
14
+ @rejected = []
15
+ @waitlist = []
16
+ @declined = []
17
+ end
18
+
19
+ def submission_url(state, per_page: 50)
20
+ "#{SUBMISSIONS_URL}?state=#{state}&per_page=#{per_page}"
21
+ end
22
+
23
+ def papercall(papercall_url)
24
+ raw_results =
25
+ RestClient::Request.execute(method: :get,
26
+ url: papercall_url,
27
+ headers: @auth_hash) # :timeout => 120
28
+ JSON.parse raw_results
29
+ end
30
+
31
+ def fetch(*states)
32
+ states.flatten.each do |state|
33
+ if state
34
+ puts "Fetching #{state} submissions from PaperCall API..."
35
+ instance_variable_set("@#{state}", papercall(submission_url(state.to_s)))
36
+ end
37
+ end
38
+ fetch_ratings
39
+ fetch_feedback
40
+ end
41
+
42
+ def fetch_ratings
43
+ puts "Fetching ratings for all submissions from Papercall API..."
44
+ analysis.each do |submission|
45
+ unless submission['ratings']
46
+ ratings_url = "#{SUBMISSIONS_URL}/#{submission['id']}/ratings"
47
+ submission['ratings'] = papercall(ratings_url)
48
+ end
49
+ end
50
+ end
51
+
52
+ def fetch_feedback
53
+ puts "Fetching feedback for all submissions from Papercall API..."
54
+ analysis.each do |submission|
55
+ unless submission['feedback']
56
+ feedback_url = "#{SUBMISSIONS_URL}/#{submission['id']}/feedback"
57
+ submission['feedback'] = papercall(feedback_url)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module Papercall
2
+ VERSION = '0.10.0'.freeze
3
+ end
data/lib/papercall.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'papercall/version'
2
+ require 'papercall/core'
3
+ require 'papercall/fetcher'
4
+ require 'papercall/file_fetcher'
5
+ require 'papercall/rest_fetcher'
6
+ require 'papercall/analysis'
data/papercall.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'papercall/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "papercall"
8
+ spec.version = Papercall::VERSION
9
+ spec.authors = ["Jørn Ølmheim"]
10
+ spec.email = ["jorn@olmheim.com"]
11
+
12
+ spec.summary = "Small client library for the PaperCall API"
13
+ spec.description = "Small client library for the PaperCall API. With some analytics for the submissions."
14
+ spec.homepage = "https://github.com/joelmheim/PaperCall.rb"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "guard", "~> 2.13"
28
+ spec.add_development_dependency "guard-rspec", "~> 4.7", ">= 4.7.3"
29
+ spec.add_development_dependency "pry", "~> 0.11.2"
30
+ spec.add_development_dependency "rubocop", "~> 0.51.0"
31
+
32
+ spec.add_dependency "json", "~> 2.1"
33
+ spec.add_dependency "rest-client", "~> 2.0", ">= 2.0.2"
34
+ end
data/papercallapi.rb ADDED
@@ -0,0 +1,318 @@
1
+ module PaperCallAPI
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ attr_accessor :analysis
7
+
8
+ TESTFILE = './test.json'
9
+
10
+ def status
11
+ puts "Number of submissions: #{@analysis['summary']['numSubmissions']}"
12
+ puts "Number of active reviewers: #{@analysis['summary']['numActiveReviewers']}"
13
+ puts "Number of submissions missing feedback: #{@analysis['summary']['numWithoutFeedback']}"
14
+ puts "Number of submissions with enough reviews: #{@analysis['summary']['numCompleted']}"
15
+ puts "Number of highly rated talks (at least three reviews): #{@analysis['summary']['numHighlyRated']}"
16
+ puts "Number of low rated talks (at least three reviews): #{@analysis['summary']['numLowRated']}"
17
+ puts "Number of maybes (at least three reviews): #{@analysis['summary']['numMaybe']}"
18
+ puts "Number of submissions with less than three reviews: #{@analysis['summary']['numLessThanThreeReviews']}"
19
+ puts "Number of submissions missing reviews: #{@analysis['summary']['numWithoutReviews']}"
20
+ puts "Number of submissions with four or more reviews: #{@analysis['summary']['numWithFourOrMoreReviews']}"
21
+ puts "Number of accepted submissions: #{@analysis['summary']['numAccepted']}"
22
+ puts "Number of waitlisted submissions: #{@analysis['summary']['numWaitlisted']}"
23
+ puts "Number of rejected submissions: #{@analysis['summary']['numRejected']}"
24
+ puts "Number of confirmed talks: #{@analysis['summary']['numConfirmed']}"
25
+ end
26
+
27
+ def saveToFile
28
+ timestamp = DateTime.now.strftime '%Y%m%d%H%M'
29
+ filename = "pc_#{timestamp}.json"
30
+ tf = File.open(filename, 'w') {|f| f.write(@analysis.to_json)}
31
+ puts "Daily stats saved successfully (#{filename})!" if tf
32
+ end
33
+
34
+ def activeReviewers
35
+ reviewers = @analysis['reviewers'].keys
36
+ reviewers.each do |reviewer|
37
+ puts "#{reviewer} (#{@analysis['reviewers'][reviewer].size})"
38
+ end
39
+ end
40
+
41
+ def updateTestFile
42
+ unless @analysis['submissions'].empty?
43
+ tf = File.open(PaperCallAPI::TESTFILE, 'w') {|f| f.write(@analysis.to_json)}
44
+ puts "Testfile successfully updated (#{PaperCallAPI::TESTFILE})!" if tf
45
+ end
46
+ end
47
+
48
+ def clearlyAcceptedToCSV
49
+ filename = "highlyRated.csv"
50
+ hashes = @analysis['highlyRated']
51
+ writeToFile(filename, to_csv(submissionsFromHash(hashes)), "#{hashes.size} talks exported to file #{filename}")
52
+ end
53
+
54
+ def clearlyRejectedToCSV
55
+ filename = "lowRated.csv"
56
+ hashes = @analysis['lowRated']
57
+ writeToFile(filename, to_csv(submissionsFromHash(hashes)), "#{hashes.size} talks exported to file #{filename}")
58
+ end
59
+
60
+ def maybeToCSV
61
+ filename = "maybe.csv"
62
+ hashes = @analysis['maybe']
63
+ writeToFile(filename, to_csv(submissionsFromHash(hashes)), "#{hashes.size} talks exported to file #{filename}")
64
+ end
65
+
66
+ def techtalkstextfile
67
+ filename = "techtalks.txt"
68
+ techtalks = []
69
+ @analysis['submissions'].each do |submission|
70
+ techtalks.push(submission) if (submission['talk']['talk_format'] == "Tech Talks and Tech Tutorials (30 or 90 minutes - please specify the exact time in the Notes section)")
71
+ end
72
+ writeToFile(filename, techtalkdetails(techtalks), "#{techtalks.size} tech talks written to file #{filename}")
73
+ end
74
+
75
+ def missingFeedback
76
+ filename = "missing_feedback.csv"
77
+ missingFeedback = []
78
+ @analysis['submissions'].each do |submission|
79
+ missingFeedback.push(submission) if (submission['feedback'].size <= 2)
80
+ end
81
+ writeToFile(filename, feedbackdetails(missingFeedback), "#{missingFeedback.size} talks with little or no feedback written to file #{filename}")
82
+ end
83
+
84
+ def listConfirmed
85
+ confirmed = []
86
+ @analysis['confirmed'].each do |submission|
87
+ confirmed.push(submission[:id])
88
+ end
89
+ puts confirmed.sort
90
+ end
91
+
92
+ private
93
+
94
+ def writeToFile(filename, content, message)
95
+ ff = File.open(filename, 'w') {|f| f.write(content)}
96
+ puts message if (ff && message)
97
+ end
98
+
99
+ def feedbackdetails(missingfb)
100
+ output = "Id;Title;Rating;NumReviews;NumFeedback\n"
101
+ missingfb.each do |talk|
102
+ output += "#{id(talk)};#{title(talk)};#{rating(talk)};#{numReviews(talk)};#{numFeedback(talk)}\n"
103
+ end
104
+ output
105
+ end
106
+
107
+ def techtalkdetails(techtalks)
108
+ output = ""
109
+ techtalks.each do |submission|
110
+ output += "#{id(submission)} - #{title(submission)} ()\n"
111
+ end
112
+ output
113
+ end
114
+
115
+ def fetch_submissions
116
+ @analysis = {}
117
+ @analysis['submissions'] = []
118
+ if (@from_file)
119
+ testf = File.new(PaperCallAPI::TESTFILE, 'r')
120
+ Dir.glob("pc_*.json") do |filename|
121
+ file = File.new(filename, 'r')
122
+ testf = file if file.mtime > testf.mtime
123
+ end
124
+ puts "Reading from file (#{testf.path})..."
125
+ if testf
126
+ @analysis = JSON.parse testf.read
127
+ end
128
+ testf.close
129
+ else
130
+ puts "Fetching updated results from PaperCall API..."
131
+ submissions_url = 'https://www.papercall.io/api/v1/submissions'
132
+ auth_hash = {:Authorization => '7460df7e664ca9511fc3c698381e0115'}
133
+ #response = RestClient.get(submissions_url + "?per_page=150", auth_hash)
134
+ submitted = RestClient::Request.execute({:method => :get, :url => submissions_url + "?state=submitted&per_page=150", :headers => auth_hash, :timeout => 120})
135
+ rejected = RestClient::Request.execute({:method => :get, :url => submissions_url + "?state=rejected&per_page=150", :headers => auth_hash, :timeout => 120})
136
+ accepted = RestClient::Request.execute({:method => :get, :url => submissions_url + "?state=accepted&per_page=150", :headers => auth_hash, :timeout => 120})
137
+ waitlist = RestClient::Request.execute({:method => :get, :url => submissions_url + "?state=waitlist&per_page=150", :headers => auth_hash, :timeout => 120})
138
+ submissions = JSON.parse submitted
139
+ submissions += JSON.parse rejected
140
+ submissions += JSON.parse accepted
141
+ submissions += JSON.parse waitlist
142
+ @analysis['submissions'] = submissions
143
+
144
+ @analysis['submissions'].each do |submission|
145
+ base_url = "#{submissions_url}/#{submission["id"]}"
146
+ ratings_url = "#{base_url}/ratings"
147
+ ratings_json = RestClient::Request.execute({:method => :get, :url => ratings_url, :headers => auth_hash, :timeout => 120})
148
+ submission["ratings"] = JSON.parse ratings_json
149
+ feedback_url = "#{base_url}/feedback"
150
+ feedback_json = RestClient::Request.execute(:method => :get, :url => feedback_url, :headers => auth_hash, :timeout => 120)
151
+ submission["feedback"] = JSON.parse(feedback_json)
152
+ end
153
+ end
154
+ end
155
+
156
+ def analyze
157
+ @analysis['reviewers'] = {}
158
+ @analysis['talksWithoutReviews'] = []
159
+ @analysis['talksWithLessThanThreeReviews'] = []
160
+ @analysis['talksWithFourOrMoreReviews'] = []
161
+ @analysis['talksWithoutFeedback'] = []
162
+ @analysis['highlyRated'] = []
163
+ @analysis['lowRated'] = []
164
+ @analysis['maybe'] = []
165
+ @analysis['accepted'] = []
166
+ @analysis['waitlist'] = []
167
+ @analysis['rejected'] = []
168
+ @analysis['confirmed'] = []
169
+ @analysis['submissions'].each do |submission|
170
+ submission["ratings"].each do |rating|
171
+ unless(@analysis['reviewers'].include?(rating["user"]["name"]))
172
+ @analysis['reviewers'][rating["user"]["name"]] = [{:id => rating["submission_id"]}]
173
+ else
174
+ @analysis['reviewers'][rating['user']['name']].push({:id => rating["submission_id"]})
175
+ end
176
+ end
177
+ @analysis['talksWithoutReviews'].push({:id => submission["id"]}) if submission["ratings"].empty?
178
+ @analysis['talksWithFourOrMoreReviews'].push({:id => submission["id"]}) if submission["ratings"].size >= 4
179
+ @analysis['talksWithLessThanThreeReviews'].push({:id => submission["id"]}) if submission["ratings"].size < 3
180
+ @analysis['talksWithoutFeedback'].push({:id => submission["id"]}) if submission["feedback"].empty?
181
+ @analysis['highlyRated'].push({:id => submission["id"], :submission => submission}) if highlyRated? submission
182
+ @analysis['lowRated'].push({:id => submission["id"], :submission => submission}) if lowRated? submission
183
+ @analysis['maybe'].push({:id => submission["id"], :submission => submission}) if maybe? submission
184
+ @analysis['accepted'].push({:id => submission["id"], :submission => submission}) if accepted? submission
185
+ @analysis['waitlist'].push({:id => submission["id"], :submission => submission}) if waitlisted? submission
186
+ @analysis['rejected'].push({:id => submission["id"], :submission => submission}) if rejected? submission
187
+ @analysis['confirmed'].push({:id => submission["id"], :submission => submission}) if confirmed? submission
188
+ end
189
+ @analysis['summary'] = summary
190
+ end
191
+
192
+ def highlyRated?(submission)
193
+ submission["rating"] >= 75 && review_complete?(submission)
194
+ end
195
+
196
+ def lowRated?(submission)
197
+ submission["rating"] <= 25 && review_complete?(submission)
198
+ end
199
+
200
+ def maybe?(submission)
201
+ !accepted?(submission) && !rejected?(submission) && review_complete?(submission)
202
+ end
203
+
204
+ def review_complete?(submission)
205
+ submission["ratings"].size >= 3
206
+ end
207
+
208
+ def accepted?(submission)
209
+ submission["state"] == "accepted"
210
+ end
211
+
212
+ def rejected?(submission)
213
+ submission["state"] == "rejected"
214
+ end
215
+
216
+ def waitlisted?(submission)
217
+ submission["state"] == "waitlist"
218
+ end
219
+
220
+ def confirmed?(submission)
221
+ accepted?(submission) && submission["confirmed"] == true
222
+ end
223
+
224
+ def summary
225
+ summary = {}
226
+ summary['numSubmissions'] = @analysis['submissions'].size
227
+ summary['numActiveReviewers'] = @analysis['reviewers'].size
228
+ summary['numWithoutFeedback'] = @analysis['talksWithoutFeedback'].size
229
+ summary['numCompleted'] = @analysis['submissions'].size - @analysis['talksWithLessThanThreeReviews'].size
230
+ summary['numHighlyRated'] = @analysis['highlyRated'].size
231
+ summary['numLowRated'] = @analysis['lowRated'].size
232
+ summary['numMaybe'] = @analysis['maybe'].size
233
+ summary['numLessThanThreeReviews'] = @analysis['talksWithLessThanThreeReviews'].size
234
+ summary['numWithFourOrMoreReviews'] = @analysis['talksWithFourOrMoreReviews'].size
235
+ summary['numWithoutReviews'] = @analysis['talksWithoutReviews'].size
236
+ summary['numAccepted'] = @analysis['accepted'].size
237
+ summary['numWaitlisted'] = @analysis['waitlist'].size
238
+ summary['numRejected'] = @analysis['rejected'].size
239
+ summary['numConfirmed'] = @analysis['confirmed'].size
240
+ summary
241
+ end
242
+
243
+ def csv_header
244
+ "Id;Title;Session Type;Author;Rating;Trust;Review(#);Reviewers;Abstract\n"
245
+ end
246
+
247
+ def to_csv(submissions)
248
+ csv_string = csv_header
249
+ submissions.each do |submission|
250
+ csv_string += to_csv_row(submission)
251
+ csv_string += "\n"
252
+ end
253
+ csv_string
254
+ end
255
+
256
+ def to_csv_row(submission)
257
+ "#{id(submission)};#{title(submission)};#{talkFormat(submission)};#{author(submission)};#{rating(submission)};#{trust(submission)};#{numReviews(submission)};#{reviewers(submission)};#{abstract(submission)}"
258
+ end
259
+
260
+ def id(submission)
261
+ submission['id']
262
+ end
263
+
264
+ def title(submission)
265
+ submission['talk']['title']
266
+ end
267
+
268
+ def talkFormat(submission)
269
+ submission['talk']['talk_format']
270
+ end
271
+
272
+ def author(submission)
273
+ submission['profile']['name']
274
+ end
275
+
276
+ def rating(submission)
277
+ submission['rating']
278
+ end
279
+
280
+ def trust(submission)
281
+ submission['trust']
282
+ end
283
+
284
+ def numReviews(submission)
285
+ submission['ratings'].size
286
+ end
287
+
288
+ def numFeedback(submission)
289
+ submission['feedback'].size
290
+ end
291
+
292
+ def reviewers(submission)
293
+ reviewers = ""
294
+ submission['ratings'].each do |rating|
295
+ reviewers += rating['user']['name']
296
+ reviewers += ", "
297
+ end
298
+ reviewers[0..-3]
299
+ end
300
+
301
+ def abstract(submission)
302
+ submission['talk']['abstract'].gsub("\n", " ")
303
+ end
304
+
305
+ def submissionsFromHash(submissionshashes)
306
+ submissionshashes.map { |s| s[:submission] }
307
+ end
308
+ end
309
+
310
+ class PaperCallClient
311
+ include PaperCallAPI
312
+ attr :from_file
313
+ def initialize(from_file=false)
314
+ @from_file = from_file
315
+ fetch_submissions
316
+ analyze
317
+ end
318
+ end
data/plugins ADDED
@@ -0,0 +1,13 @@
1
+ abolish
2
+ commentary
3
+ dispatch
4
+ endwise
5
+ eunuch
6
+ fugitive
7
+ sensible
8
+ sleuth
9
+ surround
10
+ unimpaired
11
+
12
+ ctags...
13
+
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: papercall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
5
+ platform: ruby
6
+ authors:
7
+ - Jørn Ølmheim
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.7'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 4.7.3
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '4.7'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 4.7.3
89
+ - !ruby/object:Gem::Dependency
90
+ name: pry
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.11.2
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.11.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 0.51.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 0.51.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: json
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '2.1'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '2.1'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rest-client
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '2.0'
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 2.0.2
141
+ type: :runtime
142
+ prerelease: false
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '2.0'
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 2.0.2
151
+ description: Small client library for the PaperCall API. With some analytics for the
152
+ submissions.
153
+ email:
154
+ - jorn@olmheim.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - ".gitignore"
160
+ - ".rspec"
161
+ - ".travis.yml"
162
+ - CODE_OF_CONDUCT.md
163
+ - Gemfile
164
+ - Guardfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - bin/console
169
+ - bin/setup
170
+ - lib/papercall.rb
171
+ - lib/papercall/analysis.rb
172
+ - lib/papercall/core.rb
173
+ - lib/papercall/fetcher.rb
174
+ - lib/papercall/file_fetcher.rb
175
+ - lib/papercall/rest_fetcher.rb
176
+ - lib/papercall/version.rb
177
+ - papercall.gemspec
178
+ - papercallapi.rb
179
+ - plugins
180
+ homepage: https://github.com/joelmheim/PaperCall.rb
181
+ licenses:
182
+ - MIT
183
+ metadata: {}
184
+ post_install_message:
185
+ rdoc_options: []
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ requirements: []
199
+ rubyforge_project:
200
+ rubygems_version: 2.6.12
201
+ signing_key:
202
+ specification_version: 4
203
+ summary: Small client library for the PaperCall API
204
+ test_files: []