theoj 0.0.1 → 0.0.2
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -0
- data/lib/theoj/journal.rb +59 -0
- data/lib/theoj/paper.rb +35 -23
- data/lib/theoj/review_issue.rb +1 -0
- data/lib/theoj/version.rb +1 -1
- data/lib/theoj.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3393fdafdacce02e4613bb5b20b7ebc53f860a560f826ce4fcc695b808658d7
|
4
|
+
data.tar.gz: 2d3472010e8ad6ecd0c66b9fd68e4c47a176cbc12bd06efa0b5c041a2b21fdbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f52232e14aa6bfd81afd4bc5a79e3ae02e1f439277597acbfee6b31048b58c8b0003816147ea296446cccebcecfd6c7d28009675d9981a50fa0675b4e1da4ec8
|
7
|
+
data.tar.gz: 6b8d060629fa1652ecd47bda9fc9869b21f4ffa3af8676569a8c7d7e481c572fcf369adcda6213eadc7d9a4594378d9d729af45f38715b96418a6cd9106eb5d5
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -2,3 +2,4 @@
|
|
2
2
|
A library to manage editorial objects used by the open journals review process
|
3
3
|
|
4
4
|
[](https://github.com/xuanxu/theoj/actions/workflows/ci.yml)
|
5
|
+
[](https://badge.fury.io/rb/theoj)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Theoj
|
2
|
+
class Journal
|
3
|
+
attr_accessor :data
|
4
|
+
attr_accessor :doi_prefix
|
5
|
+
attr_accessor :url
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :alias
|
8
|
+
attr_accessor :launch_date
|
9
|
+
|
10
|
+
def initialize(custom_data = {})
|
11
|
+
set_data custom_data
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_year
|
15
|
+
data[:current_year] || Time.new.year
|
16
|
+
end
|
17
|
+
|
18
|
+
def current_volume
|
19
|
+
data[:current_volume] || (Time.new.year - (launch_year - 1))
|
20
|
+
end
|
21
|
+
|
22
|
+
def current_issue
|
23
|
+
data[:current_issue] || (1 + ((Time.new.year * 12 + Time.new.month) - (launch_year * 12 + launch_month)))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def set_data(custom_data)
|
29
|
+
@data = default_data.merge(custom_data)
|
30
|
+
@doi_prefix = data[:doi_prefix]
|
31
|
+
@url = data[:url]
|
32
|
+
@name = data[:name]
|
33
|
+
@alias = data[:alias]
|
34
|
+
@launch_date = data[:launch_date]
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_data
|
38
|
+
{
|
39
|
+
doi_prefix: "10.21105",
|
40
|
+
url: "http://joss.theoj.org",
|
41
|
+
name: "Journal of Open Source Software",
|
42
|
+
alias: "joss",
|
43
|
+
launch_date: "2016-05-05",
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def parsed_launch_date
|
48
|
+
@parsed_launch_date ||= Time.parse(data[:launch_date])
|
49
|
+
end
|
50
|
+
|
51
|
+
def launch_year
|
52
|
+
parsed_launch_date.year
|
53
|
+
end
|
54
|
+
|
55
|
+
def launch_month
|
56
|
+
parsed_launch_date.month
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/theoj/paper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'find'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module Theoj
|
4
5
|
class Paper
|
@@ -7,21 +8,14 @@ module Theoj
|
|
7
8
|
attr_accessor :review_issue
|
8
9
|
attr_accessor :repository
|
9
10
|
attr_accessor :paper_path
|
11
|
+
attr_accessor :branch
|
12
|
+
attr_accessor :paper_metadata
|
10
13
|
|
11
|
-
def initialize(
|
12
|
-
@repository =
|
14
|
+
def initialize(repository_url, branch, path = nil)
|
15
|
+
@repository = repository_url
|
13
16
|
@branch = branch
|
14
17
|
find_paper path
|
15
|
-
|
16
|
-
|
17
|
-
def find_paper(path)
|
18
|
-
if path.to_s.strip.empty?
|
19
|
-
setup_local_repo
|
20
|
-
@paper_path = Theoj::Paper.find_paper_path(local_path)
|
21
|
-
cleanup
|
22
|
-
else
|
23
|
-
@paper_path = path
|
24
|
-
end
|
18
|
+
load_metadata
|
25
19
|
end
|
26
20
|
|
27
21
|
def authors
|
@@ -43,28 +37,46 @@ module Theoj
|
|
43
37
|
paper_path
|
44
38
|
end
|
45
39
|
|
46
|
-
def self.from_repo(
|
47
|
-
Paper.new(
|
40
|
+
def self.from_repo(repository_url, branch = "")
|
41
|
+
Paper.new(repository_url, branch, nil)
|
42
|
+
end
|
43
|
+
|
44
|
+
def cleanup
|
45
|
+
FileUtils.rm_rf(local_path) if Dir.exist?(local_path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def local_path
|
49
|
+
@local_path ||= "tmp/#{SecureRandom.hex}"
|
48
50
|
end
|
49
51
|
|
50
52
|
private
|
53
|
+
|
54
|
+
def find_paper(path)
|
55
|
+
if path.to_s.strip.empty?
|
56
|
+
setup_local_repo
|
57
|
+
@paper_path = Theoj::Paper.find_paper_path(local_path)
|
58
|
+
else
|
59
|
+
@paper_path = path
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
51
63
|
def setup_local_repo
|
52
64
|
msg_no_repo = "Downloading of the repository failed. Please make sure the URL is correct."
|
53
|
-
msg_no_branch = "Couldn't check the bibtex because branch name is incorrect: #{
|
65
|
+
msg_no_branch = "Couldn't check the bibtex because branch name is incorrect: #{branch.to_s}"
|
54
66
|
|
55
|
-
error = clone_repo(
|
56
|
-
(error = change_branch(
|
67
|
+
error = clone_repo(repository, local_path) ? nil : msg_no_repo
|
68
|
+
(error = change_branch(branch, local_path) ? nil : msg_no_branch) unless error
|
57
69
|
|
58
70
|
failure(error) if error
|
59
71
|
error.nil?
|
60
72
|
end
|
61
73
|
|
62
|
-
def
|
63
|
-
@
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
74
|
+
def load_metadata
|
75
|
+
@paper_metadata ||= if paper_path.include?('.tex')
|
76
|
+
YAML.load_file(paper_path.gsub('.tex', '.yml'))
|
77
|
+
else
|
78
|
+
YAML.load_file(paper_path)
|
79
|
+
end
|
68
80
|
end
|
69
81
|
|
70
82
|
def failure(msg)
|
data/lib/theoj/review_issue.rb
CHANGED
data/lib/theoj/version.rb
CHANGED
data/lib/theoj.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theoj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanjo Bazán
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -59,12 +59,14 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- CHANGELOG.md
|
62
63
|
- LICENSE
|
63
64
|
- README.md
|
64
65
|
- lib/theoj.rb
|
65
66
|
- lib/theoj/author.rb
|
66
67
|
- lib/theoj/git.rb
|
67
68
|
- lib/theoj/github.rb
|
69
|
+
- lib/theoj/journal.rb
|
68
70
|
- lib/theoj/paper.rb
|
69
71
|
- lib/theoj/review_issue.rb
|
70
72
|
- lib/theoj/version.rb
|