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.



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

#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



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

.load(file) ⇒ Object



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

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

Instance Method Details

#deployment_dirObject



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

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

#deployment_management_filesObject



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

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

#package_tmp_dirObject



99
100
101
# File 'lib/eh/settings.rb', line 99

def package_tmp_dir
  './tmp'
end

#processor_template_repository_urlObject



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_dirObject



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

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

#rails_release_dirObject



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

def rails_release_dir
  releases_dir('rails')
end

#rails_src_dirObject



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

#repositoriesObject



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

#repositoryObject



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_dirObject



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

def ruby_release_dir
  releases_dir('ruby')
end

#source_config_dirObject



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

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

#stages_dirObject



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

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

#template_tmp_dirObject



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

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

#writeObject



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