Class: RubyYacht::Project::DSL

Inherits:
Object
  • Object
show all
Extended by:
DSL::Base::ClassMethods
Includes:
DSL::Base
Defined in:
lib/ruby_yacht/dsl/project.rb

Overview

This class provides a DSL for configuring a project.

You can access this inside RubyYacht::Configuration::DSL by calling project. It will create a RubyYacht::Project.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL::Base::ClassMethods

add_attribute, add_boolean, add_generic_attribute, add_list, add_object, add_object_list, all_attributes, copied_attributes, created_type, creates_object, custom_attribute_method, default_values, required_attributes

Methods included from DSL::Base

#check_required_attributes, #check_server_type, #copy_local_config, #create_object, #load_custom_attributes, #run

Constructor Details

#initialize(name) ⇒ DSL

This initializer creates a new project.

Parameters

  • name: String The name of the project


69
70
71
72
73
# File 'lib/ruby_yacht/dsl/project.rb', line 69

def initialize(name)
  @name = name.to_sym
  load_custom_attributes
  load_app_initializers
end

Class Method Details

.custom_attribute_methodObject

This method gets the attribute that server types can use to specify custom attributes for this DSL type.

This DSL uses project_attributes.



169
170
171
# File 'lib/ruby_yacht/dsl/project.rb', line 169

def self.custom_attribute_method
  :project_attributes
end

Instance Method Details

#appObject

:method: app

You can call app 'mars' to add an app called mars. This takes a block for configuring the app, which allows you to call methods in RubyYacht::App::DSL



114
# File 'lib/ruby_yacht/dsl/project.rb', line 114

add_object_list :app, RubyYacht::App::DSL

#check_out_locallyObject

:method: check_out_locally

You can call check_out_locally to set the project's check_out_locally flag to true. The default is false.



106
# File 'lib/ruby_yacht/dsl/project.rb', line 106

add_boolean :check_out_locally

#databaseObject

:method: database

You can call database to configure a database for the project. This takes a block for configuring the database, which allows you to call methods in RubyYacht::Database::DSL



122
# File 'lib/ruby_yacht/dsl/project.rb', line 122

add_object_list :database, RubyYacht::Database::DSL

#dns_serverObject

:method: dns_server

You can call dns_server to configure the DNS for the project. This takes a block for configuring the DNS , which allows you to call methods in RubyYacht::DnsServer::DSL

This is optional.



140
# File 'lib/ruby_yacht/dsl/project.rb', line 140

add_object :dns_server, RubyYacht::DnsServer::DSL, required: false

#load_app_initializersObject

This method loads the special DSL methods for defining apps of a certain type.

For the app type with the name foo, this will create a foo_app method on the DSL that builds an app with the type foo.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/ruby_yacht/dsl/project.rb', line 149

def load_app_initializers
  RubyYacht.configuration.server_types.each do |server_type|
    main_method = server_type.container_type.to_s
    main_method += "_server" if server_type.container_type == :web
    method_name = "#{server_type.name}_#{main_method}"
    define_singleton_method method_name do |*args, &block|
      self.public_send(
        main_method,
        server_type.name,
        *args,
        &block
      ) 
    end
  end
end

#repositoryObject

:method: repository You can call repository 'github.com' to set the project's repository to github.com



87
# File 'lib/ruby_yacht/dsl/project.rb', line 87

add_attribute :repository

#repository_protocolObject

:method: repository_protocol You can call repository_protocol :https to tell the scripts to check out the repositories over HTTPS rather than SSH.



93
# File 'lib/ruby_yacht/dsl/project.rb', line 93

add_attribute :repository_protocol, :ssh

#system_prefixObject

:method: system_prefix You can call system_prefix 'my-apps' to set the projects system_prefixtomy-apps`



81
# File 'lib/ruby_yacht/dsl/project.rb', line 81

add_attribute :system_prefix

#web_serverObject

:method: web_server

You can call web_server to configure a web server for the project. This takes a block for configuring the server, which allows you to call methods in RubyYacht::WebServer::DSL



130
# File 'lib/ruby_yacht/dsl/project.rb', line 130

add_object_list :web_server, RubyYacht::WebServer::DSL