Skip to content

Commit

Permalink
update PaperWithCodeApi
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry940100 committed Oct 26, 2022
1 parent d9dccec commit ab65bd1
Show file tree
Hide file tree
Showing 37 changed files with 149 additions and 58 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ GEM

PLATFORMS
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
flog
Expand Down
52 changes: 14 additions & 38 deletions coverage/.resultset.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,27 @@
1,
1,
null,
null,
null,
null,
null,
null,
null,
1,
null,
4,
4,
3,
null,
null,
1,
null,
null,
null,
1,
1,
3,
null,
null,
1,
null,
null,
null,
1,
1,
2,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
},
Expand Down Expand Up @@ -213,20 +193,20 @@
1,
null,
1,
1,
6,
null,
null,
1,
4,
null,
null,
1,
1,
null,
null,
1,
1,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
1,
Expand All @@ -240,10 +220,6 @@
]
}
},
<<<<<<< HEAD
"timestamp": 1666110905
=======
"timestamp": 1666105299
>>>>>>> 0a184e4854f6798134dc9bcab00b9bba97077834
"timestamp": 1666769932
}
}
}
14 changes: 10 additions & 4 deletions lib/paperswithcode_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@
# PaperWithCode API module
module PapMon
# PaperWithCode API
class PaperswithcodeApi
class PapersWithCodeApi
API_PROJECT_ROOT = 'https://paperswithcode.com/api/v1/'

def paper(papername)
paper_response = Request.new(API_PROJECT_ROOT).paper(papername).parse
# paper_response = Request.new(API_PROJECT_ROOT).paper(papername).parse
paper_url = API_PROJECT_ROOT + ['papers', papername, ''].join('/')
paper_response = Request.new.get(paper_url).parse
Paper.new(paper_response, self)
end

def datasets(paper_id)
dataset_data = Request.new(API_PROJECT_ROOT).datasets(paper_id).parse
# dataset_data = Request.new(API_PROJECT_ROOT).datasets(paper_id).parse
dataset_url = API_PROJECT_ROOT + ['papers', paper_id, 'datasets', ''].join('/')
dataset_data = Request.new.get(dataset_url).parse
dataset_data['results'].map { |dataset| Dataset.new(dataset) }
end

def repositories(paper_id)
repo_data = Request.new(API_PROJECT_ROOT).repositories(paper_id).parse
# repo_data = Request.new(API_PROJECT_ROOT).repositories(paper_id).parse
repo_url = API_PROJECT_ROOT + ['papers', paper_id, 'repositories', ''].join('/')
repo_data = Request.new.get(repo_url).parse
repo_data['results'].map { |repo| Repository.new(repo) }
end
end
Expand Down
24 changes: 12 additions & 12 deletions lib/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
module PapMon
# request class
class Request
def initialize(api_project_root)
@api_project_root = api_project_root
end
# def initialize(api_project_root)
# @api_project_root = api_project_root
# end

def paper(papername)
get(@api_project_root + ['papers', papername, ''].join('/'))
end
# def paper(papername)
# get(@api_project_root + ['papers', papername, ''].join('/'))
# end

def datasets(paper_id)
get(@api_project_root + ['papers', paper_id, 'datasets', ''].join('/'))
end
# def datasets(paper_id)
# get(@api_project_root + ['papers', paper_id, 'datasets', ''].join('/'))
# end

def repositories(paper_id)
get(@api_project_root + ['papers', paper_id, 'repositories', ''].join('/'))
end
# def repositories(paper_id)
# get(@api_project_root + ['papers', paper_id, 'repositories', ''].join('/'))
# end

def get(url)
http_response = HTTP.headers('Accept' => 'application/json').get(url)
Expand Down
7 changes: 7 additions & 0 deletions spec/coverage/.resultset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"RSpec": {
"coverage": {
},
"timestamp": 1666769848
}
}
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions spec/coverage/assets/0.12.3/application.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions spec/coverage/assets/0.12.3/application.js

Large diffs are not rendered by default.

