Class: Theoj::Paper

Inherits:
Object
  • Object
show all
Includes:
Git
Defined in:
lib/theoj/paper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Git

#change_branch, #clone_repo

Constructor Details

#initialize(repository_url, branch, path = nil) ⇒ Paper

Returns a new instance of Paper.



17
18
19
20
21
22
# File 'lib/theoj/paper.rb', line 17

def initialize(repository_url, branch, path = nil)
  @repository = repository_url
  @branch = branch
  find_paper path
  
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



14
15
16
# File 'lib/theoj/paper.rb', line 14

def branch
  @branch
end

#paper_metadataObject

Returns the value of attribute paper_metadata.



15
16
17
# File 'lib/theoj/paper.rb', line 15

def 
  
end

#paper_pathObject

Returns the value of attribute paper_path.



13
14
15
# File 'lib/theoj/paper.rb', line 13

def paper_path
  @paper_path
end

#repositoryObject

Returns the value of attribute repository.



12
13
14
# File 'lib/theoj/paper.rb', line 12

def repository
  @repository
end

#review_issueObject

Returns the value of attribute review_issue.



11
12
13
# File 'lib/theoj/paper.rb', line 11

def review_issue
  @review_issue
end

Class Method Details

.find_paper_path(search_path) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/theoj/paper.rb', line 67

def self.find_paper_path(search_path)
  paper_path = nil

  if Dir.exist? search_path
    Find.find(search_path).each do |path|
      if path =~ /\/paper\.tex$|\/paper\.md$/
        paper_path = path
        break
      end
    end
  end

  paper_path
end

.from_repo(repository_url, branch = "") ⇒ Object



82
83
84
# File 'lib/theoj/paper.rb', line 82

def self.from_repo(repository_url, branch = "")
  Paper.new(repository_url, branch, nil)
end

Instance Method Details

#authorsObject



24
25
26
# File 'lib/theoj/paper.rb', line 24

def authors
  @authors ||= parse_authors
end

#bibliography_pathObject



55
56
57
# File 'lib/theoj/paper.rb', line 55

def bibliography_path
  ["bibliography"]
end

#citation_authorObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/theoj/paper.rb', line 28

def citation_author
  surname = authors.first.last_name
  initials = authors.first.initials

  if authors.size > 1
    return "#{surname} et al."
  else
    return "#{surname}, #{initials}"
  end
end

#cleanupObject



63
64
65
# File 'lib/theoj/paper.rb', line 63

def cleanup
  FileUtils.rm_rf(local_path) if Dir.exist?(local_path)
end

#dateObject



47
48
49
# File 'lib/theoj/paper.rb', line 47

def date
  ["date"]
end

#languagesObject



51
52
53
# File 'lib/theoj/paper.rb', line 51

def languages
  @languages ||= detect_languages
end

#local_pathObject



59
60
61
# File 'lib/theoj/paper.rb', line 59

def local_path
  @local_path ||= "tmp/#{SecureRandom.hex}"
end

#tagsObject



43
44
45
# File 'lib/theoj/paper.rb', line 43

def tags
  ["tags"] || ["keywords"]
end

#titleObject



39
40
41
# File 'lib/theoj/paper.rb', line 39

def title
  ["title"]
end