evertils 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52e6a69464d4e124f2e77134b249c4a078ff921929355f95cd0c823453fa1c88
4
- data.tar.gz: 10aa26578c12a747fd026040259bf26ff88a858f220c7e52c6e78fe288e3be53
3
+ metadata.gz: df26df4a386a535b8d49f2c5786f36bf770962d136dc26e47dfd3ccf5e1333ca
4
+ data.tar.gz: 950b7191584cb2339f55d8e70af6ad3941d11bd68250c11ea03d5a1d151afc19
5
5
  SHA512:
6
- metadata.gz: 62f26f68ffa20afd0aa71b606e6541963b4522557c109e43cefdcc16c9ddee8f4e6a18b9e74f72ff7aa308bc0346f03948197a5bd269e34ca12466c323b54af5
7
- data.tar.gz: 5e9d84b4e561cc1ec482d3c1cb86c79ab86772aade652c76ad4298117e071681db8a6dc332455bab471d9a2b83d0d11bf743024e9a89810702342dad67637091
6
+ metadata.gz: 7d8943ad6c9a5988451abe8da76c3e14d98ca81a656eda1b1abaf95a1ab88ea6cc5d64d933dc314013950f9f3a6a5395c0ebf2ab29fda27be0883429ce825939
7
+ data.tar.gz: '0815efbb2c410b28b20e44bc4b168824ac126c85d36245ef41a14de5d89c7bbabd6f06b830650a77d594101e8b03b056c5ded6939ccff2b9c8320117f7cc9c0f'
@@ -50,6 +50,9 @@ module Evertils
50
50
  fmt = Evertils::Helper.load('Formatting')
51
51
 
52
52
  @yml = fmt.symbolize(::YAML.load_file(file))
53
+
54
+ set_evertils_token
55
+
53
56
  self
54
57
  end
55
58
 
@@ -122,6 +125,10 @@ module Evertils
122
125
 
123
126
  private
124
127
 
128
+ def set_evertils_token
129
+ ENV['EVERTILS_TOKEN'] = @yml[:token]
130
+ end
131
+
125
132
  # Check if configuration data exists
126
133
  def valid_config?
127
134
  !@yml.nil?
@@ -0,0 +1,48 @@
1
+ module Evertils
2
+ module Controller
3
+ class Change < Controller::Base
4
+ REQUIRED_TOKEN_GROUPS = [:S, :U, :E, :C, :P, :A, :V, :H].freeze
5
+ CONFIG = File.expand_path('~/.evertils/config.yml')
6
+ ERROR_MESSAGE = "Token invalid\nGet one from https://www.evernote.com/Login.action?targetUrl=%2Fapi%2FDeveloperToken.action".freeze
7
+
8
+ # Change the defined Evernote token
9
+ def token
10
+ Notify.spit 'Already have your Evernote token? Paste it now:'
11
+
12
+ begin
13
+ set_evertils_token
14
+ rescue RuntimeError
15
+ Notify.error ERROR_MESSAGE
16
+ rescue Interrupt
17
+ Notify.error ERROR_MESSAGE
18
+ end
19
+
20
+ Notify.success('Token saved!')
21
+ end
22
+
23
+ private
24
+
25
+ def set_evertils_token
26
+ token = STDIN.gets.chomp
27
+ conf = YAML.load_file(CONFIG)
28
+ conf['token'] = token
29
+
30
+ raise unless valid? token
31
+
32
+ overwrite_config_with(conf)
33
+ end
34
+
35
+ def overwrite_config_with
36
+ File.open(CONFIG, 'w') { |file| file.write(conf.to_yaml) }
37
+ end
38
+
39
+ def valid?(token)
40
+ token_groups = token.split(':').map do |group|
41
+ group.split('=').first.to_sym
42
+ end
43
+
44
+ token_groups == REQUIRED_TOKEN_GROUPS
45
+ end
46
+ end
47
+ end
48
+ end
@@ -26,7 +26,7 @@ module Evertils
26
26
  end
27
27
  end
28
28
  rescue Interrupt
29
- Notify.warning('Cancelled wait')
29
+ Notify.error('Cancelled wait')
30
30
  end
31
31
 
32
32
  note
@@ -47,7 +47,7 @@ module Evertils
47
47
  end
48
48
  end
49
49
  rescue Interrupt
50
- Notify.warning('Cancelled wait')
50
+ Notify.error('Cancelled wait')
51
51
  end
52
52
 
53
53
  note
@@ -1,3 +1,3 @@
1
1
  module Evertils
2
- VERSION = '1.0.8'.freeze
2
+ VERSION = '1.0.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evertils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe
@@ -122,6 +122,7 @@ files:
122
122
  - lib/evertils/configs/templates/pq.enml
123
123
  - lib/evertils/configs/templates/weekly.enml
124
124
  - lib/evertils/controller.rb
125
+ - lib/evertils/controllers/change.rb
125
126
  - lib/evertils/controllers/convert.rb
126
127
  - lib/evertils/controllers/firstrun.rb
127
128
  - lib/evertils/controllers/generate.rb