Class: Eh::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/eh/settings.rb

Defined Under Namespace

Classes: Repository

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Settings

Returns a new instance of Settings.



35
36
37
38
# File 'lib/eh/settings.rb', line 35

def initialize(file)
  @file = file
  @data = JSON.parse(File.read(file))
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/eh/settings.rb', line 3

def data
  @data
end

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/eh/settings.rb', line 3

def file
  @file
end

Class Method Details

.currentObject



54
55
56
# File 'lib/eh/settings.rb', line 54

def self.current
  Thread.current[:eh_settings]
end

.current=(value) ⇒ Object



50
51
52
# File 'lib/eh/settings.rb', line 50

def self.current=(value)
  Thread.current[:eh_settings] = value
end

.load(file) ⇒ Object



40
41
42
# File 'lib/eh/settings.rb', line 40

def self.load(file)
  Eh::Settings.new(file)
end

Instance Method Details

#console_source_dirObject



92
93
94
# File 'lib/eh/settings.rb', line 92

def console_source_dir
  File.join(repository.dir, 'src', 'rails', 'console')
end

#default_stageObject



31
32
33
# File 'lib/eh/settings.rb', line 31

def default_stage
  @data['default_stage'] || 'development'
end

#deployment_dirObject



96
97
98
# File 'lib/eh/settings.rb', line 96

def deployment_dir
  File.join(repository.dir, 'src', 'deployment')
end

#deployment_management_filesObject



120
121
122
# File 'lib/eh/settings.rb', line 120

def deployment_management_files
  [ File.join(deployment_dir, 'management', 'launcher.rb') ]
end

#package_tmp_dirObject



112
113
114
# File 'lib/eh/settings.rb', line 112

def package_tmp_dir
  './tmp'
end

#processor_template_repository_urlObject



108
109
110
# File 'lib/eh/settings.rb', line 108

def processor_template_repository_url
  'https://github.com/thomis/eventhub-processor-template.git'
end

#processors_src_dirObject



84
85
86
# File 'lib/eh/settings.rb', line 84

def processors_src_dir
  File.join(repository.dir, 'src', 'ruby')
end

#rails_release_dirObject



76
77
78
# File 'lib/eh/settings.rb', line 76

def rails_release_dir
  releases_dir('rails')
end

#rails_src_dirObject



88
89
90
# File 'lib/eh/settings.rb', line 88

def rails_src_dir
  File.join(repository.dir, 'src', 'rails')
end

#releases_dir(*extra_paths) ⇒ Object



71
72
73
# File 'lib/eh/settings.rb', line 71

def releases_dir(*extra_paths)
  File.join(repository.dir, 'releases', *extra_paths)
end

#repositoriesObject



64
65
66
67
68
69
# File 'lib/eh/settings.rb', line 64

def repositories
  repos = data["repositories"].map do |json|
    Eh::Settings::Repository.new(json)
  end if data["repositories"]
  repos || []
end

#repositoryObject



58
59
60
61
62
# File 'lib/eh/settings.rb', line 58

def repository
  repositories.find do |repository|
    repository.current?
  end if repositories
end

#ruby_release_dirObject



80
81
82
# File 'lib/eh/settings.rb', line 80

def ruby_release_dir
  releases_dir('ruby')
end

#source_config_dirObject



104
105
106
# File 'lib/eh/settings.rb', line 104

def source_config_dir
  File.join(repository.dir, 'config')
end

#stages_dirObject



124
125
126
# File 'lib/eh/settings.rb', line 124

def stages_dir
  File.join(repository.dir, 'config', 'stages')
end

#template_tmp_dirObject



116
117
118
# File 'lib/eh/settings.rb', line 116

def template_tmp_dir
  '/tmp/eventhub-processor-template/'
end

#writeObject



44
45
46
47
48
# File 'lib/eh/settings.rb', line 44

def write
  File.open(file,"w") do |f|
    f.write(data.to_json)
  end
end