Module: AppSendr::Helpers
- Included in:
- Command, Command::Base
- Defined in:
- lib/appsendr/helpers.rb
Instance Method Summary collapse
- #credentials_file ⇒ Object
- #credentials_setup? ⇒ Boolean
- #display(msg, newline = true) ⇒ Object
- #error(msg) ⇒ Object
-
#has_project_droppr? ⇒ Boolean
droppr.
- #home_directory ⇒ Object
- #in_project_dir? ⇒ Boolean
-
#is_file_to_large?(file) ⇒ Boolean
split.
- #message(msg) ⇒ Object
- #project_appsendr ⇒ Object
- #project_appsendr_app ⇒ Object
- #read_app ⇒ Object
- #read_app_id ⇒ Object
- #require_in_project_and_no_droppr(num_args, action, wrong_args, greater_than = false) ⇒ Object
- #require_project(num_args, action, wrong_args, greater_than = false) ⇒ Object
- #require_project_dir(action) ⇒ Object
- #require_project_droppr ⇒ Object
- #running_on_a_mac? ⇒ Boolean
- #running_on_windows? ⇒ Boolean
- #size_of_file(file) ⇒ Object
Instance Method Details
#credentials_file ⇒ Object
24 25 26 |
# File 'lib/appsendr/helpers.rb', line 24 def credentials_file "#{home_directory}/#{AppSendr::APPDROPPR_DIR}/credentials" end |
#credentials_setup? ⇒ Boolean
28 29 30 |
# File 'lib/appsendr/helpers.rb', line 28 def credentials_setup? File.exist?(credentials_file) end |
#display(msg, newline = true) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/appsendr/helpers.rb', line 15 def display(msg, newline=true) if newline puts(msg) else print(msg) STDOUT.flush end end |
#error(msg) ⇒ Object
47 48 49 50 |
# File 'lib/appsendr/helpers.rb', line 47 def error(msg) STDERR.puts(msg) exit 1 end |
#has_project_droppr? ⇒ Boolean
droppr
74 75 76 77 |
# File 'lib/appsendr/helpers.rb', line 74 def has_project_droppr? return false unless File.directory?(project_appsendr) return File.exist?(project_appsendr_app) end |
#home_directory ⇒ Object
3 4 5 |
# File 'lib/appsendr/helpers.rb', line 3 def home_directory running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME'] end |
#in_project_dir? ⇒ Boolean
87 88 89 |
# File 'lib/appsendr/helpers.rb', line 87 def in_project_dir? return Dir.entries(Dir.pwd).grep(/.+\.xcodeproj/).first end |
#is_file_to_large?(file) ⇒ Boolean
split
57 58 59 60 61 62 63 64 |
# File 'lib/appsendr/helpers.rb', line 57 def is_file_to_large?(file) in_mb = size_of_file(file).to_f if in_mb > 10 return true else return false end end |
#message(msg) ⇒ Object
52 53 54 |
# File 'lib/appsendr/helpers.rb', line 52 def (msg) puts("=== #{msg}") end |
#project_appsendr ⇒ Object
32 33 34 |
# File 'lib/appsendr/helpers.rb', line 32 def project_appsendr Dir.pwd+"/#{AppSendr::PROJECT_DIR}" end |
#project_appsendr_app ⇒ Object
36 37 38 |
# File 'lib/appsendr/helpers.rb', line 36 def project_appsendr_app project_appsendr+"/app" end |
#read_app ⇒ Object
43 44 45 |
# File 'lib/appsendr/helpers.rb', line 43 def read_app File.exists?(project_appsendr_app) and File.read(project_appsendr_app).split("\n") end |
#read_app_id ⇒ Object
40 41 42 |
# File 'lib/appsendr/helpers.rb', line 40 def read_app_id File.exists?(project_appsendr_app) and File.read(project_appsendr_app).split("\n").first end |
#require_in_project_and_no_droppr(num_args, action, wrong_args, greater_than = false) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/appsendr/helpers.rb', line 112 def require_in_project_and_no_droppr(num_args,action,wrong_args,greater_than=false) if in_project_dir? and !has_project_droppr? if args.count >= num_args if greater_than return true elsif !greater_than and (args.count == num_args) return true else return false end elsif wrong_args error "You must include #{wrong_args}" end else require_project_dir(action) error "This app is already linked to appsendr." unless !has_project_droppr? end return false end |
#require_project(num_args, action, wrong_args, greater_than = false) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/appsendr/helpers.rb', line 91 def require_project(num_args,action,wrong_args,greater_than=false) if in_project_dir? and has_project_droppr? if args.count >= num_args if greater_than return true elsif !greater_than and (args.count == num_args) return true else return false end elsif wrong_args error "You must include #{wrong_args}" end else require_project_dir(action) require_project_droppr end return false end |
#require_project_dir(action) ⇒ Object
83 84 85 |
# File 'lib/appsendr/helpers.rb', line 83 def require_project_dir(action) error "You must be in a Xcode project directory to #{action}" unless in_project_dir? end |
#require_project_droppr ⇒ Object
79 80 81 |
# File 'lib/appsendr/helpers.rb', line 79 def require_project_droppr error "Project directory doesn't exist. Have you created an this app on appsendr?" unless has_project_droppr? end |
#running_on_a_mac? ⇒ Boolean
11 12 13 |
# File 'lib/appsendr/helpers.rb', line 11 def running_on_a_mac? RUBY_PLATFORM =~ /-darwin\d/ end |
#running_on_windows? ⇒ Boolean
7 8 9 |
# File 'lib/appsendr/helpers.rb', line 7 def running_on_windows? RUBY_PLATFORM =~ /mswin32|mingw32/ end |
#size_of_file(file) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/appsendr/helpers.rb', line 66 def size_of_file(file) size = File.size(file) mb = 1024.0 * 1024.0 in_mb = size / mb end |