Module: FontanaClientSupport

Defined in:
lib/fontana_client_support.rb,
lib/fontana_client_support/version.rb,
lib/fontana_client_support/config_server.rb

Defined Under Namespace

Classes: ConfigServer

Constant Summary collapse

DEPLOY_STRATEGY_NAMES =
[:scm, :sync].freeze
VERSION =
"0.19.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.root_dirObject

Returns the value of attribute root_dir.



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

def root_dir
  @root_dir
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



65
66
67
68
# File 'lib/fontana_client_support.rb', line 65

def configure
  yield(self) if block_given?
  self
end

.current_branch_nameObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fontana_client_support.rb', line 36

def current_branch_name
  raise "missing root_dir" if root_dir.nil?
  raise "root_dir does not exist: #{root_dir.inspect}" unless Dir.exist?(root_dir)
  unless @current_branch_name
    Dir.chdir(root_dir) do
      @current_branch_name = git_current_branch_name
    end
  end
  puts "@current_branch_name: #{@current_branch_name.inspect}"
  return @current_branch_name
end

.deploy_strategyObject



52
53
54
# File 'lib/fontana_client_support.rb', line 52

def deploy_strategy
  @deploy_strategy ||= :deploy
end

.deploy_strategy=(v) ⇒ Object



58
59
60
61
62
63
# File 'lib/fontana_client_support.rb', line 58

def deploy_strategy=(v)
  unless DEPLOY_STRATEGY_NAMES.include?(v)
    raise ArgumentError, "invalid deploy_strategy: #{v.inspect} must be one of #{DEPLOY_STRATEGY_NAMES.inspect}"
  end
  @deploy_strategy = v
end

.git_current_branch_nameObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fontana_client_support.rb', line 18

def git_current_branch_name
  # http://qiita.com/sugyan/items/83e060e895fa8ef2038c
  result = `git symbolic-ref --short HEAD`.strip
  return result unless result.nil? || result.empty?
  result = `git status`.scan(/On branch\s*(.+)\s*$/).flatten.first
  return result unless result.nil? || result.empty?
  work = `git log --decorate -1`.scan(/^commit\s[0-9a-f]+\s\((.+)\)/).
    flatten.first.split(/,/).map(&:strip).reject{|s| s =~ /HEAD\Z/}
  r = work.select{|s| s =~ /origin\//}.first
  r ||= work.first
  result = r.sub(/\Aorigin\//, '')
rescue => e
  puts "[#{e.class}] #{e.message}"
  puts "Dir.pwd: #{Dir.pwd}"
  puts "git status\n" << `git status`
  raise e
end

.repo_urlObject



48
49
50
# File 'lib/fontana_client_support.rb', line 48

def repo_url
  @repo_url ||= `git remote -v`.scan(/origin\s+(.+?)\s/).flatten.uniq.first
end

.vendor_dirObject



10
11
12
# File 'lib/fontana_client_support.rb', line 10

def vendor_dir
  @vendor_dir ||= File.join(root_dir, "vendor")
end

.vendor_fontanaObject



14
15
16
# File 'lib/fontana_client_support.rb', line 14

def vendor_fontana
  @vendor_fontana ||= File.join(vendor_dir, "fontana")
end