sifttter-redux 0.3.5 → 0.3.6

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: 09dc6c17b4c8b08a270eb3390b3d5b168bbf9469
4
- data.tar.gz: d04dffea935f1ae8b9742d56f06b3876192e97fb
3
+ metadata.gz: b75ea05818cbdfe4e746c4c4107e8c25e45e9481
4
+ data.tar.gz: 37553f4bf3251e39694cb3c381b4d3d091d8a46c
5
5
  SHA512:
6
- metadata.gz: 4d29f5d7f4c3e8cb87341de4ba20845360fcce004096a8bdfead8093d78b33736e5689238dff1cbd2d316cac0e01268d03dd8743e8f16582e511084840e719d4
7
- data.tar.gz: 4f123218f2f8ea194982396303598425c361b01f1d7af93c0c7ea2c1d9da55def2cab394354cb9305fdda65b18a8c23634166011f3cb54842ea8bc496f0d7540
6
+ metadata.gz: 4705794626c05d79d9a87f512a3a1684d5dbbb85612859efb4f58d43eab7b2e0791e2b2a296629b00532e23a4d927ffc0e499f498d0b3491ce81c563c15bd59c
7
+ data.tar.gz: 1b81b5030f1db6aef89df7f3aec8aa74f432094ffe62ba55c0b30e677ae8e8edcab772528b78941f4126824b0944c8694014bf8377fc86640a516fbf16f2a201
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.3.6 (2014-02-21)
2
+
3
+ * Added logging via Methadone (key interactions logged to ~/.sifttter\_redux\_log)
4
+
1
5
  # 0.3.5 (2014-02-21)
2
6
 
3
7
  * Updated documentation and usage message
data/README.md CHANGED
@@ -65,12 +65,13 @@ $ srd init
65
65
 
66
66
  Initialization will perform the following steps:
67
67
 
