Class: Cid::Bootstrap
- Inherits:
-
Object
- Object
- Cid::Bootstrap
- Defined in:
- lib/cid.rb,
lib/cid/bootstrap.rb
Instance Attribute Summary collapse
-
#no_remote ⇒ Object
Returns the value of attribute no_remote.
Instance Method Summary collapse
- #encrypt_token ⇒ Object
-
#initialize(options) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
- #perform ⇒ Object
- #travis_yaml(dir = Dir.pwd) ⇒ Object
- #write ⇒ Object
- #yaml_string ⇒ Object
Constructor Details
#initialize(options) ⇒ Bootstrap
Returns a new instance of Bootstrap.
6 7 8 9 |
# File 'lib/cid/bootstrap.rb', line 6 def initialize() @branch = [:branch] @github_token = [:github_token] end |
Instance Attribute Details
#no_remote ⇒ Object
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_token ⇒ Object
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 |
#perform ⇒ Object
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.('.travis.yml', dir) end |
#write ⇒ Object
23 24 25 |
# File 'lib/cid/bootstrap.rb', line 23 def write File.write(travis_yaml, yaml_string) end |
#yaml_string ⇒ Object
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( = {line_width: -1}) end |