Class: BranchableCDNAssets::Config

Inherits:
Object
  • Object
show all
Extended by:
EnvironmentAttributeReader::ClassMethods
Includes:
EnvironmentAttributeReader
Defined in:
lib/branchable_cdn_assets/config.rb,
lib/branchable_cdn_assets/config/environment_attribute_reader.rb

Defined Under Namespace

Modules: EnvironmentAttributeReader Classes: Remote

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EnvironmentAttributeReader::ClassMethods

env_attr_reader

Methods included from EnvironmentAttributeReader

#env_attr

Constructor Details

#initialize(data, branch = Asgit.current_branch) ⇒ Config

Returns a new instance of Config.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/branchable_cdn_assets/config.rb', line 13

def initialize data, branch=Asgit.current_branch
  @raw_data = normalize_data data
  @branch   = branch

  @production_branch = raw_data.fetch :production_branch, 'master'
  @cloudfront        = raw_data.fetch :cloudfront,        {}
  @cdn_dir           = raw_data.fetch :dir,               'cdn'
  @dir_permissions   = env_attr(:dir_permissions)      || 755
  @file_permissions  = env_attr(:file_permissions)     || 644
  @rsync_flags       = env_attr(:rsync_flags)          || '-aviz'
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def branch
  @branch
end

#cdn_dirObject (readonly)

Returns the value of attribute cdn_dir.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def cdn_dir
  @cdn_dir
end

#cloudfrontObject (readonly)

Returns the value of attribute cloudfront.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def cloudfront
  @cloudfront
end

#dir_permissionsObject (readonly)

Returns the value of attribute dir_permissions.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def dir_permissions
  @dir_permissions
end

#file_permissionsObject (readonly)

Returns the value of attribute file_permissions.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def file_permissions
  @file_permissions
end

#production_branchObject (readonly)

Returns the value of attribute production_branch.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def production_branch
  @production_branch
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def raw_data
  @raw_data
end

#rsync_flagsObject (readonly)

Returns the value of attribute rsync_flags.



8
9
10
# File 'lib/branchable_cdn_assets/config.rb', line 8

def rsync_flags
  @rsync_flags
end

Instance Method Details

#envObject



25
26
27
# File 'lib/branchable_cdn_assets/config.rb', line 25

def env
  @env ||= env_for_branch
end

#environmentsObject



29
30
31
# File 'lib/branchable_cdn_assets/config.rb', line 29

def environments
  @environments ||= add_env_path_modifications_to_env_data raw_data.fetch(:environments, {})
end

#remotesObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/branchable_cdn_assets/config.rb', line 33

def remotes
  return @_remotes if @_remotes

  @_remotes = environments[env.to_sym].fetch(:remotes, [default_remote]).map do |r|
    remote = Remote.new
    default_remote.merge( normalize_data(r) ).each do |k, v|
      remote.public_send "#{k}=", v
    end
    remote
  end
end