Class: Epuber::Config
- Inherits:
-
Object
- Object
- Epuber::Config
- Defined in:
- lib/epuber/config.rb
Constant Summary collapse
- WORKING_PATH =
'.epuber'
Class Attribute Summary collapse
-
.test ⇒ Object
Returns the value of attribute test.
Class Method Summary collapse
-
.instance ⇒ Epuber::Config
Singleton.
- .test? ⇒ Boolean
Instance Method Summary collapse
- #bookspec ⇒ Epuber::Book
- #bookspec=(bookspec) ⇒ Epuber::Book
- #bookspec_lockfile ⇒ Epuber::Lockfile
- #bookspec_lockfile_path ⇒ String
- #bookspec_path ⇒ String
- #build_path(target) ⇒ String
- #find_all_bookspecs ⇒ Array<String>
-
#pretty_path_from_project(of_file) ⇒ String
Relative path to file from root of project.
- #project_path ⇒ String
- #release_build_path(target) ⇒ String
-
#save_lockfile ⇒ Object
Nil.
- #working_path ⇒ String
Class Attribute Details
.test ⇒ Object
Returns the value of attribute test.
116 117 118 |
# File 'lib/epuber/config.rb', line 116 def test @test end |
Class Method Details
.instance ⇒ Epuber::Config
Singleton
111 112 113 |
# File 'lib/epuber/config.rb', line 111 def self.instance @instance ||= new end |
.test? ⇒ Boolean
118 119 120 |
# File 'lib/epuber/config.rb', line 118 def test? test end |
Instance Method Details
#bookspec ⇒ Epuber::Book
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/epuber/config.rb', line 54 def bookspec require_relative 'book' @bookspec ||= ( book = Epuber::Book.from_file(bookspec_path) book.finish_toc book.validate book.freeze book ) end |
#bookspec=(bookspec) ⇒ Epuber::Book
69 70 71 |
# File 'lib/epuber/config.rb', line 69 def bookspec=(bookspec) @bookspec = bookspec end |
#bookspec_lockfile ⇒ Epuber::Lockfile
75 76 77 78 79 80 81 |
# File 'lib/epuber/config.rb', line 75 def bookspec_lockfile @bookspec_lockfile ||= ( lockfile = Lockfile.from_file(bookspec_lockfile_path) lockfile.version = Epuber::VERSION lockfile ) end |
#bookspec_lockfile_path ⇒ String
38 39 40 |
# File 'lib/epuber/config.rb', line 38 def bookspec_lockfile_path "#{bookspec_path}.lock" end |
#bookspec_path ⇒ String
32 33 34 |
# File 'lib/epuber/config.rb', line 32 def bookspec_path @bookspec_path ||= find_all_bookspecs.first end |
#build_path(target) ⇒ String
93 94 95 |
# File 'lib/epuber/config.rb', line 93 def build_path(target) File.join(working_path, 'build', target.name.to_s) end |
#find_all_bookspecs ⇒ Array<String>
44 45 46 47 48 49 50 |
# File 'lib/epuber/config.rb', line 44 def find_all_bookspecs Dir.chdir(project_path) do Dir.glob('*.bookspec').map do |path| File.(path) end end end |
#pretty_path_from_project(of_file) ⇒ String
Returns relative path to file from root of project.
20 21 22 |
# File 'lib/epuber/config.rb', line 20 def pretty_path_from_project(of_file) Pathname.new(of_file.unicode_normalize).relative_path_from(Pathname.new(project_path)) end |
#project_path ⇒ String
12 13 14 |
# File 'lib/epuber/config.rb', line 12 def project_path @project_path ||= Dir.pwd.unicode_normalize end |
#release_build_path(target) ⇒ String
101 102 103 |
# File 'lib/epuber/config.rb', line 101 def release_build_path(target) File.join(working_path, 'release_build', target.name.to_s) end |
#save_lockfile ⇒ Object
Returns nil.
85 86 87 |
# File 'lib/epuber/config.rb', line 85 def save_lockfile bookspec_lockfile.write_to_file end |
#working_path ⇒ String
26 27 28 |
# File 'lib/epuber/config.rb', line 26 def working_path @working_path ||= File.join(project_path, WORKING_PATH) end |