theoj 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09237502c90ed400980274941c03683a2f5b33eaa911debc8b9d50d0747e5a91'
4
- data.tar.gz: eb959c2aa0821a45246d3a7551f1fc265c0dc571c9ce791840e7465fc5bb6045
3
+ metadata.gz: e3393fdafdacce02e4613bb5b20b7ebc53f860a560f826ce4fcc695b808658d7
4
+ data.tar.gz: 2d3472010e8ad6ecd0c66b9fd68e4c47a176cbc12bd06efa0b5c041a2b21fdbe
5
5
  SHA512:
6
- metadata.gz: 877313b88d2739e7076ec44b18e7efe50026f099f0e2a55e95919aa2af8ea8d72edbb35ee4882154c650b79134bbb72cdf2780f26e8daa64d06a7505ecd91e26
7
- data.tar.gz: 54b6835727136c213a5339d303000bc6f2ee47e8ae24118a3577c2e70657a36613417397074bf7228ffd66a6b3949df0fd7b91649e06be4ba9bdb3b7664ec5b2
6
+ metadata.gz: f52232e14aa6bfd81afd4bc5a79e3ae02e1f439277597acbfee6b31048b58c8b0003816147ea296446cccebcecfd6c7d28009675d9981a50fa0675b4e1da4ec8
7
+ data.tar.gz: 6b8d060629fa1652ecd47bda9fc9869b21f4ffa3af8676569a8c7d7e481c572fcf369adcda6213eadc7d9a4594378d9d729af45f38715b96418a6cd9106eb5d5
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 (2021-09-22)
4
+
5
+ - Gem created
6
+
7
+ ## 0.0.2 (2021-09-22)
8
+
9
+ - Available objects: Theoj::Journal, Theoj::ReviewIssue and Theoj::Paper
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
  [![CI](https://github.com/xuanxu/theoj/actions/workflows/ci.yml/badge.svg)](https://github.com/xuanxu/theoj/actions/workflows/ci.yml)
5
+ [![Gem Version](https://badge.fury.io/rb/theoj.svg)](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(repository, branch, path = nil)
12
- @repository = repository
14
+ def initialize(repository_url, branch, path = nil)
15
+ @repository = repository_url
13
16
  @branch = branch
14
17
  find_paper path
15
- end
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(repository, branch = "main")
47
- Paper.new(repository, branch, nil)
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: #{paper_branch.to_s}"
65
+ msg_no_branch = "Couldn't check the bibtex because branch name is incorrect: #{branch.to_s}"
54
66
 
55
- error = clone_repo(target_repository, local_path) ? nil : msg_no_repo
56
- (error = change_branch(paper_branch, local_path) ? nil : msg_no_branch) unless error
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 local_path
63
- @local_path ||= "tmp/#{SecureRandom.hex}"
64
- end
65
-
66
- def cleanup
67
- FileUtils.rm_rf(local_path) if Dir.exist?(local_path)
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)
@@ -20,6 +20,7 @@ module Theoj
20
20
  end
21
21
 
22
22
  def paper
23
+ @paper ||= Theoj::Paper.new(target_repository, paper_branch)
23
24
  end
24
25
 
25
26
  def target_repository
data/lib/theoj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Theoj
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/theoj.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "theoj/version"
2
2
  require_relative "theoj/git"
3
3
  require_relative "theoj/github"
4
+ require_relative "theoj/journal"
4
5
  require_relative "theoj/review_issue"
5
6
  require_relative "theoj/paper"
6
7
  require_relative "theoj/author"
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.1
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-22 00:00:00.000000000 Z
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