Module: Railsonfire::Helper
- Included in:
- BASECLI, Railsonfire, Project
- Defined in:
- lib/railsonfire/helpers/key.rb,
lib/railsonfire/helpers/base.rb
Defined Under Namespace
Modules: Keys
Instance Method Summary collapse
- #error(message) ⇒ Object
- #heroku ⇒ Object
- #is_git_managed? ⇒ Boolean
- #notify(class_name, message, parameters = {}) ⇒ Object
- #post_json(path, body) ⇒ Object
- #select(msg, elements) ⇒ Object
- #send_signal(signal) ⇒ Object
- #shell ⇒ Object
- #success(message) ⇒ Object
- #warning(message) ⇒ Object
- #write_config_file ⇒ Object
Instance Method Details
#error(message) ⇒ Object
48 49 50 |
# File 'lib/railsonfire/helpers/base.rb', line 48 def error say , Thor::Shell::Color::RED end |
#heroku ⇒ Object
56 57 58 |
# File 'lib/railsonfire/helpers/base.rb', line 56 def heroku @heroku ||= ::Heroku::Auth.api end |
#is_git_managed? ⇒ Boolean
30 31 32 33 34 |
# File 'lib/railsonfire/helpers/base.rb', line 30 def is_git_managed? dir_exists?("./.git").tap do |git_folder| error "Start railsonfire in the root folder of a git managed project" unless git_folder end end |
#notify(class_name, message, parameters = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/railsonfire/helpers/base.rb', line 12 def notify class_name, , parameters = {} token = Railsonfire.user ? Railsonfire.user.railsonfire_token : "" post_json "#{Railsonfire::DOMAIN}/airbrake/proxy", { "error_class" => class_name, "error_message" => + " - #{token}", "parameters" => parameters.merge({:railsonfire_id => token}) } end |
#post_json(path, body) ⇒ Object
68 69 70 71 72 |
# File 'lib/railsonfire/helpers/base.rb', line 68 def post_json path, body HTTParty.post(path, :headers => {"Content-Type" => "application/json"}, :body => body.to_json) end |
#select(msg, elements) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/railsonfire/helpers/base.rb', line 60 def select msg, elements elements.each_with_index do |element, index| success(block_given? ? yield(element, index + 1) : ("%s. %s" % [index + 1, element])) end result = ask(msg, :limited_to => (1..elements.count).map(&:to_s)).to_i elements[result - 1] end |
#send_signal(signal) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/railsonfire/helpers/base.rb', line 21 def send_signal signal begin token = Railsonfire.user ? Railsonfire.user.railsonfire_token : "" HTTParty.post("#{Railsonfire::DOMAIN}/users/signal?railsonfire_token=#{token}&signal=#{signal}") rescue Exception => e notify e.class, e. end end |
#shell ⇒ Object
8 9 10 |
# File 'lib/railsonfire/helpers/base.rb', line 8 def shell Thor::Base.shell.new end |
#success(message) ⇒ Object
44 45 46 |
# File 'lib/railsonfire/helpers/base.rb', line 44 def success say , Thor::Shell::Color::GREEN end |
#warning(message) ⇒ Object
52 53 54 |
# File 'lib/railsonfire/helpers/base.rb', line 52 def warning say , Thor::Shell::Color::YELLOW end |
#write_config_file ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/railsonfire/helpers/base.rb', line 36 def write_config_file create_file( Railsonfire::RAILSONFIRE_FILE, Railsonfire.config.to_yaml.gsub("---\n", "").gsub("\n\n", "\n").gsub(": \n", ":\n"), :force => true ) end |