Class: ErrorMessage
- Inherits:
-
Object
- Object
- ErrorMessage
- Defined in:
- lib/qiita_org/error_message.rb
Instance Method Summary collapse
- #access_token_error(access_token) ⇒ Object
- #config_set_error(conf_dir) ⇒ Object
-
#initialize ⇒ ErrorMessage
constructor
A new instance of ErrorMessage.
- #many_tags_error(tags) ⇒ Object
- #md_file_exists?(src, res) ⇒ Boolean
- #qiita_access_error(e) ⇒ Object
- #qiita_post_error(response, file) ⇒ Object
- #teams_url_error(teams_url) ⇒ Object
Constructor Details
#initialize ⇒ ErrorMessage
Returns a new instance of ErrorMessage.
5 6 |
# File 'lib/qiita_org/error_message.rb', line 5 def initialize() end |
Instance Method Details
#access_token_error(access_token) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/qiita_org/error_message.rb', line 8 def access_token_error(access_token) if access_token == "" puts "Please setting ACCESS_TOKEN".red exit end end |
#config_set_error(conf_dir) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/qiita_org/error_message.rb', line 54 def config_set_error(conf_dir) conf_path = File.join(conf_dir, ".qiita.conf") conf = JSON.load(File.read(conf_path)) check = true if conf["name"] == "" puts "Please set your name in config".red puts "Hint: qiita config global name 'YOUR NAME'".red puts "Hint: qiita config local name 'YOUR NAME'".red # system "rm template.org" check = false end if conf["email"] == "" puts "Please set your email in config".red puts "Hint: qiita config global email '[email protected]'".red puts "Hint: qiita config local name '[email protected]'".red check = false end unless check exit end end |
#many_tags_error(tags) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/qiita_org/error_message.rb', line 88 def () if .count(",") >= 5 puts "The maximum number of tag is five. Please delete some tags.".red exit end end |
#md_file_exists?(src, res) ⇒ Boolean
78 79 80 81 82 83 84 85 86 |
# File 'lib/qiita_org/error_message.rb', line 78 def md_file_exists?(src, res) unless File.exists?(src.gsub(".org", ".md")) puts "Can not make #{src.gsub(".org", ".md")}".red puts "Please confirm emacs version.".red exit else p res end end |
#qiita_access_error(e) ⇒ Object
22 23 24 25 |
# File 'lib/qiita_org/error_message.rb', line 22 def qiita_access_error(e) puts "#{$!}".red exit end |
#qiita_post_error(response, file) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/qiita_org/error_message.rb', line 27 def qiita_post_error(response, file) = response. if != "Created" if != "OK" if == "Unauthorized" puts "#{message}".red puts "Please check your access_token.".red system "rm #{file}" exit elsif == "Forbidden" puts "#{message}".red puts "You are not authorized to access this page. please check qiita_id.".red system "rm #{file}" exit elsif == "Not Found" puts "#{message}".red system "rm #{file}" exit else puts "#{message}".red system "rm #{file}" exit end end end end |
#teams_url_error(teams_url) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/qiita_org/error_message.rb', line 15 def teams_url_error(teams_url) if teams_url == "" puts "Please setting teams_url".red exit end end |