Module: Flydata::Helpers
- Included in:
- ApiClient, Cli, Command::Setup, Credentials
- Defined in:
- lib/flydata/helpers.rb
Class Method Summary collapse
- .development? ⇒ Boolean
- .flydata_api_host_file ⇒ Object
- .flydata_conf_file ⇒ Object
- .flydata_home_directory ⇒ Object
-
.format_menu_list(menu_list) ⇒ Object
format text.
-
.home_directory ⇒ Object
file paths.
- .parse_command(cmd) ⇒ Object
- .print_usage ⇒ Object
- .to_command_class(class_name) ⇒ Object
Class Method Details
.development? ⇒ Boolean
38 39 40 |
# File 'lib/flydata/helpers.rb', line 38 def development? File.open(flydata_conf_file).first.strip.end_with?('dev') end |
.flydata_api_host_file ⇒ Object
67 68 69 |
# File 'lib/flydata/helpers.rb', line 67 def flydata_api_host_file File.join(flydata_home_directory, 'flydata_api_host') end |
.flydata_conf_file ⇒ Object
71 72 73 |
# File 'lib/flydata/helpers.rb', line 71 def flydata_conf_file File.join(flydata_home_directory, 'flydata.conf') end |
.flydata_home_directory ⇒ Object
63 64 65 |
# File 'lib/flydata/helpers.rb', line 63 def flydata_home_directory File.join(home_directory, '.flydata') end |
.format_menu_list(menu_list) ⇒ Object
format text
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/flydata/helpers.rb', line 43 def () max_length_list = .inject(Array.new(.first.size, 0)) do |ml, | 0.upto(.size - 1) do |i| ml[i] = [i].length if ml[i] < [i].length end ml end = .collect do || 0.upto(.size - 1).inject("") do |str, i| str = "#{str}#{[i].ljust(max_length_list[i] + 1, ' ')}" end end end |
.home_directory ⇒ Object
file paths
59 60 61 |
# File 'lib/flydata/helpers.rb', line 59 def home_directory ENV['HOME'] || Dir.pwd end |
.parse_command(cmd) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/flydata/helpers.rb', line 4 def parse_command(cmd) klass = Flydata::Command::Base method = cmd if cmd.include?(':') class_name, method = cmd.split(':') klass = to_command_class(class_name) end [klass, method] end |
.print_usage ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/flydata/helpers.rb', line 14 def print_usage puts '-' * 64 puts <<-EOM Usage: flydata COMMAND setup # setup initially start # start flydata process stop # stop flydata process restart # restart flydata process If you encountered login or any other errors during setup, please setup flydata again by following commands. source ~/.bashrc flydata setup You can check the logs of sender(flydata) process. Log path: ~/.flydata/flydata.log EOM puts '-' * 64 end |
.to_command_class(class_name) ⇒ Object
34 35 36 |
# File 'lib/flydata/helpers.rb', line 34 def to_command_class(class_name) eval("Flydata::Command::#{class_name.camelcase}") end |