Class: Eh::Settings
- Inherits:
-
Object
- Object
- Eh::Settings
- Defined in:
- lib/eh/settings.rb
Defined Under Namespace
Classes: Repository
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #deployment_dir ⇒ Object
- #deployment_management_files ⇒ Object
-
#initialize(file) ⇒ Settings
constructor
A new instance of Settings.
- #package_tmp_dir ⇒ Object
- #processor_template_repository_url ⇒ Object
- #processors_src_dir ⇒ Object
- #rails_release_dir ⇒ Object
- #rails_src_dir ⇒ Object
- #releases_dir(*extra_paths) ⇒ Object
- #repositories ⇒ Object
- #repository ⇒ Object
- #ruby_release_dir ⇒ Object
- #source_config_dir ⇒ Object
- #stages_dir ⇒ Object
- #template_tmp_dir ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(file) ⇒ Settings
Returns a new instance of Settings.
31 32 33 34 |
# File 'lib/eh/settings.rb', line 31 def initialize(file) @file = file @data = JSON.parse(File.read(file)) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/eh/settings.rb', line 3 def data @data end |
#file ⇒ Object (readonly)
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
50 51 52 |
# File 'lib/eh/settings.rb', line 50 def self.current Thread.current[:eh_settings] end |
.current=(value) ⇒ Object
46 47 48 |
# File 'lib/eh/settings.rb', line 46 def self.current=(value) Thread.current[:eh_settings] = value end |
Instance Method Details
#deployment_dir ⇒ Object
83 84 85 |
# File 'lib/eh/settings.rb', line 83 def deployment_dir File.join(repository.dir, 'src', 'deployment') end |
#deployment_management_files ⇒ Object
107 108 109 |
# File 'lib/eh/settings.rb', line 107 def deployment_management_files [ File.join(deployment_dir, 'management', 'launcher.rb') ] end |
#package_tmp_dir ⇒ Object
99 100 101 |
# File 'lib/eh/settings.rb', line 99 def package_tmp_dir './tmp' end |
#processor_template_repository_url ⇒ Object
95 96 97 |
# File 'lib/eh/settings.rb', line 95 def processor_template_repository_url 'https://github.com/thomis/eventhub-processor-template.git' end |
#processors_src_dir ⇒ Object
79 80 81 |
# File 'lib/eh/settings.rb', line 79 def processors_src_dir File.join(repository.dir, 'src', 'ruby') end |
#rails_release_dir ⇒ Object
71 72 73 |
# File 'lib/eh/settings.rb', line 71 def rails_release_dir releases_dir('rails') end |
#rails_src_dir ⇒ Object
87 88 89 |
# File 'lib/eh/settings.rb', line 87 def rails_src_dir File.join(repository.dir, 'src', 'rails', 'console') end |
#releases_dir(*extra_paths) ⇒ Object
67 68 69 |
# File 'lib/eh/settings.rb', line 67 def releases_dir(*extra_paths) File.join(repository.dir, 'releases', *extra_paths) end |
#repositories ⇒ Object
60 61 62 63 64 65 |
# File 'lib/eh/settings.rb', line 60 def repositories repos = data["repositories"].map do |json| Eh::Settings::Repository.new(json) end if data["repositories"] repos || [] end |
#repository ⇒ Object
54 55 56 57 58 |
# File 'lib/eh/settings.rb', line 54 def repository repositories.find do |repository| repository.current? end if repositories end |
#ruby_release_dir ⇒ Object
75 76 77 |
# File 'lib/eh/settings.rb', line 75 def ruby_release_dir releases_dir('ruby') end |
#source_config_dir ⇒ Object
91 92 93 |
# File 'lib/eh/settings.rb', line 91 def source_config_dir File.join(repository.dir, 'config') end |
#stages_dir ⇒ Object
111 112 113 |
# File 'lib/eh/settings.rb', line 111 def stages_dir File.join(repository.dir, 'config', 'stages') end |
#template_tmp_dir ⇒ Object
103 104 105 |
# File 'lib/eh/settings.rb', line 103 def template_tmp_dir '/tmp/eventhub-processor-template/' end |
#write ⇒ Object
40 41 42 43 44 |
# File 'lib/eh/settings.rb', line 40 def write File.open(file,"w") do |f| f.write(data.to_json) end end |