Binary file added spec/coverage/assets/0.12.3/colorbox/border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spec/coverage/assets/0.12.3/colorbox/controls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spec/coverage/assets/0.12.3/colorbox/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spec/coverage/assets/0.12.3/favicon_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spec/coverage/assets/0.12.3/favicon_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spec/coverage/assets/0.12.3/favicon_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spec/coverage/assets/0.12.3/loading.gif
Binary file added spec/coverage/assets/0.12.3/magnify.png
93 changes: 93 additions & 0 deletions spec/coverage/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Code coverage for Spec</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src='./assets/0.12.3/application.js' type='text/javascript'></script>
<link href='./assets/0.12.3/application.css' media='screen, projection, print' rel='stylesheet' type='text/css' />
<link rel="shortcut icon" type="image/png" href="./assets/0.12.3/favicon_green.png" />
<link rel="icon" type="image/png" href="./assets/0.12.3/favicon.png" />
</head>

<body>
<div id="loading">
<img src="./assets/0.12.3/loading.gif" alt="loading"/>
</div>
<div id="wrapper" class="hide">
<div class="timestamp">Generated <abbr class="timeago" title="2022-10-26T15:37:28+08:00">2022-10-26T15:37:28+08:00</abbr></div>
<ul class="group_tabs"></ul>

<div id="content">
<div class="file_list_container" id="AllFiles">
<h2>
<span class="group_name">All Files</span>
(<span class="covered_percent">
<span class="green">
100.0%
</span>

</span>
covered at
<span class="covered_strength">
<span class="red">
0.0
</span>
</span> hits/line
)
</h2>

<a name="AllFiles"></a>

<div>
<b>0</b> files in total.
</div>

<div class="t-line-summary">
<b>0</b> relevant lines,
<span class="green"><b>0</b> lines covered</span> and
<span class="red"><b>0</b> lines missed. </span>
(<span class="green">
100.0%
</span>
)
</div>



<div class="file_list--responsive">
<table class="file_list">
<thead>
<tr>
<th>File</th>
<th class="cell--number">% covered</th>
<th class="cell--number">Lines</th>
<th class="cell--number">Relevant Lines</th>
<th class="cell--number">Lines covered</th>
<th class="cell--number">Lines missed</th>
<th class="cell--number">Avg. Hits / Line</th>

</tr>
</thead>
<tbody>

</tbody>
</table>
</div>
</div>



</div>

<div id="footer">
Generated by <a href="https://github.com/simplecov-ruby/simplecov">simplecov</a> v0.21.2
and simplecov-html v0.12.3<br/>
using RSpec
</div>

<div class="source_files">

</div>
</div>
</body>
</html>
8 changes: 4 additions & 4 deletions spec/paperswithcode_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

describe 'Paper information' do
it 'HAPPY: should provide correct paper information' do
paper = PapMon::PaperswithcodeApi.new.paper(PAPERNAME)
paper = PapMon::PapersWithCodeApi.new.paper(PAPERNAME)
_(paper.id).must_equal CORRECT['id']
_(paper.arxiv_id).must_equal CORRECT['arxiv_id']
_(paper.url_abs).must_equal CORRECT['url_abs']
Expand All @@ -32,14 +32,14 @@

it 'SAD: should raise exception on invalid paper name' do
_(proc {
PapMon::PaperswithcodeApi.new.paper('be-your-own-teacher')
PapMon::PapersWithCodeApi.new.paper('be-your-own-teacher')
}).must_raise PapMon::Response::Errors::NotFound
end
end

describe 'Dataset information' do
before do
@paper = PapMon::PaperswithcodeApi.new.paper(PAPERNAME)
@paper = PapMon::PapersWithCodeApi.new.paper(PAPERNAME)
end

it 'HAPPY: should provide correct dataset information' do
Expand All @@ -53,7 +53,7 @@

describe 'Repository information' do
before do
@paper = PapMon::PaperswithcodeApi.new.paper(PAPERNAME)
@paper = PapMon::PapersWithCodeApi.new.paper(PAPERNAME)
end

it 'HAPPY: should provide correct repository information' do
Expand Down

0 comments on commit ab65bd1

Please sign in to comment.