Class: Heroku::Command::Labs

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/command/labs.rb

Overview

manage optional features

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#api, #heroku, #initialize, namespace

Methods included from Helpers

#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #host_name, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty

Constructor Details

This class inherits a constructor from Heroku::Command::Base

Instance Method Details

#disableObject

labs:disable FEATURE

disables an experimental feature

Example:

$ pogo labs:disable ninja-power Disabling ninja-power feature for [email protected]… done



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/heroku/command/labs.rb', line 74

def disable
  feature_name = shift_argument
  error "Usage: pogo labs:disable FEATURE\nMust specify FEATURE to disable." unless feature_name
  validate_arguments!

  feature = api.get_features(app).body.detect { |f| f["name"] == feature_name }
  message = "Disabling #{feature_name} "

  error "No such feature: #{feature_name}" unless feature

  if feature["kind"] == "user"
    message += "for #{Heroku::Auth.user}"
  else
    error "Must specify an app" unless app
    message += "for #{app}"
  end

  action message do
    api.delete_feature feature_name, app
  end
end

#enableObject

labs:enable FEATURE

enables an experimental feature

Example:

$ pogo labs:enable ninja-power Enabling ninja-power feature for [email protected]… done



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/heroku/command/labs.rb', line 105

def enable
  feature_name = shift_argument
  error "Usage: pogo labs:enable FEATURE\nMust specify FEATURE to enable." unless feature_name
  validate_arguments!

  feature = api.get_features.body.detect { |f| f["name"] == feature_name }
  message = "Enabling #{feature_name} "

  error "No such feature: #{feature_name}" unless feature

  if feature["kind"] == "user"
    message += "for #{Heroku::Auth.user}"
  else
    error "Must specify an app" unless app
    message += "for #{app}"
  end

  feature_data = action(message) do
    api.post_feature(feature_name, app).body
  end

  display "WARNING: This feature is experimental and may change or be removed without notice."
  display "For more information see: #{feature_data["docs"]}" if feature_data["docs"]
end

#indexObject

labs

list experimental features

Example:

User Features ([email protected])

+

dashboard Use Heroku Dashboard by default

App Features (glacial-retreat-5913)

preboot Provide seamless web dyno deploys

user-env-compile Add user config vars to the environment during slug compilation # $ pogo labs -a example



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/heroku/command/labs.rb', line 20

def index
  validate_arguments!

  user_features, app_features = api.get_features(app).body.sort_by do |feature|
    feature["name"]
  end.partition do |feature|
    feature["kind"] == "user"
  end

  display_app = app || "no app specified"

  styled_header "User Features (#{Heroku::Auth.user})"
  display_features user_features
  display
  styled_header "App Features (#{display_app})"
  display_features app_features
end

#infoObject

labs:info FEATURE

displays additional information about FEATURE

Example:

$ pogo labs:info user_env_compile

user_env_compile

Docs: devcenter.heroku.com/articles/labs-user-env-compile Summary: Add user config vars to the environment during slug compilation



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/heroku/command/labs.rb', line 51

def info
  unless feature_name = shift_argument
    error("Usage: pogo labs:info FEATURE\nMust specify FEATURE for info.")
  end
  validate_arguments!

  feature_data = api.get_feature(feature_name, app).body
  styled_header(feature_data['name'])
  styled_hash({
    'Summary' => feature_data['summary'],
    'Docs'    => feature_data['docs']
  })
end