Class: Travis::CLI::Init
- Inherits:
-
Enable
- Object
- Command
- ApiCommand
- RepoCommand
- Enable
- Travis::CLI::Init
- Defined in:
- lib/travis/cli/init.rb
Constant Summary collapse
- LANGUAGE_MAPPING =
{ "node" => "node_js", "node.js" => "node_js", "javascript" => "node_js", "coffeescript" => "node_js", "c++" => "cpp", "obj-c" => "objective-c" }
Constants inherited from RepoCommand
RepoCommand::GIT_REGEX, RepoCommand::TRAVIS
Constants inherited from Command
Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK
Constants included from Tools::Assets
Instance Attribute Summary collapse
-
#travis_config ⇒ Object
writeonly
Sets the attribute travis_config.
Attributes inherited from RepoCommand
Attributes inherited from ApiCommand
Attributes inherited from Command
#arguments, #config, #debug, #force_interactive, #formatter, #input, #output
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from RepoCommand
Methods inherited from ApiCommand
#authenticate, #detected_endpoint?, #endpoint_config, #enterprise?, #initialize, #org?, #pro?, #setup, #sync
Methods included from Travis::Client::Methods
#access_token, #access_token=, #account, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #hooks, #job, #lint, #listen, #repo, #repos, #restart, #user
Methods inherited from Command
abstract, abstract?, #check_completion, #check_ruby, #check_version, #command_name, command_name, #debug?, description, #execute, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, subcommands, #terminal, #time, #usage, #usage_for, #write_to
Methods included from Tools::Assets
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::ApiCommand
Instance Attribute Details
#travis_config=(value) ⇒ Object (writeonly)
Sets the attribute travis_config
34 35 36 |
# File 'lib/travis/cli/init.rb', line 34 def travis_config=(value) @travis_config = value end |
Class Method Details
.languages ⇒ Object
36 37 38 |
# File 'lib/travis/cli/init.rb', line 36 def self.languages Dir[asset_path('init/*.yml')].map { |f| File.basename(f, '.yml') }.sort end |
Instance Method Details
#custom_config ⇒ Object
59 60 61 |
# File 'lib/travis/cli/init.rb', line 59 def custom_config @custom_config ||= {} end |
#help ⇒ Object
40 41 42 |
# File 'lib/travis/cli/init.rb', line 40 def help super("Available languages: #{self.class.languages.join(", ")}\n\n") end |
#run(language = nil, file = '.travis.yml') ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/travis/cli/init.rb', line 44 def run(language = nil, file = '.travis.yml') error "#{file} already exists, use --force to override" if File.exist?(file) and not force? and not print_conf? language ||= ask('Main programming language used: ') { |q| q.default = detect_language } self.travis_config = template(language).merge(custom_config) if print_conf? puts travis_config.to_yaml else save_travis_config(file) say("#{file} file created!") end super() unless skip_enable? end |