Module: Houston::Extensions

Included in:
Houston
Defined in:
lib/houston/boot/extensions.rb

Defined Under Namespace

Classes: Event, FeatureDsl, FormBuilderDsl, GlobalFeature, ProjectBannerFeature, ProjectBannerFeatureDsl, ProjectColumn, ProjectColumnDsl, ProjectFeature, ProjectFeatureForm, RegisterEventDsl, RegisterEventsDsl

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



6
7
8
# File 'lib/houston/boot/extensions.rb', line 6

def events
  @events
end

#serializersObject (readonly)

Returns the value of attribute serializers.



6
7
8
# File 'lib/houston/boot/extensions.rb', line 6

def serializers
  @serializers
end

Instance Method Details

#accept_credentials_for(service, &test_connection_proc) ⇒ Object



146
147
148
# File 'lib/houston/boot/extensions.rb', line 146

def accept_credentials_for(service, &test_connection_proc)
  @credentials_services[service] = test_connection_proc
end

#add_navigation_renderer(slug, &block) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
# File 'lib/houston/boot/extensions.rb', line 18

def add_navigation_renderer(slug, &block)
  dsl = FeatureDsl.new(GlobalFeature.new)
  dsl.instance_eval(&block)
  feature = dsl.feature
  feature.slug = slug
  raise ArgumentError, "Renderer must supply name, but #{slug.inspect} doesn't" unless feature.name
  raise ArgumentError, "Renderer must supply path lambda, but #{slug.inspect} doesn't" unless feature.path_block

  @navigation_renderers[slug] = feature
end

#add_project_column(slug, &block) ⇒ Object



98
99
100
101
102
103
104
105
# File 'lib/houston/boot/extensions.rb', line 98

def add_project_column(slug, &block)
  dsl = ProjectColumnDsl.new(ProjectColumn.new)
  dsl.instance_eval(&block)
  feature = dsl.feature
  feature.slug = slug

  @project_columns[slug] = feature
end

#add_project_feature(slug, &block) ⇒ Object

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
49
# File 'lib/houston/boot/extensions.rb', line 40

def add_project_feature(slug, &block)
  dsl = FeatureDsl.new(ProjectFeature.new)
  dsl.instance_eval(&block)
  feature = dsl.feature
  feature.slug = slug
  raise ArgumentError, "Project Feature must supply name, but #{slug.inspect} doesn't" unless feature.name
  raise ArgumentError, "Project Feature must supply path lambda, but #{slug.inspect} doesn't" unless feature.path_block

  @available_project_features[slug] = feature
end

#add_project_header_command(slug, &block) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/houston/boot/extensions.rb', line 83

def add_project_header_command(slug, &block)
  dsl = ProjectBannerFeatureDsl.new(ProjectBannerFeature.new)
  dsl.instance_eval(&block)
  feature = dsl.feature
  feature.slug = slug

  @project_header_commands[slug] = feature
end

#add_project_option(slug, &block) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/houston/boot/extensions.rb', line 68

def add_project_option(slug, &block)
  dsl = FormBuilderDsl.new
  dsl.instance_eval(&block)
  form = dsl.form
  form.slug = slug

  @project_options[slug] = form
end

#add_serializer(serializer) ⇒ Object



135
136
137
138
139
140
141
142
# File 'lib/houston/boot/extensions.rb', line 135

def add_serializer(serializer)
  [:applies_to?, :pack].each do |method|
    next if serializer.respond_to?(method)
    raise ArgumentError, "`serializer` must respond to `#{method}`"
  end

  @serializers.push serializer
end

#add_user_option(slug, &block) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/houston/boot/extensions.rb', line 53

def add_user_option(slug, &block)
  dsl = FormBuilderDsl.new
  dsl.instance_eval(&block)
  form = dsl.form
  form.slug = slug

  @user_options[slug] = form
end

#available_navigation_renderersObject



10
11
12
# File 'lib/houston/boot/extensions.rb', line 10

def available_navigation_renderers
  @navigation_renderers.keys
end

#available_project_featuresObject



32
33
34
# File 'lib/houston/boot/extensions.rb', line 32

def available_project_features
  @available_project_features.keys
end

#get_navigation_renderer(name) ⇒ Object



14
15
16
# File 'lib/houston/boot/extensions.rb', line 14

def get_navigation_renderer(name)
  @navigation_renderers.fetch(name)
end

#get_project_feature(slug) ⇒ Object



36
37
38
# File 'lib/houston/boot/extensions.rb', line 36

def get_project_feature(slug)
  @available_project_features.fetch(slug)
end

#get_registered_event(event_name) ⇒ Object



117
118
119
# File 'lib/houston/boot/extensions.rb', line 117

def get_registered_event(event_name)
  events.find { |event| event.matches? event_name }
end

#project_columnsObject



107
108
109
# File 'lib/houston/boot/extensions.rb', line 107

def project_columns
  @project_columns.values
end

#project_header_commandsObject



92
93
94
# File 'lib/houston/boot/extensions.rb', line 92

def project_header_commands
  @project_header_commands.values
end

#project_optionsObject



77
78
79
# File 'lib/houston/boot/extensions.rb', line 77

def project_options
  @project_options.values
end

#register_event(name, description) ⇒ Object



121
122
123
# File 'lib/houston/boot/extensions.rb', line 121

def register_event(name, description)
  events.push Event.new(name, description)
end

#register_events(&block) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/houston/boot/extensions.rb', line 125

def register_events(&block)
  dsl = RegisterEventsDsl.new
  hash = dsl.instance_eval(&block)
  hash.each do |name, description|
    register_event(name, description.to_h)
  end
end

#registered_event?(event_name) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/houston/boot/extensions.rb', line 113

def registered_event?(event_name)
  events.any? { |event| event.matches? event_name }
end

#test_connection_to(credentials) ⇒ Object



154
155
156
157
158
159
# File 'lib/houston/boot/extensions.rb', line 154

def test_connection_to(credentials)
   = credentials.
  password = credentials.password.decrypt(Houston.config.passphrase)
  errors = credentials.errors
  @credentials_services[credentials.service].call(, password, errors)
end

#user_credentials_support_servicesObject



150
151
152
# File 'lib/houston/boot/extensions.rb', line 150

def user_credentials_support_services
  @credentials_services.values
end

#user_optionsObject



62
63
64
# File 'lib/houston/boot/extensions.rb', line 62

def user_options
  @user_options.values
end