Class: Eh::Settings
- Inherits:
-
Object
show all
- Defined in:
- lib/eh/settings.rb
Defined Under Namespace
Classes: Proxy, Repository
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(file) ⇒ Settings
Returns a new instance of Settings.
54
55
56
57
58
|
# File 'lib/eh/settings.rb', line 54
def initialize(file)
@file = file
@data = JSON.parse(File.read(file))
@data['proxies'] ||= []
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3
4
5
|
# File 'lib/eh/settings.rb', line 3
def data
@data
end
|
#file ⇒ Object
Returns the value of attribute file.
3
4
5
|
# File 'lib/eh/settings.rb', line 3
def file
@file
end
|
Class Method Details
.current ⇒ Object
74
75
76
|
# File 'lib/eh/settings.rb', line 74
def self.current
Thread.current[:eh_settings]
end
|
.current=(value) ⇒ Object
70
71
72
|
# File 'lib/eh/settings.rb', line 70
def self.current=(value)
Thread.current[:eh_settings] = value
end
|
.load(file) ⇒ Object
60
61
62
|
# File 'lib/eh/settings.rb', line 60
def self.load(file)
Eh::Settings.new(file)
end
|
Instance Method Details
#console_source_dir ⇒ Object
129
130
131
|
# File 'lib/eh/settings.rb', line 129
def console_source_dir
File.join(repository.dir, 'src', 'rails', 'console')
end
|
#db_backups_dir ⇒ Object
166
167
168
|
# File 'lib/eh/settings.rb', line 166
def db_backups_dir
File.expand_path('~/backups')
end
|
#default_stage ⇒ Object
50
51
52
|
# File 'lib/eh/settings.rb', line 50
def default_stage
@data['default_stage'] || 'development'
end
|
#deployment_dir ⇒ Object
133
134
135
|
# File 'lib/eh/settings.rb', line 133
def deployment_dir
File.join(repository.dir, 'src', 'deployment')
end
|
#deployment_management_files ⇒ Object
158
159
160
|
# File 'lib/eh/settings.rb', line 158
def deployment_management_files
[File.join(deployment_dir, 'management', 'launcher.rb')]
end
|
#go_processors_src_dir ⇒ Object
120
121
122
|
# File 'lib/eh/settings.rb', line 120
def go_processors_src_dir
File.join(repository.dir, 'src', 'go', 'src', 'github.com', 'cme-eventhub')
end
|
#go_release_dir ⇒ Object
112
113
114
|
# File 'lib/eh/settings.rb', line 112
def go_release_dir
releases_dir('go')
end
|
#package_tmp_dir ⇒ Object
150
151
152
|
# File 'lib/eh/settings.rb', line 150
def package_tmp_dir
'./tmp'
end
|
#processor_template_repository_url ⇒ Object
146
147
148
|
# File 'lib/eh/settings.rb', line 146
def processor_template_repository_url
'https://github.com/thomis/eventhub-processor-template.git'
end
|
#proxies ⇒ Object
92
93
94
95
96
97
|
# File 'lib/eh/settings.rb', line 92
def proxies
proxies = data['proxies'].map do |json|
Eh::Settings::Proxy.new(json)
end if data['proxies']
proxies || []
end
|
#rails_release_dir ⇒ Object
104
105
106
|
# File 'lib/eh/settings.rb', line 104
def rails_release_dir
releases_dir('rails')
end
|
#rails_src_dir ⇒ Object
124
125
126
127
|
# File 'lib/eh/settings.rb', line 124
def rails_src_dir
File.join(repository.dir, 'src', 'rails')
end
|
#releases_dir(*extra_paths) ⇒ Object
99
100
101
|
# File 'lib/eh/settings.rb', line 99
def releases_dir(*)
File.join(repository.dir, 'releases', *)
end
|
#repositories ⇒ Object
84
85
86
87
88
89
|
# File 'lib/eh/settings.rb', line 84
def repositories
repos = data["repositories"].map do |json|
Eh::Settings::Repository.new(json)
end if data["repositories"]
repos || []
end
|
#repository ⇒ Object
78
79
80
81
82
|
# File 'lib/eh/settings.rb', line 78
def repository
repositories.find do |repository|
repository.current?
end if repositories
end
|
#ruby_processors_src_dir ⇒ Object
116
117
118
|
# File 'lib/eh/settings.rb', line 116
def ruby_processors_src_dir
File.join(repository.dir, 'src', 'ruby')
end
|
#ruby_release_dir ⇒ Object
108
109
110
|
# File 'lib/eh/settings.rb', line 108
def ruby_release_dir
releases_dir('ruby')
end
|
#source_config_dir ⇒ Object
142
143
144
|
# File 'lib/eh/settings.rb', line 142
def source_config_dir
File.join(repository.dir, 'config')
end
|
#stages_dir ⇒ Object
162
163
164
|
# File 'lib/eh/settings.rb', line 162
def stages_dir
File.join(repository.dir, 'config', 'stages')
end
|
#template_tmp_dir ⇒ Object
154
155
156
|
# File 'lib/eh/settings.rb', line 154
def template_tmp_dir
'/tmp/eventhub-processor-template/'
end
|
#write ⇒ Object
64
65
66
67
68
|
# File 'lib/eh/settings.rb', line 64
def write
File.open(file,"w") do |f|
f.write(data.to_json)
end
end
|