Module: Mixin::Config

Included in:
Pomodoro
Defined in:
lib/fox/interface/thor/mixin/config.rb

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object

Parameters:

  • args (Array)

    Argument array



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fox/interface/thor/mixin/config.rb', line 21

def initialize *args

  super

  # Store all config paths and relevant filenames (global)
  @paths                     = OpenStruct.new

  # Level 1
  @paths.user_home           = Dir.home
  @paths.fox_home            = options[:'config-path']

  # Level 2
  @paths.assets              = File.join( @paths.fox_home, 'assets' )
  @paths.databases           = File.join( @paths.fox_home, 'databases' )

  # Level 3
  @paths.pomodoro_assets     = File.join( @paths.assets, 'pomodoro' )
  @paths.coffeeshop_assets   = File.join( @paths.assets, 'coffeeshop' )

  # Sanity check, create if doesn't exist in $HOME
  @paths.to_h.each do |tag, uri|
    FileUtils.mkdir_p( uri ) unless( File.exists?( uri ) )
  end


  # Remote Assets URLs
  @urls                               = OpenStruct.new

  @urls.pomodoro                      = OpenStruct.new
  @urls.pomodoro.short                = 'https://github.com/rennhak/fox/raw/master/data/pomodoro/pomodoro_5.mp3'
  @urls.pomodoro.normal               = 'https://github.com/rennhak/fox/raw/master/data/pomodoro/pomodoro_25.mp3'

  @urls.coffeeshop                    = OpenStruct.new
  @urls.coffeeshop.morning_murmur     = 'https://github.com/rennhak/fox/raw/master/data/coffeeshop/morning_murmur.mp3'


  # Assets
  @assets                             = OpenStruct.new

  @assets.pomodoro                    = OpenStruct.new
  @assets.pomodoro.short              = File.join( @paths.pomodoro_assets, File.basename( @urls.pomodoro.short ) )
  @assets.pomodoro.normal             = File.join( @paths.pomodoro_assets, File.basename( @urls.pomodoro.normal ) )

  # Config
  @config                             = OpenStruct.new

  @config.pomodoro                    = OpenStruct.new
  @config.pomodoro.default            = :normal

end