comer_de_tapas 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bffe960a14d00a4e709f83f73a18c92eb24ac2c
4
- data.tar.gz: af4c448c8ff3b9fa99dafbd65bb2022d7dd6e343
3
+ metadata.gz: 581ba0c2dd6e3afcccaa2f54d488abf8bb7039d7
4
+ data.tar.gz: b7f0040150ca17fac7d81580a844901003558ece
5
5
  SHA512:
6
- metadata.gz: b549581031583ec8ad878d7fb743318aa569f69af8e8212a4d451dcd6c4a252f0ebbb1ba3d8cf1e5e2b0b0c1f959537405227af6414d1f808a56d9244090b8b4
7
- data.tar.gz: f240419d5b141823ca17c3c5cf853eb2fe0233aed611534fe2458f105934c3b04785f1eb1aee7dd93532803f133529f350a99ae3ee4e26f08879c184b819d6c0
6
+ metadata.gz: df5f387b94fcb6c1b36860e27787c040b39c6141e77e27895105b800074fb7cb2ee947df0d46f09664b2c2eb873b10c1ac6cf79b6a12cbfdead7961b0711fcb9
7
+ data.tar.gz: d4979d6e54fd92bf1dc2e46e2b77f2c8cabec22208b447922c7d60031fb8251c24cef320cd69075f3772c2570e20b437d621b3547e718848a614dd6faf611859
@@ -1,11 +1,9 @@
1
1
  module ComerDeTapas
2
2
  class Subscription
3
- CredentialYamlNotExist = Class.new StandardError
4
- CredentialYamlKeyError = Class.new StandardError
5
- CredentialYamlValueError = Class.new StandardError
3
+ KEYS = %w(email password save_path)
6
4
 
7
5
  def initialize
8
- raise CredentialYamlNotExist, 'Please run `comer_de_tapas init` first' unless File.exist? CREDENTIAL_FILE
6
+ abort 'Please run `comer_de_tapas init` first' unless File.exist? CREDENTIAL_FILE
9
7
 
10
8
  set_subscription_data if subscription_data_valid?
11
9
  end
@@ -25,7 +23,8 @@ module ComerDeTapas
25
23
  @credential_yaml ||= YAML.load_file CREDENTIAL_FILE
26
24
  end
27
25
 
28
- # Check if ~/.rubytapas/.credentials files are filled and corrected.
26
+ # Return true if ~/.rubytapas/.credentials files are filled and correct.
27
+ # @return [Boolen]
29
28
  def subscription_data_valid?
30
29
  # empty credential file's size is about 50-55.
31
30
  # 65 is when you have a very short email, password, and save_path.
@@ -38,12 +37,16 @@ module ComerDeTapas
38
37
  credential_data_valid?(get_validate load_credential_data)
39
38
  end
40
39
 
41
- # Check if credential data valid?
40
+ # Return true if passed-in data all match criteria.
41
+ # @return [Boolen]
42
42
  def credential_data_valid? data
43
43
  data.each do |hash|
44
44
  hash.each do |k,v|
45
- raise CredentialYamlKeyError, "Valid yaml keys: #{KEYS.join(' ,')}." unless %w(email password save_path).include? k
46
- raise CredentialYamlValueError, "Please fill value for this one: #{k}" if v.nil?
45
+ abort <<-MSG unless KEYS.include? k
46
+ Probably have a typo in #{CREDENTIAL_FILE}: #{k}
47
+ Valid yaml keys: #{KEYS.join(', ')}.
48
+ MSG
49
+ abort "Please fill in #{k} in #{CREDENTIAL_FILE}" unless v
47
50
  end
48
51
  end
49
52
 
@@ -1,3 +1,3 @@
1
1
  module ComerDeTapas
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comer_de_tapas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juanito Fatas