68
- 1. Download [Dropbox-Uploader](https://github.com/andreafabrizi/Dropbox-Uploader "Dropbox-Uploder") to a location of your choice.
69
- 2. Collect some user preferences:
70
- 1. The location on your filesystem where Sifttter files will be temporarily stored
71
- 2. The location of your Sifttter files in Dropbox
72
- 3. The location on your filesystem where Day One files will be temporarily stored
73
- 4. The location of your Day One files in Dropbox
68
+ 1. Download [Dropbox Uploader](https://github.com/andreafabrizi/Dropbox-Uploader "Dropbox-Uploder") to a location of your choice.
69
+ 2. Automatically configure Dropbox Uploader.
70
+ 3. Collect some user preferences:
71
+ * The location on your filesystem where Sifttter files will be temporarily stored
72
+ * The location of your Sifttter files in Dropbox
73
+ * The location on your filesystem where Day One files will be temporarily stored
74
+ * The location of your Day One files in Dropbox
74
75
 
75
76
  ## Basic Execution
76
77
 
@@ -382,7 +383,7 @@ $ bundle install --global
382
383
  # Known Issues
383
384
 
384
385
  * Sifttter Redux makes no effort to see if entries already exist in Day One for a particular date. This means that if you're not careful, you might end up with duplicate entries. A future version will address this.
385
- * At indeterminiate times (usually when in catch-up mode), Sifttter Redux will upload a file to Day One that Day One fails to read. Uncertain of the cause at this stage, but it's happened a few times.
386
+ * Multiline updates aren't caught by Sifttter Redux; it counts on content being on single lines.
386
387
 
387
388
  # Future Releases
388
389
 
@@ -391,6 +392,7 @@ Some functionality I would like to tackle for future releases:
391
392
  * Plugin architecture for services that IFTTT doesn't support
392
393
  * Interactive cron job installer
393
394
  * Smarter checking of the config file to see if an old version is being used
395
+ * Multiline Sifttter entries
394
396
 
395
397
  # Bugs and Feature Requests
396
398
 
@@ -419,6 +421,6 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
419
421
  # Credits
420
422
 
421
423
  * Craig Eley for [Sifttter](http://craigeley.com/post/72565974459/sifttter-an-ifttt-to-day-one-logger "Sifttter") and for giving me the idea for Sifttter Redux
422
- * Dave Copeland for [GLI](https://github.com/davetron5000/gli "GLI")
424
+ * Dave Copeland for [GLI](https://github.com/davetron5000/gli "GLI") and [Methadone]("https://github.com/davetron5000/methadone" Methadone)
423
425
  * Andrea Fabrizi for [Dropbox Uploader](https://github.com/andreafabrizi/Dropbox-Uploader "Dropbox Uploader")
424
426
  * Tom Preston-Werner and Lee Jarvis for [Chronic](https://github.com/mojombo/chronic "Chronic")
data/bin/srd CHANGED
@@ -35,9 +35,12 @@
35
35
 
36
36
  require 'fileutils'
37
37
  require 'gli'
38
+ require 'methadone'
38
39
  require 'sifttter_redux'
39
40
 
40
41
  include GLI::App
42
+ include Methadone::CLILogging
43
+ include SifttterRedux
41
44
 
42
45
  program_desc 'Sifttter Redux
43
46
 
@@ -45,7 +48,7 @@ program_desc 'Sifttter Redux
45
48
  smart installation and automated running on a standalone
46
49
  *NIX device (such as a Raspberry Pi).'
47
50
 
48
- version SifttterRedux::VERSION
51
+ version VERSION
49
52
 
50
53
  # ======================================================
51
54
  # Global Flags and Switches
@@ -61,15 +64,19 @@ switch(
61
64
  # ======================================================
62
65
 
63
66
  pre do |global, command, options, args|
64
- SifttterRedux::Configuration.load(SifttterRedux::SRD_CONFIG_FILEPATH)
65
- SifttterRedux::DBU.load(
66
- File.join(
67
- SifttterRedux::Configuration['db_uploader']['local_filepath'],
68
- 'dropbox_uploader.sh'
69
- )
70
- )
71
-
72
- init unless File.exists?(SifttterRedux::SRD_CONFIG_FILEPATH)
67
+ # Load SifttterRedux configuration module.
68
+ Configuration.load(SRD_CONFIG_FILEPATH)
69
+
70
+ # Load Dropbox Uploader module.
71
+ DBU.load(File.join(Configuration['db_uploader']['local_filepath'], 'dropbox_uploader.sh'))
72
+
73
+ # Load Methadone CLILogging module.
74
+ Methadone::CLILogging.change_logger(Methadone::CLILogger.new(
75
+ File.open(SRD_LOG_FILEPATH, 'a+')
76
+ ))
77
+
78
+ # Initialize if the config file doesn't exist.
79
+ init unless File.exists?(SRD_CONFIG_FILEPATH)
73
80
  true
74
81
  end
75
82
 
@@ -130,50 +137,50 @@ command :exec do |c|
130
137
 
131
138
  SifttterRedux.verbose = global_options[:verbose] || options[:verbose]
132
139
 
133
- SifttterRedux::CliMessage.section_block('EXECUTING...') do
140
+ CLIMessage.section_block('EXECUTING...') do
134
141
  if options[:c] || options[:n] || options[:w] || options[:y] || options[:f] || options[:t]
135
142
 
136
143
  command_complete = false
137
144
 
138
145
  # Current Week
139
146
  if !command_complete && options[:c]
140
- dates = SifttterRedux::DateRangeMaker.last_n_weeks(0, options[:i])
147
+ dates = DateRangeMaker.last_n_weeks(0, options[:i])
141
148
  command_complete = true
142
149
  end
143
150
 
144
151
  # Last N Days
145
152
  if !command_complete && options[:n]
146
- dates = SifttterRedux::DateRangeMaker.last_n_days(options[:n].to_i, options[:i])
153
+ dates = DateRangeMaker.last_n_days(options[:n].to_i, options[:i])
147
154
  command_complete = true
148
155
  end
149
156
 
150
157
  # Yesterday
151
158
  if !command_complete && options[:y]
152
- dates = SifttterRedux::DateRangeMaker.yesterday
159
+ dates = DateRangeMaker.yesterday
153
160
  command_complete = true
154
161
  end
155
162
 
156
163
  # Last N Weeks
157
164
  if !command_complete && options[:w]
158
- dates = SifttterRedux::DateRangeMaker.last_n_weeks(options[:w].to_i, options[:i])
165
+ dates = DateRangeMaker.last_n_weeks(options[:w].to_i, options[:i])
159
166
  command_complete = true
160
167
  end
161
168
 
162
169
  # Specific Range
163
170
  if !command_complete && (options[:f] || options[:t])
164
171
  begin
165
- dates = SifttterRedux::DateRangeMaker.range(options[:f], options[:t], options[:i])
172
+ dates = DateRangeMaker.range(options[:f], options[:t], options[:i])
166
173
 
167
174
  if dates.last > Date.today
168
- SifttterRedux::CliMessage.warning("Ignoring overextended end date and using today's date (#{ Date.today })")
175
+ CLIMessage.warning("Ignoring overextended end date and using today's date (#{ Date.today })")
169
176
  dates = (dates.first..Date.today)
170
177
  end
171
178
  rescue ArgumentError => e
172
- SifttterRedux::CliMessage.error(e)
179
+ CLIMessage.error(e)
173
180
  end
174
181
  end
175
182
  else
176
- dates = SifttterRedux::DateRangeMaker.today
183
+ dates = DateRangeMaker.today
177
184
  end
178
185
 
179
186
  unless dates.nil?
@@ -182,36 +189,36 @@ command :exec do |c|
182
189
 
183
190
  if first_date == second_date
184
191
  date_string = first_date.strftime('%B %d, %Y')
185
- SifttterRedux::CliMessage.info("Creating entry for #{ date_string }...")
192
+ CLIMessage.info("Creating entry for #{ date_string }...")
186
193
  else
187
194
  date_string = "#{ first_date.strftime('%B %d, %Y') } to #{ second_date.strftime('%B %d, %Y') }"
188
- SifttterRedux::CliMessage.info("Creating entries for dates from #{ date_string }...")
195
+ CLIMessage.info("Creating entries for dates from #{ date_string }...")
189
196
  end
190
197
 
191
- SifttterRedux::DBU.local_target = '/tmp/sifttter'
192
- SifttterRedux::DBU.remote_target = '/Apps/ifttt/sifttter'
193
- SifttterRedux::DBU.message = 'Downloading Sifttter files...'
194
- SifttterRedux::DBU.download
198
+ DBU.local_target = '/tmp/sifttter'
199
+ DBU.remote_target = '/Apps/ifttt/sifttter'
200
+ DBU.message = 'Downloading Sifttter files...'
201
+ DBU.download
195
202
 
196
203
  dates.each do |date|
197
- SifttterRedux::Sifttter.run(date)
204
+ Sifttter.run(date)
198
205
  end
199
206
 
200
207
  # Upload any Day One entries to Dropbox (if there are any).
201
- unless Dir[SifttterRedux::Configuration['sifttter_redux']['dayone_local_filepath'] + '/*'].empty?
202
- SifttterRedux::DBU.local_target = "#{SifttterRedux::Configuration['sifttter_redux']['dayone_local_filepath']}/*"
203
- SifttterRedux::DBU.remote_target = SifttterRedux::Configuration['sifttter_redux']['dayone_remote_filepath']
204
- SifttterRedux::DBU.message = 'Uploading Day One entries to Dropbox...'
205
- SifttterRedux::DBU.upload
208
+ unless Dir[Configuration['sifttter_redux']['dayone_local_filepath'] + '/*'].empty?
209
+ DBU.local_target = "#{Configuration['sifttter_redux']['dayone_local_filepath']}/*"
210
+ DBU.remote_target = Configuration['sifttter_redux']['dayone_remote_filepath']
211
+ DBU.message = 'Uploading Day One entries to Dropbox...'
212
+ DBU.upload
206
213
  end
207
214
 
208
215
  # Remove any downloaded local files that we no longer need.
209
216
  dirs = [
210
- SifttterRedux::Configuration['sifttter_redux']['dayone_local_filepath'],
211
- SifttterRedux::Configuration['sifttter_redux']['sifttter_local_filepath']
217
+ Configuration['sifttter_redux']['dayone_local_filepath'],
218
+ Configuration['sifttter_redux']['sifttter_local_filepath']
212
219
  ]
213
220
 
214
- SifttterRedux::CliMessage.info_block('Removing temporary local files...') { dirs.each { |d| FileUtils.rm_rf(d) } }
221
+ CLIMessage.info_block('Removing temporary local files...') { dirs.each { |d| FileUtils.rm_rf(d) } }
215
222
  end
216
223
  end
217
224
  end
@@ -226,15 +233,13 @@ end
226
233
  desc 'Install and initialize dependencies'
227
234
  command :init do |c|
228
235
  c.action do |global_options, options, args|
229
-
230
- SifttterRedux::CliMessage.section_block('INITIALIZING...') do
231
- if File.exists?(SifttterRedux::Configuration.config_path)
232
- SifttterRedux.init if SifttterRedux::CliMessage.prompt("It looks like you've already initialized Sifttter Redux. Do you want to re-initialize?", 'N').downcase == 'y'
236
+ CLIMessage.section_block('INITIALIZING...') do
237
+ if File.exists?(Configuration.config_path)
238
+ SifttterRedux.init if CLIMessage.prompt("It looks like you've already initialized Sifttter Redux. Do you want to re-initialize?", 'N').downcase == 'y'
233
239
  else
234
240
  SifttterRedux.init
235
241
  end
236
242
  end
237
-
238
243
  end
239
244
  end
240
245
 
@@ -13,8 +13,6 @@ require 'sifttter_redux/version.rb'
13
13
  # ======================================================
14
14
 
15
15
  module SifttterRedux
16
- using CliMessage
17
- using Configuration
18
16
 
19
17
  # ----------------------------------------------------
20
18
  # Constants
@@ -23,6 +21,7 @@ module SifttterRedux
23
21
  DO_REMOTE_FILEPATH = "/Apps/Day\\ One/Journal.dayone/entries"
24
22
  DO_LOCAL_FILEPATH = '/tmp/dayone'
25
23
  SRD_CONFIG_FILEPATH = File.join(ENV['HOME'], '.sifttter_redux')
24
+ SRD_LOG_FILEPATH = File.join(ENV['HOME'], '.sifttter_redux_log')
26
25
  SFT_LOCAL_FILEPATH = '/tmp/sifttter'
27
26
  SFT_REMOTE_FILEPATH = '/Apps/ifttt/sifttter'
28
27
 
@@ -45,7 +44,7 @@ module SifttterRedux
45
44
  DBU::install_wizard
46
45
 
47
46
  # Collect other misc. preferences.
48
- CliMessage.section_block('COLLECTING PREFERENCES...') do
47
+ CLIMessage.section_block('COLLECTING PREFERENCES...') do
49
48
  pref_prompts = [
50
49
  {
51
50
  prompt: 'Location for downloaded Sifttter files from Dropbox',
@@ -74,11 +73,13 @@ module SifttterRedux
74
73
  ]
75
74
 
76
75
  pref_prompts.each do |prompt|
77
- pref = CliMessage.prompt(prompt[:prompt], prompt[:default])
76
+ pref = CLIMessage.prompt(prompt[:prompt], prompt[:default])
78
77
  Configuration[prompt[:section]].merge!(prompt[:key] => pref)
79
78
  end
80
79
  end
81
-
80
+
81
+ Methadone::CLILogging.info("Configuration values: #{ Configuration.dump }")
82
+
82
83
  Configuration.save
83
84
  end
84
85
 
@@ -5,7 +5,7 @@ module SifttterRedux
5
5
  # CliManager Module
6
6
  # Singleton to manage common CLI interfacing
7
7
  # ======================================================
8
- module CliMessage
8
+ module CLIMessage
9
9
  # ----------------------------------------------------
10
10
  # error method
11
11
  #
@@ -13,7 +13,8 @@ module SifttterRedux
13
13
  # @param m The message to output
14
14
  # @return Void
15
15
  # ----------------------------------------------------
16
- def self.error(m)
16
+ def self.error(m, log = true)
17
+ Methadone::CLILogging.error(m) if log
17
18
  puts "---> ERROR: #{ m }".red
18
19
  end
19
20
 
@@ -24,7 +25,8 @@ module SifttterRedux
24
25
  # @param m The message to output
25
26
  # @return Void
26
27
  # ----------------------------------------------------
27
- def self.info(m)
28
+ def self.info(m, log = true)
29
+ Methadone::CLILogging.info(m) if log
28
30
  puts "---> INFO: #{ m }".blue
29
31
  end
30
32
 
@@ -37,10 +39,10 @@ module SifttterRedux
37
39
  # @param multiline Whether the message should be multiline
38
40
  # @return Void
39
41
  # ----------------------------------------------------
40
- def self.info_block(m1, m2 = 'Done.', multiline = false)
42
+ def self.info_block(m1, m2 = 'Done.', multiline = false, log = true)
41
43
  if block_given?
42
44
  if multiline
43
- info(m1)
45
+ info(m1, log)
44
46
  else
45
47
  print "---> INFO: #{ m1 }".blue
46
48
  end
@@ -48,12 +50,14 @@ module SifttterRedux
48
50
  yield
49
51
 
50
52
  if multiline
51
- info(m2)
53
+ info(m2, log)
52
54
  else
53
55
  puts m2.blue
54
56
  end
55
57
  else
56
- fail ArgumentError, 'Did not specify a valid block'
58
+ error = 'Did not specify a valid block'
59
+ Methadone::CLILogging.error(error) if log
60
+ fail ArgumentError, error
57
61
  end
58
62
  end
59
63
 
@@ -83,7 +87,8 @@ module SifttterRedux
83
87
  # @param m The message to output
84
88
  # @return Void
85
89
  # ----------------------------------------------------
86
- def self.section(m)
90
+ def self.section(m, log = true)
91
+ Methadone::CLILogging.info(m) if log
87
92
  puts "#### #{ m }".purple
88
93
  end
89
94
 
@@ -97,17 +102,19 @@ module SifttterRedux
97
102
  # @param multiline A multiline message or not
98
103
  # @return Void
99
104
  # ----------------------------------------------------
100
- def self.section_block(m, multiline = true)
105
+ def self.section_block(m, multiline = true, log = true)
101
106
  if block_given?
102
107
  if multiline
103
- section(m)
108
+ section(m, log)
104
109
  else
105
110
  print "#### #{ m }".purple
106
111
  end
107
112
 
108
113
  yield
109
114
  else
110
- fail ArgumentError, 'Did not specify a valid block'
115
+ error = 'Did not specify a valid block'
116
+ Methadone::CLILogging.error(error) if log
117
+ fail ArgumentError, error
111
118
  end
112
119
  end
113
120
 
@@ -118,7 +125,8 @@ module SifttterRedux
118
125
  # @param m The message to output
119
126
  # @return Void
120
127
  # ----------------------------------------------------
121
- def self.success(m)
128
+ def self.success(m, log = true)
129
+ Methadone::CLILogging.info(m) if log
122
130
  puts "---> SUCCESS: #{ m }".green
123
131
  end
124
132
 
@@ -129,7 +137,8 @@ module SifttterRedux
129
137
  # @param m The message to output
130
138
  # @return Void
131
139
  # ----------------------------------------------------
132
- def self.warning(m)
140
+ def self.warning(m, log = true)
141
+ Methadone::CLILogging.warn(m) if log
133
142
  puts "---> WARNING: #{ m }".yellow
134
143
  end
135
144
  end
@@ -33,7 +33,9 @@ module SifttterRedux
33
33
  @data[section_name] = {}
34
34
  @data[section_name].merge!(hash)
35
35
  else
36
- fail ArgumentError, "Parameter is not a Hash: #{hash}"
36
+ error = "Parameter is not a Hash: #{hash}"
37
+ Methadone::CLILogging.error(error)
38
+ fail ArgumentError, error
37
39
  end
38
40
  end
39
41
 
@@ -48,7 +50,7 @@ module SifttterRedux
48
50
  if !self.section_exists?(section_name)
49
51
  @data[section_name] = {}
50
52
  else
51
- CliMessage.warning("Can't create already-existing section: #{section_name}")
53
+ CLIMessage.warning("Can't create already-existing section: #{section_name}")
52
54
  end
53
55
  end
54
56
 
@@ -73,7 +75,7 @@ module SifttterRedux
73
75
  if self.section_exists?(section_name)
74
76
  @data.delete(section_name)
75
77
  else
76
- CliMessage.warning("Can't delete non-existing section: #{section_name}")
78
+ CLIMessage.warning("Can't delete non-existing section: #{section_name}")
77
79
  end
78
80
  end
79
81
 
@@ -19,7 +19,11 @@ module SifttterRedux
19
19
  # @return Range
20
20
  # ------------------------------------------------------
21
21
  def self.last_n_days(num_days, include_today = false)
22
- fail ArgumentError, 'Cannot specify a negative number of days' if num_days < 0
22
+ if num_days < 0
23
+ error = 'Cannot specify a negative number of days'
24
+ Methadone::CLILogging.error(error)
25
+ fail ArgumentError, error
26
+ end
23
27
 
24
28
  if include_today
25
29
  (Date.today - num_days..Date.today)
@@ -38,7 +42,11 @@ module SifttterRedux
38
42
  # @return Range
39
43
  # ------------------------------------------------------
40
44
  def self.last_n_weeks(num_weeks = 0, include_today = false)
41
- fail ArgumentError, 'Cannot specify a negative number of weeks' if num_weeks < 0
45
+ if num_weeks < 0
46
+ error = 'Cannot specify a negative number of weeks'
47
+ Methadone::CLILogging.error(error)
48
+ fail ArgumentError, error
49
+ end
42
50
 
43
51
  beginning_date = Date.today - Date.today.wday + 1
44
52
  end_date = Date.today - Date.today.wday + 7
@@ -66,23 +74,39 @@ module SifttterRedux
66
74
  # @return Range
67
75
  # ------------------------------------------------------
68
76
  def self.range(start_date, end_date, include_today = false)
69
- fail ArgumentError, "You can't specify -t without specifying -f" if start_date.nil? && !end_date.nil?
77
+ if start_date.nil? && !end_date.nil?
78
+ error = "You can't specify -t without specifying -f"
79
+ Methadone::CLILogging.error(error)
80
+ fail ArgumentError, error
81
+ end
70
82
 
71
83
  begin
72
84
  chronic_start_date = Chronic.parse(start_date).to_date
73
85
  rescue
74
- fail ArgumentError, "Invalid date provided to Chronic: #{ start_date }" unless start_date.nil?
86
+ unless start_date.nil?
87
+ error = "Invalid date provided to Chronic: #{ start_date }"
88
+ Methadone::CLILogging.error(error)
89
+ fail ArgumentError, error
90
+ end
75
91
  nil
76
92
  end
77
93
 
78
94
  begin
79
95
  chronic_end_date = Chronic.parse(end_date).to_date
80
96
  rescue
81
- fail ArgumentError, "Invalid date provided to Chronic: #{ end_date }" unless end_date.nil?
97
+ unless end_date.nil?
98
+ error = "Invalid date provided to Chronic: #{ end_date }"
99
+ Methadone::CLILogging.error(error)
100
+ fail ArgumentError, error
101
+ end
82
102
  nil
83
103
  end
84
104
 
85
- fail ArgumentError, 'The start date must be before or equal to the end date' if chronic_end_date && chronic_start_date > chronic_end_date
105
+ if chronic_end_date && chronic_start_date > chronic_end_date
106
+ error = 'The start date must be before or equal to the end date'
107
+ Methadone::CLILogging.error(error)
108
+ fail ArgumentError, error
109
+ end
86
110
 
87
111
  unless chronic_start_date.nil?
88
112
  if chronic_end_date.nil?
@@ -17,7 +17,7 @@ module SifttterRedux
17
17
  # ----------------------------------------------------
18
18
  def self.download
19
19
  if !@local_path.nil? && !@remote_path.nil?
20
- CliMessage.info_block(@message ||= DEFAULT_MESSAGE, 'Done.', SifttterRedux.verbose) do
20
+ CLIMessage.info_block(@message ||= DEFAULT_MESSAGE, 'Done.', SifttterRedux.verbose) do
21
21
  if SifttterRedux.verbose
22
22
  system "#{ @dbu } download #{ @remote_path } #{ @local_path }"
23
23
  else
@@ -25,7 +25,9 @@ module SifttterRedux
25
25
  end
26
26
  end
27
27
  else
28
- fail ArgumentError, 'Local and remote DBU targets cannot be nil'
28
+ error = 'Local and remote DBU targets cannot be nil'
29
+ Methadone::CLILogging.error(error)
30
+ fail ArgumentError, error
29
31
  end
30
32
  end
31
33
 
@@ -39,10 +41,10 @@ module SifttterRedux
39
41
  def self.install_wizard
40
42
  valid_directory_chosen = false
41
43
 
42
- CliMessage.section_block('CONFIGURING DROPBOX UPLOADER...') do
44
+ CLIMessage.section_block('CONFIGURING DROPBOX UPLOADER...') do
43
45
  until valid_directory_chosen
44
46
  # Prompt the user for a location to save Dropbox Uploader. '
45
- path = CliMessage.prompt('Location for Dropbox-Uploader', DBU_LOCAL_FILEPATH)
47
+ path = CLIMessage.prompt('Location for Dropbox-Uploader', DBU_LOCAL_FILEPATH)
46
48
  path.chop! if path.end_with?('/')
47
49
  path = '/usr/local/opt' if path.empty?
48
50
 
@@ -52,15 +54,15 @@ module SifttterRedux
52
54
  path << '/Dropbox-Uploader'
53
55
 
54
56
  if File.directory?(path)
55
- CliMessage.warning("Using pre-existing Dropbox Uploader at #{ path }...")
57
+ CLIMessage.warning("Using pre-existing Dropbox Uploader at #{ path }...")
56
58
  else
57
- CliMessage.info_block("Downloading Dropbox Uploader to #{ path }...", 'Done.', true) do
59
+ CLIMessage.info_block("Downloading Dropbox Uploader to #{ path }...", 'Done.', true) do
58
60
  system "git clone https://github.com/andreafabrizi/Dropbox-Uploader.git #{ path }"
59
61
  end
60
62
  end
61
63
 
62
64
  # If the user has never configured Dropbox Uploader, have them do it here.
63
- system "#{ @dbu }" unless File.exists?(CONFIG_FILEPATH)
65
+ CLIMessage.info_block('Initializing Dropbox Uploader...') { system "#{ @dbu }" } unless File.exists?(CONFIG_FILEPATH)
64
66
 
65
67
  Configuration.add_section('db_uploader')
66
68
  Configuration['db_uploader'].merge!('local_filepath' => path)
@@ -127,7 +129,7 @@ module SifttterRedux
127
129
  # ----------------------------------------------------
128
130
  def self.upload
129
131
  if !@local_path.nil? && !@remote_path.nil?
130
- CliMessage.info_block(@message ||= DEFAULT_MESSAGE, 'Done.', SifttterRedux.verbose) do
132
+ CLIMessage.info_block(@message ||= DEFAULT_MESSAGE, 'Done.', SifttterRedux.verbose) do
131
133
  if SifttterRedux.verbose
132
134
  system "#{ @dbu } upload #{ @local_path } #{ @remote_path }"
133
135
  else
@@ -135,7 +137,9 @@ module SifttterRedux
135
137
  end
136
138
  end
137
139
  else
138
- fail ArgumentError, 'Local and remote DBU targets cannot be nil'
140
+ error = 'Local and remote DBU targets cannot be nil'
141
+ Methadone::CLILogging.error(error)
142
+ fail ArgumentError, error
139
143
  end
140
144
  end
141
145
  end
@@ -77,7 +77,7 @@ module SifttterRedux
77
77
  end
78
78
 
79
79
  if projects.length <=0
80
- CliMessage.warning('No entries found...')
80
+ CLIMessage.warning('No entries found...')
81
81
  end
82
82
 
83
83
  if projects.length > 0
@@ -91,7 +91,7 @@ module SifttterRedux
91
91
  fh = File.new(File.expand_path(Configuration['sifttter_redux']['dayone_local_filepath'] + '/' + uuid + '.doentry'), 'w+')
92
92
  fh.puts template.result(binding)
93
93
  fh.close
94
- CliMessage.success("Entry logged for #{ date_for_title }...")
94
+ CLIMessage.success("Entry logged for #{ date_for_title }...")
95
95
  end
96
96
  end
97
97
  end
@@ -1,3 +1,3 @@
1
1
  module SifttterRedux
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
@@ -24,4 +24,5 @@ spec = Gem::Specification.new do |s|
24
24
  s.add_development_dependency('rake', '~> 0')
25
25
  s.add_runtime_dependency('chronic', '0.10.2')
26
26
  s.add_runtime_dependency('gli','2.9.0')
27
+ s.add_runtime_dependency('methadone', '1.3.1')
27
28
  end
@@ -1,52 +1,55 @@
1
- require "test_helper"
2
- require File.join(File.dirname(__FILE__), "..", "lib/sifttter_redux/cli_message.rb")
1
+ require 'methadone'
2
+ require 'test_helper'
3
+ require File.join(File.dirname(__FILE__), '..', 'lib/sifttter_redux/cli_message.rb')
3
4
 
4
- class CliMessageTest < Test::Unit::TestCase
5
+ include Methadone::CLILogging
6
+
7
+ class CLIMessageTest < Test::Unit::TestCase
5
8
  def test_error_message
6
- assert_output('---> ERROR: test'.red + "\n") { SifttterRedux::CliMessage.error('test') }
9
+ assert_output('---> ERROR: test'.red + "\n") { SifttterRedux::CLIMessage.error('test', false) }
7
10
  end
8
11
 
9
12
  def test_info_message
10
- assert_output('---> INFO: test'.blue + "\n") { SifttterRedux::CliMessage.info('test') }
13
+ assert_output('---> INFO: test'.blue + "\n") { SifttterRedux::CLIMessage.info('test', false) }
11
14
  end
12
15
 
13
16
  def test_info_block_single_line
14
17
  assert_output("---> INFO: start".blue + "body\n" + 'end'.blue + "\n") do
15
- SifttterRedux::CliMessage.info_block('start', 'end') { puts 'body' }
18
+ SifttterRedux::CLIMessage.info_block('start', 'end', false, false) { puts 'body' }
16
19
  end
17
20
  end
18
21
 
19
22
  def test_info_block_multiline
20
23
  assert_output("---> INFO: start".blue + "\nbody\n" + '---> INFO: end'.blue + "\n") do
21
- SifttterRedux::CliMessage.info_block('start', 'end', true) { puts 'body' }
24
+ SifttterRedux::CLIMessage.info_block('start', 'end', true, false) { puts 'body' }
22
25
  end
23
26
  end
24
27
 
25
28
  def test_info_block_no_block
26
29
  assert_raise ArgumentError do
27
- SifttterRedux::CliMessage.info_block('start', 'end', true)
30
+ SifttterRedux::CLIMessage.info_block('start', 'end', true, false)
28
31
  end
29
32
  end
30
33
 
31
34
  def test_prompt
32
- assert_equal(SifttterRedux::CliMessage.prompt('Pick the default option', 'default'), 'default')
35
+ assert_equal(SifttterRedux::CLIMessage.prompt('Pick the default option', 'default'), 'default')
33
36
  end
34
37
 
35
38
  def test_section_message
36
- assert_output('#### test'.purple + "\n") { SifttterRedux::CliMessage.section('test') }
39
+ assert_output('#### test'.purple + "\n") { SifttterRedux::CLIMessage.section('test', false) }
37
40
  end
38
41
 
39
42
  def test_section_block_single_line
40
43
  assert_output("#### section".purple + "\nbody\n") do
41
- SifttterRedux::CliMessage.section_block('section', true) { puts 'body' }
44
+ SifttterRedux::CLIMessage.section_block('section', true, false) { puts 'body' }
42
45
  end
43
46
  end
44
47
 
45
48
  def test_success_message
46
- assert_output('---> SUCCESS: test'.green + "\n") { SifttterRedux::CliMessage.success('test') }
49
+ assert_output('---> SUCCESS: test'.green + "\n") { SifttterRedux::CLIMessage.success('test', false) }
47
50
  end
48
51
 
49
52
  def test_warning_message
50
- assert_output('---> WARNING: test'.yellow + "\n") { SifttterRedux::CliMessage.warning('test') }
53
+ assert_output('---> WARNING: test'.yellow + "\n") { SifttterRedux::CLIMessage.warning('test', false) }
51
54
  end
52
55
  end
@@ -1,5 +1,5 @@
1
- require "test_helper"
2
- require File.join(File.dirname(__FILE__), "..", "lib/sifttter_redux/configuration.rb")
1
+ require 'test_helper'
2
+ require File.join(File.dirname(__FILE__), '..', 'lib/sifttter_redux/configuration.rb')
3
3
 
4
4
  class ConfigurationTest < Test::Unit::TestCase
5
5
 
@@ -1,6 +1,6 @@
1
- require "date"
2
- require "test_helper"
3
- require File.join(File.dirname(__FILE__), "..", "lib/sifttter_redux/date_range_maker.rb")
1
+ require 'date'
2
+ require 'test_helper'
3
+ require File.join(File.dirname(__FILE__), '..', 'lib/sifttter_redux/date_range_maker.rb')
4
4
 
5
5
  class DateRangeMakerTest < Test::Unit::TestCase
6
6
  def test_today
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sifttter-redux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Bach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: methadone
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.1
55
69
  description: A customized IFTTT-to-Day One service that allows for smart installation
56
70
  and automated running on a standalone *NIX device (such as a Raspberry Pi).
57
71
  email: bachya1208@gmail.com