pry-parsecom 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,5 +19,6 @@ PryParsecom::Commands.create_command "show-applications" do
19
19
  table.add_row [name, name == PryParsecom::Setting.current_app ? '*' : '']
20
20
  end
21
21
  output.puts table
22
+ output.puts "(cached at: #{PryParsecom::Setting.cache_time})"
22
23
  end
23
24
  end
@@ -31,5 +31,6 @@ PryParsecom::Commands.create_command 'show-classes' do
31
31
  table.add_row klass
32
32
  end
33
33
  output.puts table
34
+ output.puts "(cached at: #{PryParsecom::Setting.cache_time})"
34
35
  end
35
36
  end
@@ -32,5 +32,6 @@ PryParsecom::Commands.create_command "show-credentials" do
32
32
  table.add_row ['MASTER_KEY', (setting.master_key || '').sub(/.{30}$/, '*' * 30)]
33
33
  end
34
34
  output.puts table
35
+ output.puts "(cached at: #{PryParsecom::Setting.cache_time})"
35
36
  end
36
37
  end
@@ -35,5 +35,6 @@ PryParsecom::Commands.create_command "show-schema" do
35
35
  table.add_row [name, type]
36
36
  end
37
37
  output.puts table
38
+ output.puts "(cached at: #{PryParsecom::Setting.cache_time})"
38
39
  end
39
40
  end
@@ -29,6 +29,8 @@ module PryParsecom
29
29
 
30
30
  def current_app= app
31
31
  @@current_app = app
32
+ store_setting
33
+ app
32
34
  end
33
35
 
34
36
  def current_setting
@@ -37,7 +39,7 @@ module PryParsecom
37
39
 
38
40
  def setup_if_needed
39
41
  if @@apps.empty?
40
- unless load
42
+ unless restore
41
43
  login *PryParsecom.ask_email_and_password
42
44
  end
43
45
  end
@@ -54,7 +56,7 @@ module PryParsecom
54
56
  end
55
57
  end
56
58
 
57
- def load
59
+ def restore
58
60
  if File.exist? DOT_DIRNAME
59
61
  settings = read_setting_file SETTINGS_FILENAME
60
62
  ignores = read_setting_file IGNORES_FILENAME
@@ -69,13 +71,17 @@ module PryParsecom
69
71
  @@apps[app_name] = Setting.new app_name, key['app_id'], key['api_key'],
70
72
  key['master_key'], schemas[app_name]
71
73
  end
74
+ unless settings.empty?
75
+ settings = YAML.load settings
76
+ @@current_app = settings['current_app']
77
+ end
72
78
  return true
73
79
  end
74
80
  end
75
81
  false
76
82
  end
77
83
 
78
- def save
84
+ def store_cache
79
85
  keys = {}
80
86
  schemas = {}
81
87
  @@apps.each do |app_name, setting|
@@ -91,6 +97,12 @@ module PryParsecom
91
97
  write_setting_file SCHEMAS_FILENAME, schemas
92
98
  end
93
99
 
100
+ def store_setting
101
+ if @@current_app
102
+ write_setting_file SETTINGS_FILENAME, 'current_app' => @@current_app
103
+ end
104
+ end
105
+
94
106
  def login email, password
95
107
  @@apps = {}
96
108
 
@@ -121,7 +133,7 @@ module PryParsecom
121
133
  @@apps[app_name] = Setting.new app_name, app_id, api_key, master_key, schema
122
134
  end
123
135
 
124
- save
136
+ store_cache
125
137
  end
126
138
 
127
139
  def logout
@@ -131,6 +143,14 @@ module PryParsecom
131
143
  @@current_app = nil
132
144
  end
133
145
 
146
+ def cache_time
147
+ if File.exist? DOT_DIRNAME
148
+ File.mtime "#{DOT_DIRNAME}/#{SCHEMAS_FILENAME}"
149
+ else
150
+ nil
151
+ end
152
+ end
153
+
134
154
  def app_names
135
155
  @@apps.keys
136
156
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module PryParsecom
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-parsecom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-18 00:00:00.000000000 Z
12
+ date: 2013-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry