Class: Gitdocs::Initializer
- Inherits:
-
Object
- Object
- Gitdocs::Initializer
- Defined in:
- lib/gitdocs/initializer.rb
Class Method Summary collapse
- .database ⇒ String
- .database=(value) ⇒ nil
- .foreground ⇒ Boolean
- .foreground=(value) ⇒ Object
- .initialize_all ⇒ nil
- .initialize_database ⇒ nil
- .initialize_old_paths ⇒ nil
- .root_dirname ⇒ String
- .root_dirname=(value) ⇒ nil
- .verbose ⇒ Boolean
- .verbose=(value) ⇒ Object
Class Method Details
.database ⇒ String
52 53 54 |
# File 'lib/gitdocs/initializer.rb', line 52 def self.database @database ||= File.join(root_dirname, 'config.db') end |
.database=(value) ⇒ nil
58 59 60 61 |
# File 'lib/gitdocs/initializer.rb', line 58 def self.database=(value) return if value.nil? @database = value end |
.foreground ⇒ Boolean
64 65 66 |
# File 'lib/gitdocs/initializer.rb', line 64 def self.foreground @foreground ||= false end |
.foreground=(value) ⇒ Object
68 69 70 71 |
# File 'lib/gitdocs/initializer.rb', line 68 def self.foreground=(value) return if value.nil? @foreground = value end |
.initialize_all ⇒ nil
8 9 10 11 |
# File 'lib/gitdocs/initializer.rb', line 8 def self.initialize_all initialize_database initialize_old_paths end |
.initialize_database ⇒ nil
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitdocs/initializer.rb', line 14 def self.initialize_database FileUtils.mkdir_p(root_dirname) ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: database ) ActiveRecord::Migrator.migrate( File.('../migration', __FILE__) ) end |
.initialize_old_paths ⇒ nil
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitdocs/initializer.rb', line 26 def self.initialize_old_paths old_path_dirname = File.('paths', root_dirname) return unless File.exist?(old_path_dirname) File.read(old_path_dirname).split("\n").each do |path| begin Share.create_by_path!(path) rescue # rubocop:disable HandleExceptions # Nothing to do, because we want the process to keep going. end end end |
.root_dirname ⇒ String
40 41 42 |
# File 'lib/gitdocs/initializer.rb', line 40 def self.root_dirname @root_dirname ||= File.('.gitdocs', ENV['HOME']) end |
.root_dirname=(value) ⇒ nil
46 47 48 49 |
# File 'lib/gitdocs/initializer.rb', line 46 def self.root_dirname=(value) return if value.nil? @root_dirname = value end |
.verbose ⇒ Boolean
74 75 76 |
# File 'lib/gitdocs/initializer.rb', line 74 def self.verbose @verbose ||= false end |
.verbose=(value) ⇒ Object
79 80 81 |
# File 'lib/gitdocs/initializer.rb', line 79 def self.verbose=(value) @verbose = !!value # rubocop:disable DoubleNegation end |