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.
53
54
55
56
57
|
# File 'lib/eh/settings.rb', line 53
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.
2
3
4
|
# File 'lib/eh/settings.rb', line 2
def data
@data
end
|
#file ⇒ Object
Returns the value of attribute file.
2
3
4
|
# File 'lib/eh/settings.rb', line 2
def file
@file
end
|
Class Method Details
.current ⇒ Object
73
74
75
|
# File 'lib/eh/settings.rb', line 73
def self.current
Thread.current[:eh_settings]
end
|
.current=(value) ⇒ Object
69
70
71
|
# File 'lib/eh/settings.rb', line 69
def self.current=(value)
Thread.current[:eh_settings] = value
end
|
.load(file) ⇒ Object
59
60
61
|
# File 'lib/eh/settings.rb', line 59
def self.load(file)
Eh::Settings.new(file)
end
|
Instance Method Details
#console_source_dir ⇒ Object
125
126
127
|
# File 'lib/eh/settings.rb', line 125
def console_source_dir
File.join(repository.dir, "src", "rails", "console")
end
|
#db_backups_dir ⇒ Object
162
163
164
|
# File 'lib/eh/settings.rb', line 162
def db_backups_dir
File.expand_path("~/backups")
end
|
#default_stage ⇒ Object
49
50
51
|
# File 'lib/eh/settings.rb', line 49
def default_stage
@data["default_stage"] || "development"
end
|
#deployment_dir ⇒ Object
129
130
131
|
# File 'lib/eh/settings.rb', line 129
def deployment_dir
File.join(repository.dir, "src", "deployment")
end
|
#deployment_management_files ⇒ Object
154
155
156
|
# File 'lib/eh/settings.rb', line 154
def deployment_management_files
[File.join(deployment_dir, "management", "launcher.rb")]
end
|
#go_processors_src_dir ⇒ Object
121
122
123
|
# File 'lib/eh/settings.rb', line 121
def go_processors_src_dir
File.join(repository.dir, "src", "go", "src", "github.com", "cme-eventhub")
end
|
#go_release_dir ⇒ Object
113
114
115
|
# File 'lib/eh/settings.rb', line 113
def go_release_dir
releases_dir("go")
end
|
#package_tmp_dir ⇒ Object
146
147
148
|
# File 'lib/eh/settings.rb', line 146
def package_tmp_dir
"./tmp"
end
|
#processor_template_repository_url ⇒ Object
142
143
144
|
# File 'lib/eh/settings.rb', line 142
def processor_template_repository_url
"https://github.com/thomis/eventhub-processor-template.git"
end
|
#proxies ⇒ Object
92
93
94
95
96
97
98
99
|
# File 'lib/eh/settings.rb', line 92
def proxies
if data["proxies"]
proxies = data["proxies"].map do |json|
Eh::Settings::Proxy.new(json)
end
end
proxies || []
end
|
#rails_release_dir ⇒ Object
105
106
107
|
# File 'lib/eh/settings.rb', line 105
def rails_release_dir
releases_dir("rails")
end
|
#rails_src_dir ⇒ Object
133
134
135
136
|
# File 'lib/eh/settings.rb', line 133
def rails_src_dir
File.join(repository.dir, "src", "rails", "console")
end
|
#releases_dir(*extra_paths) ⇒ Object
101
102
103
|
# File 'lib/eh/settings.rb', line 101
def releases_dir(*)
File.join(repository.dir, "releases", *)
end
|
#repositories ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/eh/settings.rb', line 83
def repositories
if data["repositories"]
repos = data["repositories"].map do |json|
Eh::Settings::Repository.new(json)
end
end
repos || []
end
|
#repository ⇒ Object
77
78
79
80
81
|
# File 'lib/eh/settings.rb', line 77
def repository
repositories&.find do |repository|
repository.current?
end
end
|
#ruby_processors_src_dir ⇒ Object
117
118
119
|
# File 'lib/eh/settings.rb', line 117
def ruby_processors_src_dir
File.join(repository.dir, "src", "ruby")
end
|
#ruby_release_dir ⇒ Object
109
110
111
|
# File 'lib/eh/settings.rb', line 109
def ruby_release_dir
releases_dir("ruby")
end
|
#source_config_dir ⇒ Object
138
139
140
|
# File 'lib/eh/settings.rb', line 138
def source_config_dir
File.join(repository.dir, "config")
end
|
#stages_dir ⇒ Object
158
159
160
|
# File 'lib/eh/settings.rb', line 158
def stages_dir
File.join(repository.dir, "config", "stages")
end
|
#template_tmp_dir ⇒ Object
150
151
152
|
# File 'lib/eh/settings.rb', line 150
def template_tmp_dir
"/tmp/eventhub-processor-template/"
end
|
#write ⇒ Object
63
64
65
66
67
|
# File 'lib/eh/settings.rb', line 63
def write
File.open(file, "w") do |f|
f.write(data.to_json)
end
end
|