Class: Cid::Bootstrap

Inherits:
Object
  • Object
show all
Defined in:
lib/cid.rb,
lib/cid/bootstrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Bootstrap

Returns a new instance of Bootstrap.



6
7
8
9
# File 'lib/cid/bootstrap.rb', line 6

def initialize(options)
  @branch = options[:branch]
  @github_token = options[:github_token]
end

Instance Attribute Details

#no_remoteObject

Returns the value of attribute no_remote.



4
5
6
# File 'lib/cid/bootstrap.rb', line 4

def no_remote
  @no_remote
end

Instance Method Details

#encrypt_tokenObject



18
19
20
21
# File 'lib/cid/bootstrap.rb', line 18

def encrypt_token
  output = `travis encrypt GITHUB_OAUTH_TOKEN=#{@github_token} --add`
  no_remote = true if output.match /Can't figure out GitHub repo name/
end

#performObject



11
12
13
14
15
16
# File 'lib/cid/bootstrap.rb', line 11

def perform
  write
  if @github_token
    encrypt_token
  end
end

#travis_yaml(dir = Dir.pwd) ⇒ Object



27
28
29
# File 'lib/cid/bootstrap.rb', line 27

def travis_yaml(dir = Dir.pwd)
  path = File.expand_path('.travis.yml', dir)
end

#writeObject



23
24
25
# File 'lib/cid/bootstrap.rb', line 23

def write
  File.write(travis_yaml, yaml_string)
end

#yaml_stringObject



31
32
33
34
35
36
37
# File 'lib/cid/bootstrap.rb', line 31

def yaml_string
  {
    'before_script' => 'gem install cid',
    'script' => 'cid validate',
    'after_success' => "[ \"$TRAVIS_BRANCH\" == \"#{@branch}\" ] && [ \"$TRAVIS_PULL_REQUEST\" == \"false\" ] && cid publish"
  }.to_yaml(options = {line_width: -1})
end