sifttter-redux 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +10 -0
- data/README.md +18 -12
- data/bin/srd +58 -149
- data/lib/sifttter_redux.rb +86 -40
- data/lib/sifttter_redux/cli_message.rb +3 -0
- data/lib/sifttter_redux/configuration.rb +4 -1
- data/lib/sifttter_redux/dbu.rb +17 -4
- data/lib/sifttter_redux/sifttter.rb +6 -5
- data/lib/sifttter_redux/version.rb +1 -1
- metadata +2 -3
- data/lib/sifttter_redux/os.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6089e8d0f4bb6e878a213306b36f3b1794ac7bbf
|
4
|
+
data.tar.gz: 8d429c68df6b8cb9d5cdb825baad4d96e5ff64c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0078c8d8e1253ba99f334d6d87d13bd1718db76f578d3ee2e4ac7acd3ff38c59c915d0ba98393b14e15772207a7ed50e0d1fc4c0ecb6dd8719412a1c5a9c8230
|
7
|
+
data.tar.gz: c4f4d97e124a3990a2e3d6fb541899d5f3a2b095fda56783699f13b5401e2c3c3fcf7212f57ecfd41a85a7b67b821fa88033675c21e0e0ba7d78feaf929f56c0
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 0.4.6 (2014-03-13)
|
2
|
+
|
3
|
+
* Added new error messaaging if Sifttter remote path is invalid
|
4
|
+
* Removed dependencies on exernal UUID library
|
5
|
+
* Removed OS module (not needed anymore)
|
6
|
+
|
7
|
+
# 0.4.5 (2014-03-01)
|
8
|
+
|
9
|
+
* Added Methadone logging for prompts
|
10
|
+
|
1
11
|
# 0.4.4 (2014-02-28)
|
2
12
|
|
3
13
|
* Fixed a prompt error when providing Dropbox-Uploader with a bad path
|
data/README.md
CHANGED
@@ -12,17 +12,7 @@ Siftter Redux has several fundamental differences:
|
|
12
12
|
|
13
13
|
# Prerequisites
|
14
14
|
|
15
|
-
In addition to Git (which, given you being on this site, I'll assume you have),
|
16
|
-
|
17
|
-
* Ruby (version 1.9.3 or greater)
|
18
|
-
* UUID (required on the Raspberry Pi because it doesn't come with a function to do this by default)
|
19
|
-
|
20
|
-
To install on a Debian-esque system:
|
21
|
-
|
22
|
-
```
|
23
|
-
$ sudo apt-get install ruby
|
24
|
-
$ sudo apt-get install uuid
|
25
|
-
```
|
15
|
+
In addition to Git (which, given you being on this site, I'll assume you have), Ruby (v. 1.9.3 or greater) is needed.
|
26
16
|
|
27
17
|
# Installation
|
28
18
|
|
@@ -47,7 +37,7 @@ SYNOPSIS
|
|
47
37
|
srd [global options] command [command options] [arguments...]
|
48
38
|
|
49
39
|
VERSION
|
50
|
-
0.4.
|
40
|
+
0.4.6
|
51
41
|
|
52
42
|
GLOBAL OPTIONS
|
53
43
|
--help - Show this message
|
@@ -97,6 +87,22 @@ Initialization will perform the following steps:
|
|
97
87
|
* The location on your filesystem where Day One files will be temporarily stored
|
98
88
|
* The location of your Day One files in Dropbox
|
99
89
|
|
90
|
+
## Pathing
|
91
|
+
|
92
|
+
Note that when Sifttter Redux asks you for paths, it will ask for "local" and "remote" filepaths. It's important to understand the difference.
|
93
|
+
|
94
|
+
### Local Filepaths
|
95
|
+
|
96
|
+
Local filepaths are, as you'd expect, filepaths on your local machine. Some examples might be:
|
97
|
+
|
98
|
+
* `/tmp/my_data`
|
99
|
+
* `/home/bob/ifttt/sifttter_data`
|
100
|
+
* `~/sifttter`
|
101
|
+
|
102
|
+
### Remote Filepaths
|
103
|
+
|
104
|
+
Remote filepaths, on the other hand, are absolute filepaths in your Dropbox folder (*as Dropbox Uploader would see them*). For instance, `/home/bob/Dropbox/apps/sifttter` is *not* a valid remote filepath; rather, `/apps/sifttter` would be correct.
|
105
|
+
|
100
106
|
## Basic Execution
|
101
107
|
|
102
108
|
```
|
data/bin/srd
CHANGED
@@ -32,209 +32,121 @@
|
|
32
32
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
33
33
|
# OTHER DEALINGS IN THE SOFTWARE.
|
34
34
|
#--------------------------------------------------------------------
|
35
|
-
|
36
|
-
require 'fileutils'
|
37
35
|
require 'gli'
|
38
36
|
require 'methadone'
|
39
37
|
require 'sifttter_redux'
|
38
|
+
require 'securerandom'
|
40
39
|
|
41
40
|
include GLI::App
|
42
41
|
include Methadone::CLILogging
|
43
42
|
include SifttterRedux
|
44
43
|
|
44
|
+
# ======================================================
|
45
|
+
# App Info
|
46
|
+
# ======================================================
|
45
47
|
program_desc 'Sifttter Redux
|
46
48
|
|
47
49
|
A customized IFTTT-to-Day One service that allows for
|
48
50
|
smart installation and automated running on a standalone
|
49
51
|
*NIX device (such as a Raspberry Pi).'
|
50
|
-
|
52
|
+
|
51
53
|
version VERSION
|
52
54
|
|
53
55
|
# ======================================================
|
54
56
|
# Global Flags and Switches
|
55
57
|
# ======================================================
|
56
|
-
|
57
|
-
switch(
|
58
|
-
[:verbose],
|
59
|
-
desc: 'Turns on verbose output'
|
60
|
-
)
|
58
|
+
switch([:verbose], desc: 'Turns on verbose output')
|
61
59
|
|
62
60
|
# ======================================================
|
63
61
|
# Pre, Post, and Error
|
64
62
|
# ======================================================
|
65
|
-
|
66
63
|
pre do |global, command, options, args|
|
67
|
-
|
68
64
|
# Load SifttterRedux configuration module.
|
69
65
|
Configuration::load(SRD_CONFIG_FILEPATH)
|
70
66
|
|
71
67
|
# Load Methadone CLILogging module.
|
72
|
-
Methadone::CLILogging::change_logger(Methadone::CLILogger.new(SRD_LOG_FILEPATH, SRD_LOG_FILEPATH))
|
68
|
+
Methadone::CLILogging::change_logger(Methadone::CLILogger.new(SRD_LOG_FILEPATH, SRD_LOG_FILEPATH))
|
73
69
|
|
74
70
|
if File.exists?(SRD_CONFIG_FILEPATH)
|
71
|
+
current_version = Gem::Version.new(Configuration['sifttter_redux']['version'])
|
72
|
+
last_config_change_version = Gem::Version.new(NEWEST_CONFIG_VERSION)
|
73
|
+
|
75
74
|
# If the config file needs updating, force the user to do that first.
|
76
|
-
if Configuration['sifttter_redux']['version'].nil? ||
|
75
|
+
if Configuration['sifttter_redux']['version'].nil? || current_version < last_config_change_version
|
77
76
|
CLIMessage::info('This version needs to make some config changes.')
|
78
|
-
CLIMessage::info("Don't worry; when prompted,
|
79
|
-
CLIMessage::
|
80
|
-
|
77
|
+
CLIMessage::info("Don't worry; when prompted, your current values for")
|
78
|
+
CLIMessage::info("existing config options will be presented (so it'll")
|
79
|
+
CLIMessage::info('be easier to fly through the upgrade).')
|
80
|
+
CLIMessage::prompt('Press enter to continue')
|
81
81
|
SifttterRedux::init(true)
|
82
82
|
exit!
|
83
83
|
end
|
84
|
+
|
85
|
+
# Load Dropbox Uploader module.
|
86
|
+
DBU.load(Configuration['db_uploader']['exe_filepath'])
|
84
87
|
else
|
85
|
-
# Force the user to
|
86
|
-
CLIMessage::info('
|
87
|
-
|
88
|
+
# Force the user to init if they try to run any command other than `init` first.
|
89
|
+
CLIMessage::info('Initializing Sifttter Redux first...') unless command.name_for_help[0] == 'init'
|
88
90
|
SifttterRedux::init
|
89
91
|
exit!
|
90
92
|
end
|
91
|
-
|
92
|
-
# Load Dropbox Uploader module.
|
93
|
-
DBU.load(Configuration['db_uploader']['exe_filepath']) if File.exists?(SRD_CONFIG_FILEPATH)
|
94
|
-
|
93
|
+
|
95
94
|
true
|
96
95
|
end
|
97
96
|
|
98
97
|
# ======================================================
|
99
98
|
# Commands
|
100
99
|
# ======================================================
|
101
|
-
|
102
100
|
# ------------------------------------------------------
|
103
101
|
# exec command
|
104
102
|
#
|
105
103
|
# Executes the script.
|
106
104
|
# ------------------------------------------------------
|
107
|
-
|
108
105
|
desc 'Execute the script'
|
109
106
|
command :exec do |c|
|
107
|
+
c.flag([:f], desc: 'Run catch-up mode with this start date')
|
108
|
+
c.flag([:n], desc: 'Run catch-up mode for the last N days')
|
109
|
+
c.flag([:t], desc: 'Run catch-up mode with this end date (must also have -f)')
|
110
|
+
c.flag([:w], desc: 'Run catch-up mode for the last N weeks')
|
110
111
|
|
111
|
-
c.
|
112
|
-
|
113
|
-
|
114
|
-
)
|
115
|
-
|
116
|
-
c.flag(
|
117
|
-
[:n],
|
118
|
-
desc: 'Run catch-up mode for the last N days'
|
119
|
-
)
|
120
|
-
|
121
|
-
c.flag(
|
122
|
-
[:t],
|
123
|
-
desc: 'Run catch-up mode with this end date (must also have -f)'
|
124
|
-
)
|
125
|
-
|
126
|
-
c.flag(
|
127
|
-
[:w],
|
128
|
-
desc: 'Run catch-up mode for the last N weeks'
|
129
|
-
)
|
130
|
-
|
131
|
-
c.switch(
|
132
|
-
[:c],
|
133
|
-
desc: 'Run catch-up mode from the beginning of the week to yesterday'
|
134
|
-
)
|
135
|
-
|
136
|
-
c.switch(
|
137
|
-
[:i],
|
138
|
-
desc: "Include today's date in catch-up"
|
139
|
-
)
|
140
|
-
|
141
|
-
c.switch(
|
142
|
-
[:verbose],
|
143
|
-
desc: 'Turns on verbose output'
|
144
|
-
)
|
145
|
-
|
146
|
-
c.switch(
|
147
|
-
[:y],
|
148
|
-
desc: 'Run catch-up mode for yesterday'
|
149
|
-
)
|
112
|
+
c.switch([:c], desc: 'Run catch-up mode from the beginning of the week to yesterday')
|
113
|
+
c.switch([:i], desc: "Include today's date in catch-up")
|
114
|
+
c.switch([:verbose], desc: 'Turns on verbose output')
|
115
|
+
c.switch([:y], desc: 'Run catch-up mode for yesterday')
|
150
116
|
|
151
117
|
c.action do |global_options, options, args|
|
152
|
-
|
153
118
|
SifttterRedux.verbose = global_options[:verbose] || options[:verbose]
|
154
119
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
120
|
+
dates = SifttterRedux::get_dates_from_options(options)
|
121
|
+
unless dates.nil?
|
122
|
+
first_date = dates.first
|
123
|
+
second_date = dates.reverse_each.first
|
159
124
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
command_complete = true
|
164
|
-
end
|
125
|
+
date_string = first_date.strftime('%B %d, %Y')
|
126
|
+
date_string << " to #{ second_date.strftime('%B %d, %Y') }" if first_date != second_date
|
127
|
+
CLIMessage::info("Creating #{ first_date == second_date ? 'entry' : 'entries' }: #{ date_string }")
|
165
128
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
129
|
+
# Download Sifttter files from Dropbox.
|
130
|
+
DBU.local_target = Configuration['sifttter_redux']['sifttter_local_filepath']
|
131
|
+
DBU.remote_target = Configuration['sifttter_redux']['sifttter_remote_filepath']
|
132
|
+
DBU.message = 'Downloading Sifttter files...'
|
133
|
+
DBU.download
|
171
134
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
command_complete = true
|
176
|
-
end
|
177
|
-
|
178
|
-
# Last N Weeks
|
179
|
-
if !command_complete && options[:w]
|
180
|
-
dates = DateRangeMaker.last_n_weeks(options[:w].to_i, options[:i])
|
181
|
-
command_complete = true
|
182
|
-
end
|
183
|
-
|
184
|
-
# Specific Range
|
185
|
-
if !command_complete && (options[:f] || options[:t])
|
186
|
-
begin
|
187
|
-
dates = DateRangeMaker.range(options[:f], options[:t], options[:i])
|
188
|
-
|
189
|
-
if dates.last > Date.today
|
190
|
-
CLIMessage::warning("Ignoring overextended end date and using today's date (#{ Date.today })")
|
191
|
-
dates = (dates.first..Date.today)
|
192
|
-
end
|
193
|
-
rescue ArgumentError => e
|
194
|
-
CLIMessage::error(e)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
else
|
198
|
-
dates = DateRangeMaker.today
|
135
|
+
# Process a new Sifttter entry for each date.
|
136
|
+
dates.each do |date|
|
137
|
+
Sifttter::run(date)
|
199
138
|
end
|
200
139
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
CLIMessage::info("Creating entry for #{ date_string }...")
|
208
|
-
else
|
209
|
-
date_string = "#{ first_date.strftime('%B %d, %Y') } to #{ second_date.strftime('%B %d, %Y') }"
|
210
|
-
CLIMessage::info("Creating entries for dates from #{ date_string }...")
|
211
|
-
end
|
212
|
-
|
213
|
-
DBU.local_target = Configuration['sifttter_redux']['sifttter_local_filepath']
|
214
|
-
DBU.remote_target = Configuration['sifttter_redux']['sifttter_remote_filepath']
|
215
|
-
DBU.message = 'Downloading Sifttter files...'
|
216
|
-
DBU.download
|
217
|
-
|
218
|
-
dates.each do |date|
|
219
|
-
Sifttter.run(date)
|
220
|
-
end
|
221
|
-
|
222
|
-
# Upload any Day One entries to Dropbox (if there are any).
|
223
|
-
unless Dir[Configuration['sifttter_redux']['dayone_local_filepath'] + '/*'].empty?
|
224
|
-
DBU.local_target = "#{ Configuration['sifttter_redux']['dayone_local_filepath'] }/*"
|
225
|
-
DBU.remote_target = Configuration['sifttter_redux']['dayone_remote_filepath']
|
226
|
-
DBU.message = 'Uploading Day One entries to Dropbox...'
|
227
|
-
DBU.upload
|
228
|
-
end
|
229
|
-
|
230
|
-
# Remove any downloaded local files that we no longer need.
|
231
|
-
dirs = [
|
232
|
-
Configuration['sifttter_redux']['dayone_local_filepath'],
|
233
|
-
Configuration['sifttter_redux']['sifttter_local_filepath']
|
234
|
-
]
|
235
|
-
|
236
|
-
CLIMessage::info_block('Removing temporary local files...') { dirs.each { |d| FileUtils.rm_rf(d) } }
|
140
|
+
# Upload any Day One entries to Dropbox (if there are any).
|
141
|
+
unless Dir[Configuration['sifttter_redux']['dayone_local_filepath'] + '/*'].empty?
|
142
|
+
DBU.local_target = "#{ Configuration['sifttter_redux']['dayone_local_filepath'] }/*"
|
143
|
+
DBU.remote_target = Configuration['sifttter_redux']['dayone_remote_filepath']
|
144
|
+
DBU.message = 'Uploading Day One entries to Dropbox...'
|
145
|
+
DBU.upload
|
237
146
|
end
|
147
|
+
|
148
|
+
# Remove any downloaded local files that we no longer need.
|
149
|
+
SifttterRedux::cleanup_temp_files
|
238
150
|
end
|
239
151
|
end
|
240
152
|
|
@@ -245,18 +157,15 @@ end
|
|
245
157
|
#
|
246
158
|
# Initializes the script.
|
247
159
|
# ------------------------------------------------------
|
248
|
-
desc 'Install and initialize dependencies'
|
160
|
+
desc 'Install and SifttterRedux::initialize dependencies'
|
249
161
|
command :init do |c|
|
250
|
-
|
251
|
-
|
252
|
-
[:s],
|
253
|
-
desc: 'Run init from scratch (i.e., clear out all values from configuration)'
|
254
|
-
)
|
255
|
-
|
162
|
+
c.switch([:s], desc: 'Run init from scratch (i.e., clear out all values from configuration)')
|
163
|
+
|
256
164
|
c.action do |global_options, options, args|
|
257
165
|
CLIMessage::section_block('INITIALIZING...') do
|
258
166
|
if File.exists?(Configuration::config_path) && !options[:s]
|
259
|
-
|
167
|
+
long_message = "You've already initialized Sifttter Redux. Do it again?"
|
168
|
+
SifttterRedux::init(true) if CLIMessage::prompt(long_message, 'N').downcase == 'y'
|
260
169
|
else
|
261
170
|
SifttterRedux::init
|
262
171
|
end
|
data/lib/sifttter_redux.rb
CHANGED
@@ -2,7 +2,6 @@ require 'sifttter_redux/cli_message.rb'
|
|
2
2
|
require 'sifttter_redux/configuration.rb'
|
3
3
|
require 'sifttter_redux/date_range_maker.rb'
|
4
4
|
require 'sifttter_redux/dbu.rb'
|
5
|
-
require 'sifttter_redux/os.rb'
|
6
5
|
require 'sifttter_redux/sifttter.rb'
|
7
6
|
require 'sifttter_redux/version.rb'
|
8
7
|
|
@@ -13,19 +12,84 @@ require 'sifttter_redux/version.rb'
|
|
13
12
|
# ======================================================
|
14
13
|
|
15
14
|
module SifttterRedux
|
15
|
+
attr_accessor :verbose
|
16
16
|
|
17
|
-
#
|
17
|
+
# ====================================================
|
18
18
|
# Constants
|
19
|
-
#
|
19
|
+
# ====================================================
|
20
20
|
DBU_LOCAL_FILEPATH = '/usr/local/opt'
|
21
|
-
|
21
|
+
|
22
22
|
DO_LOCAL_FILEPATH = '/tmp/dayone'
|
23
|
-
|
24
|
-
|
23
|
+
DO_REMOTE_FILEPATH = "/Apps/Day\\ One/Journal.dayone/entries"
|
24
|
+
|
25
25
|
SFT_LOCAL_FILEPATH = '/tmp/sifttter'
|
26
26
|
SFT_REMOTE_FILEPATH = '/Apps/ifttt/sifttter'
|
27
27
|
|
28
|
-
|
28
|
+
SRD_CONFIG_FILEPATH = File.join(ENV['HOME'], '.sifttter_redux')
|
29
|
+
SRD_LOG_FILEPATH = File.join(ENV['HOME'], '.sifttter_redux_log')
|
30
|
+
|
31
|
+
# ====================================================
|
32
|
+
# Methods
|
33
|
+
# ====================================================
|
34
|
+
# ----------------------------------------------------
|
35
|
+
# cleanup_temp_files method
|
36
|
+
#
|
37
|
+
# Removes temporary directories and their contents
|
38
|
+
# @return Void
|
39
|
+
# ----------------------------------------------------
|
40
|
+
def self.cleanup_temp_files
|
41
|
+
dirs = [
|
42
|
+
Configuration['sifttter_redux']['dayone_local_filepath'],
|
43
|
+
Configuration['sifttter_redux']['sifttter_local_filepath']
|
44
|
+
]
|
45
|
+
|
46
|
+
CLIMessage::info_block('Removing temporary local files...') { dirs.each { |d| FileUtils.rm_rf(d) } }
|
47
|
+
end
|
48
|
+
|
49
|
+
# ----------------------------------------------------
|
50
|
+
# get_dates_from_options method
|
51
|
+
#
|
52
|
+
# Creates a date range from the supplied command line
|
53
|
+
# options.
|
54
|
+
# @param options A Hash of command line options
|
55
|
+
# @return Range
|
56
|
+
# ----------------------------------------------------
|
57
|
+
def self.get_dates_from_options(options)
|
58
|
+
CLIMessage::section_block('EXECUTING...') do
|
59
|
+
if options[:c] || options[:n] || options[:w] || options[:y] || options[:f] || options[:t]
|
60
|
+
# Yesterday
|
61
|
+
DateRangeMaker.yesterday if options[:y]
|
62
|
+
|
63
|
+
# Current Week
|
64
|
+
DateRangeMaker.last_n_weeks(0, options[:i]) if options[:c]
|
65
|
+
|
66
|
+
# Last N Days
|
67
|
+
DateRangeMaker.last_n_days(options[:n].to_i, options[:i]) if options[:n]
|
68
|
+
|
69
|
+
# Last N Weeks
|
70
|
+
DateRangeMaker.last_n_weeks(options[:w].to_i, options[:i]) if options[:w]
|
71
|
+
|
72
|
+
# Custom Range
|
73
|
+
if (options[:f] || options[:t])
|
74
|
+
begin
|
75
|
+
_dates = DateRangeMaker.range(options[:f], options[:t], options[:i])
|
76
|
+
|
77
|
+
if _dates.last > Date.today
|
78
|
+
long_message = "Ignoring overextended end date and using today's date (#{ Date.today })..."
|
79
|
+
CLIMessage::warning(long_message)
|
80
|
+
(_dates.first..Date.today)
|
81
|
+
else
|
82
|
+
(_dates.first.._dates.last)
|
83
|
+
end
|
84
|
+
rescue ArgumentError => e
|
85
|
+
CLIMessage::error(e)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
else
|
89
|
+
DateRangeMaker.today
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
29
93
|
|
30
94
|
# ----------------------------------------------------
|
31
95
|
# initialize_procedures method
|
@@ -34,72 +98,54 @@ module SifttterRedux
|
|
34
98
|
# collecting all necessary items and info.
|
35
99
|
# @return Void
|
36
100
|
# ----------------------------------------------------
|
37
|
-
def self.init(
|
38
|
-
|
39
|
-
|
101
|
+
def self.init(reinit = false)
|
102
|
+
unless reinit
|
103
|
+
Configuration::reset
|
104
|
+
Configuration::add_section('sifttter_redux')
|
105
|
+
end
|
40
106
|
Configuration['sifttter_redux'].merge!('version' => VERSION, 'config_location' => Configuration::config_path)
|
41
107
|
|
42
108
|
# Run the wizard to download Dropbox Uploader.
|
43
|
-
DBU::install_wizard(
|
109
|
+
DBU::install_wizard(reinit = reinit)
|
44
110
|
|
45
111
|
# Collect other misc. preferences.
|
46
112
|
CLIMessage::section_block('COLLECTING PREFERENCES...') do
|
47
113
|
pref_prompts = [
|
48
114
|
{
|
49
115
|
prompt: 'Location for downloaded Sifttter files from Dropbox',
|
50
|
-
default:
|
116
|
+
default: SFT_LOCAL_FILEPATH,
|
51
117
|
key: 'sifttter_local_filepath',
|
52
118
|
section: 'sifttter_redux'
|
53
119
|
},
|
54
120
|
{
|
55
121
|
prompt: 'Location of Sifttter files in Dropbox',
|
56
|
-
default:
|
122
|
+
default: SFT_REMOTE_FILEPATH,
|
57
123
|
key: 'sifttter_remote_filepath',
|
58
124
|
section: 'sifttter_redux'
|
59
125
|
},
|
60
126
|
{
|
61
127
|
prompt: 'Location for downloaded Day One files from Dropbox',
|
62
|
-
default:
|
128
|
+
default: DO_LOCAL_FILEPATH,
|
63
129
|
key: 'dayone_local_filepath',
|
64
130
|
section: 'sifttter_redux'
|
65
131
|
},
|
66
132
|
{
|
67
133
|
prompt: 'Location of Day One files in Dropbox',
|
68
|
-
default:
|
134
|
+
default: DO_REMOTE_FILEPATH,
|
69
135
|
key: 'dayone_remote_filepath',
|
70
136
|
section: 'sifttter_redux'
|
71
137
|
}
|
72
138
|
]
|
73
139
|
|
74
140
|
pref_prompts.each do |prompt|
|
75
|
-
|
76
|
-
|
141
|
+
d = reinit ? Configuration[prompt[:section]][prompt[:key]] : prompt[:default]
|
142
|
+
pref = CLIMessage::prompt(prompt[:prompt], d)
|
143
|
+
|
144
|
+
Configuration[prompt[:section]].merge!(prompt[:key] => File.expand_path(pref))
|
77
145
|
end
|
78
146
|
end
|
79
|
-
|
147
|
+
|
80
148
|
Methadone::CLILogging.info("Configuration values: #{ Configuration::dump }")
|
81
|
-
|
82
149
|
Configuration::save
|
83
150
|
end
|
84
|
-
|
85
|
-
# ----------------------------------------------------
|
86
|
-
# verbose method
|
87
|
-
#
|
88
|
-
# Returns the verbosity state.
|
89
|
-
# @return Bool
|
90
|
-
# ----------------------------------------------------
|
91
|
-
def self.verbose
|
92
|
-
@verbose_output
|
93
|
-
end
|
94
|
-
|
95
|
-
# ----------------------------------------------------
|
96
|
-
# verbose= method
|
97
|
-
#
|
98
|
-
# Sets the verbosity state.
|
99
|
-
# @return Void
|
100
|
-
# ----------------------------------------------------
|
101
|
-
def self.verbose=(verbose)
|
102
|
-
@verbose_output = verbose
|
103
|
-
end
|
104
|
-
|
105
151
|
end
|
@@ -6,6 +6,9 @@ module SifttterRedux
|
|
6
6
|
# Singleton to manage common CLI interfacing
|
7
7
|
# ======================================================
|
8
8
|
module CLIMessage
|
9
|
+
# ====================================================
|
10
|
+
# Methods
|
11
|
+
# ====================================================
|
9
12
|
# ----------------------------------------------------
|
10
13
|
# error method
|
11
14
|
#
|
@@ -8,6 +8,9 @@ module SifttterRedux
|
|
8
8
|
# into which they get stored.
|
9
9
|
# ======================================================
|
10
10
|
module Configuration
|
11
|
+
# ====================================================
|
12
|
+
# Methods
|
13
|
+
# ====================================================
|
11
14
|
# ----------------------------------------------------
|
12
15
|
# [] method
|
13
16
|
#
|
@@ -29,7 +32,7 @@ module SifttterRedux
|
|
29
32
|
# []= method
|
30
33
|
#
|
31
34
|
# Assigns the passed hash to the section. NOTE THAT THE
|
32
|
-
# PREVIOUS CONTENTS OF THAT SECTION ARE
|
35
|
+
# PREVIOUS CONTENTS OF THAT SECTION ARE OVERWRITTEN.
|
33
36
|
# @param section_name The section in which to look
|
34
37
|
# @param hash The Hash that gets merged into the section
|
35
38
|
# @return Void
|
data/lib/sifttter_redux/dbu.rb
CHANGED
@@ -5,9 +5,15 @@ module SifttterRedux
|
|
5
5
|
# Wrapper module for the Dropbox Uploader project
|
6
6
|
# ======================================================
|
7
7
|
module DBU
|
8
|
+
# ====================================================
|
9
|
+
# Constants
|
10
|
+
# ====================================================
|
8
11
|
CONFIG_FILEPATH = File.join(ENV['HOME'], '.dropbox_uploader')
|
9
12
|
DEFAULT_MESSAGE = 'RUNNING DROPBOX UPLOADER'
|
10
13
|
|
14
|
+
# ====================================================
|
15
|
+
# Methods
|
16
|
+
# ====================================================
|
11
17
|
# ----------------------------------------------------
|
12
18
|
# download method
|
13
19
|
#
|
@@ -38,13 +44,18 @@ module SifttterRedux
|
|
38
44
|
# local filesystem.
|
39
45
|
# @return Void
|
40
46
|
# ----------------------------------------------------
|
41
|
-
def self.install_wizard(
|
47
|
+
def self.install_wizard(reinit = false)
|
42
48
|
valid_path_chosen = false
|
43
49
|
|
44
50
|
CLIMessage::section_block('CONFIGURING DROPBOX UPLOADER...') do
|
45
51
|
until valid_path_chosen
|
46
52
|
# Prompt the user for a location to save Dropbox Uploader.
|
47
|
-
|
53
|
+
if reinit && !Configuration['db_uploader']['base_filepath'].nil?
|
54
|
+
default = Configuration['db_uploader']['base_filepath']
|
55
|
+
else
|
56
|
+
default = DBU_LOCAL_FILEPATH
|
57
|
+
end
|
58
|
+
path = CLIMessage::prompt('Location for Dropbox-Uploader', default)
|
48
59
|
path.chop! if path.end_with?('/')
|
49
60
|
|
50
61
|
# If the entered directory exists, clone the repository.
|
@@ -63,9 +74,11 @@ module SifttterRedux
|
|
63
74
|
end
|
64
75
|
|
65
76
|
# If the user has never configured Dropbox Uploader, have them do it here.
|
66
|
-
|
77
|
+
unless File.exists?(CONFIG_FILEPATH)
|
78
|
+
CLIMessage::info_block('Initializing Dropbox Uploader...') { system "#{ executable_path }" }
|
79
|
+
end
|
67
80
|
|
68
|
-
Configuration::add_section('db_uploader') unless
|
81
|
+
Configuration::add_section('db_uploader') unless reinit
|
69
82
|
Configuration['db_uploader'].merge!('base_filepath' => path, 'dbu_filepath' => dbu_path, 'exe_filepath' => executable_path)
|
70
83
|
else
|
71
84
|
CLIMessage::error("Sorry, but #{ path } isn't a valid directory.")
|
@@ -5,8 +5,6 @@ module SifttterRedux
|
|
5
5
|
# Wrapper module for Sifttter itself
|
6
6
|
# ======================================================
|
7
7
|
module Sifttter
|
8
|
-
include SifttterRedux::OS
|
9
|
-
|
10
8
|
# ----------------------------------------------------
|
11
9
|
# run_sifttter method
|
12
10
|
#
|
@@ -18,9 +16,7 @@ module SifttterRedux
|
|
18
16
|
# @return Void
|
19
17
|
# ----------------------------------------------------
|
20
18
|
def self.run(date)
|
21
|
-
|
22
|
-
uuid_command = 'uuid' if OS.linux?
|
23
|
-
uuid = %x{#{ uuid_command }}.gsub(/-/, '').strip
|
19
|
+
uuid = SecureRandom.uuid.upcase.gsub(/-/, '').strip
|
24
20
|
|
25
21
|
date_for_title = date.strftime('%B %d, %Y')
|
26
22
|
datestamp = date.to_time.utc.iso8601
|
@@ -51,6 +47,11 @@ module SifttterRedux
|
|
51
47
|
time_regex = "(?:\d{1,2}:\d{1,2}\s?[AaPpMm]{2})"
|
52
48
|
|
53
49
|
files = `find #{ Configuration['sifttter_redux']['sifttter_local_filepath'] } -type f -name "*.txt" | grep -v -i daily | sort`
|
50
|
+
if files.empty?
|
51
|
+
m = "Couldn't download Sifttter files; is #{ Configuration['sifttter_redux']['sifttter_remote_filepath'] } the correct remote filepath?"
|
52
|
+
CLIMessage.error(m)
|
53
|
+
return
|
54
|
+
end
|
54
55
|
|
55
56
|
projects = []
|
56
57
|
files.split("\n").each do |file|
|
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.4.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -90,7 +90,6 @@ files:
|
|
90
90
|
- lib/sifttter_redux/configuration.rb
|
91
91
|
- lib/sifttter_redux/date_range_maker.rb
|
92
92
|
- lib/sifttter_redux/dbu.rb
|
93
|
-
- lib/sifttter_redux/os.rb
|
94
93
|
- lib/sifttter_redux/sifttter.rb
|
95
94
|
- lib/sifttter_redux/string_extensions.rb
|
96
95
|
- lib/sifttter_redux/version.rb
|
data/lib/sifttter_redux/os.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
module SifttterRedux
|
2
|
-
# ======================================================
|
3
|
-
# OS Module
|
4
|
-
#
|
5
|
-
# Module to easily find the running operating system
|
6
|
-
# ======================================================
|
7
|
-
module OS
|
8
|
-
# ----------------------------------------------------
|
9
|
-
# linux? method
|
10
|
-
#
|
11
|
-
# Returns true if the host OS is Linux.
|
12
|
-
# @return Bool
|
13
|
-
# ----------------------------------------------------
|
14
|
-
def OS.linux?
|
15
|
-
self.unix? and not self.mac?
|
16
|
-
end
|
17
|
-
|
18
|
-
# ----------------------------------------------------
|
19
|
-
# mac? method
|
20
|
-
#
|
21
|
-
# Returns true if the host OS is OS X.
|
22
|
-
# @return Bool
|
23
|
-
# ----------------------------------------------------
|
24
|
-
def OS.mac?
|
25
|
-
!(/darwin/ =~ RUBY_PLATFORM).nil?
|
26
|
-
end
|
27
|
-
|
28
|
-
# ----------------------------------------------------
|
29
|
-
# unix? method
|
30
|
-
#
|
31
|
-
# Returns true if the host OS is Unix.
|
32
|
-
# @return Bool
|
33
|
-
# ----------------------------------------------------
|
34
|
-
def OS.unix?
|
35
|
-
!self.windows?
|
36
|
-
end
|
37
|
-
|
38
|
-
# ----------------------------------------------------
|
39
|
-
# windows? method
|
40
|
-
#
|
41
|
-
# Returns true if the host OS is Windows
|
42
|
-
# @return Bool
|
43
|
-
# ----------------------------------------------------
|
44
|
-
def OS.windows?
|
45
|
-
!(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|