sifttter-redux 0.3.1 → 0.3.2
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 +5 -13
- data/HISTORY.md +8 -2
- data/README.md +3 -3
- data/bin/srd +158 -155
- data/lib/sifttter_redux.rb +105 -0
- data/lib/sifttter_redux/cli_message.rb +126 -0
- data/lib/sifttter_redux/configuration.rb +122 -0
- data/lib/sifttter_redux/date_range_maker.rb +120 -0
- data/lib/sifttter_redux/dbu.rb +138 -0
- data/lib/sifttter_redux/extensions.rb +65 -0
- data/lib/sifttter_redux/os.rb +48 -0
- data/lib/sifttter_redux/sifttter.rb +98 -0
- data/lib/sifttter_redux/version.rb +3 -0
- data/{sifttter-redux.gemspec → sifttter_redux.gemspec} +4 -5
- data/test/catch_up_test.rb +51 -55
- data/test/test_helper.rb +1 -1
- metadata +21 -32
- data/lib/sifttter-redux.rb +0 -6
- data/lib/sifttter-redux/cli-message.rb +0 -135
- data/lib/sifttter-redux/config-manager.rb +0 -136
- data/lib/sifttter-redux/constants.rb +0 -15
- data/lib/sifttter-redux/date-range-maker.rb +0 -208
- data/lib/sifttter-redux/methods.rb +0 -188
- data/lib/sifttter-redux/os.rb +0 -47
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NmEwNjIwMDQxZGVmZDkwNzA1ZDE2ZWJmMGYzM2NjN2MyOTUyYzVhZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7a7651a47fcd93ff3150a17b949fd50c4ca1c85
|
4
|
+
data.tar.gz: 24ea7968b26c83f2e4a54d166da41a56690cb2ed
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NGQxYTg4YTUzYmFhOWI5NThiMDRhZjkxZWRhYzZkN2QyYThlMGVhNDJlNDcx
|
11
|
-
Y2ExM2E1OWE3MTUxYWJhYzRjZjQxODY2NWIyYjU0Y2I2MzBlNWI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZGQ5N2QwNDM2MTAyZmFkY2VjYjg5OWQ3NTdhYTdkNDA2OWQ0MTY4M2Q0YjU2
|
14
|
-
ZDNmNmE1NTJlMTU0N2MyODdlMzBkNDM2MDU1ZmI1NTE4N2RkNDdkMjMwMjNi
|
15
|
-
MDY2YjQ4NzJiMDYyNDZkZTY2YjNlYjMxNzFiYWQ1NGRmMGNhMWE=
|
6
|
+
metadata.gz: 89c8c7e370f1cc517d787a82a15267ab993cc7dc36e29898652af7e5463dc05f9efead2b249291dd3a4dce40b8d7d57aa24d36f663bb280c7ed870b4f1cdc8a0
|
7
|
+
data.tar.gz: 875ee4c39c7a8b7345cb54bf9a1edafce183fb7c4740281ddc7f45c557ead91df07e4332882111571a83b36ceda6712e305b86e0ae53b0224481799994b48650
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 0.3.2 (2014-02-20)
|
2
|
+
|
3
|
+
* Added verbose flag
|
4
|
+
* Big refactorings = much nicer, more modular code
|
5
|
+
* Removed dependency on colored gem
|
6
|
+
|
1
7
|
# 0.3.1
|
2
8
|
|
3
9
|
* Removed reliance on Rails methods for first-and-last-day-of-week calculations
|
@@ -21,7 +27,7 @@
|
|
21
27
|
# 0.2.4 (originally 0.2.3)
|
22
28
|
|
23
29
|
* Updated some help documentation
|
24
|
-
* Changed message re: no entries found to a warning state
|
30
|
+
* Changed message re: no entries found to a warning state
|
25
31
|
|
26
32
|
# 0.2.2
|
27
33
|
|
@@ -32,7 +38,7 @@
|
|
32
38
|
* Fixed a bug where the config manager would fail on certain platforms
|
33
39
|
* Fixed a bug where the path to Dropbox Uploader became malformed
|
34
40
|
|
35
|
-
# 0.2.0
|
41
|
+
# 0.2.0
|
36
42
|
|
37
43
|
* Implemented catch-up mode
|
38
44
|
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Sifttter Redux
|
2
2
|
==============
|
3
3
|
|
4
|
-
Siftter Redux is a modification of Craig Eley's [Sifttter](http://craigeley.com/post/72565974459/sifttter-an-ifttt-to-day-one-logger "Sifttter"), a script to collect information from [IFTTT](http://www.ifttt.com "IFTTT") and place it in a [Day One](http://dayoneapp.com, "Day One") journal.
|
4
|
+
Siftter Redux is a modification of Craig Eley's [Sifttter](http://craigeley.com/post/72565974459/sifttter-an-ifttt-to-day-one-logger "Sifttter"), a script to collect information from [IFTTT](http://www.ifttt.com "IFTTT") and place it in a [Day One](http://dayoneapp.com, "Day One") journal.
|
5
5
|
|
6
6
|
Siftter Redux's primary difference is in its execution method: it intended to run autonomously so that it does not need to be manually activated. This allows IFTTT data to be synchronized to Day One on a schedule.
|
7
7
|
|
@@ -69,7 +69,7 @@ Initialization will perform the following steps:
|
|
69
69
|
2. The location of your Sifttter files in Dropbox
|
70
70
|
3. The location on your filesystem where Day One files will be temporarily stored
|
71
71
|
4. The location of your Day One files in Dropbox
|
72
|
-
|
72
|
+
|
73
73
|
### Basic Execution
|
74
74
|
|
75
75
|
```
|
@@ -385,8 +385,8 @@ $ bundle install --global
|
|
385
385
|
|
386
386
|
Some functionality I would like to tackle for future releases:
|
387
387
|
|
388
|
+
* Plugin architecture for services that IFTTT doesn't support
|
388
389
|
* Interactive cron job installer
|
389
|
-
* Verbose mode that more explicity tells the user what's currently going on
|
390
390
|
* Smarter checking of the config file to see if an old version is being used
|
391
391
|
|
392
392
|
## Bugs and Feature Requests
|
data/bin/srd
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# Encoding: utf-8
|
3
|
+
#--------------------------------------------------------------------
|
3
4
|
# Sifttter Redux
|
4
5
|
#
|
5
|
-
# A modification of Craig Eley's Sifttter that allows for smart
|
6
|
-
# device (such as a Raspberry Pi).
|
6
|
+
# A modification of Craig Eley's Sifttter that allows for smart
|
7
|
+
# installation on a standalone *NIX device (such as a Raspberry Pi).
|
7
8
|
#
|
8
9
|
# Sifttter copyright Craig Eley 2014 <http://craigeley.com>
|
9
10
|
#
|
10
11
|
# Copyright (c) 2014
|
11
12
|
# Aaron Bach <bachya1208@gmail.com>
|
12
|
-
#
|
13
|
+
#
|
13
14
|
# Permission is hereby granted, free of charge, to any person
|
14
15
|
# obtaining a copy of this software and associated documentation
|
15
16
|
# files (the "Software"), to deal in the Software without
|
@@ -18,10 +19,10 @@
|
|
18
19
|
# copies of the Software, and to permit persons to whom the
|
19
20
|
# Software is furnished to do so, subject to the following
|
20
21
|
# conditions:
|
21
|
-
#
|
22
|
+
#
|
22
23
|
# The above copyright notice and this permission notice shall be
|
23
24
|
# included in all copies or substantial portions of the Software.
|
24
|
-
#
|
25
|
+
#
|
25
26
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
26
27
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
27
28
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -30,206 +31,208 @@
|
|
30
31
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
31
32
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
32
33
|
# OTHER DEALINGS IN THE SOFTWARE.
|
33
|
-
|
34
|
+
#--------------------------------------------------------------------
|
34
35
|
|
35
|
-
require 'colored'
|
36
36
|
require 'fileutils'
|
37
37
|
require 'gli'
|
38
|
-
require '
|
39
|
-
require 'time'
|
40
|
-
require 'yaml'
|
38
|
+
require 'sifttter_redux'
|
41
39
|
|
42
40
|
include GLI::App
|
43
|
-
|
44
|
-
program_desc "Sifttter Redux
|
45
|
-
|
46
|
-
A modification of Craig Eley's Sifttter (an IFTTT-to-Day One service)
|
47
|
-
that allows for smart installation and automated running on a standalone
|
48
|
-
*NIX device (such as a Raspberry Pi)."
|
49
|
-
|
50
41
|
version SifttterRedux::VERSION
|
42
|
+
program_desc 'Sifttter Redux
|
43
|
+
|
44
|
+
A customized IFTTT-to-Day One service that allows for
|
45
|
+
smart installation and automated running on a standalone
|
46
|
+
*NIX device (such as a Raspberry Pi).'
|
47
|
+
|
48
|
+
# ======================================================
|
49
|
+
# Global Flags and Switches
|
50
|
+
# ======================================================
|
51
|
+
|
52
|
+
switch(
|
53
|
+
[:verbose],
|
54
|
+
desc: 'Turns on verbose output'
|
55
|
+
)
|
56
|
+
|
57
|
+
# ======================================================
|
58
|
+
# Pre, Post, and Error
|
59
|
+
# ======================================================
|
60
|
+
|
61
|
+
pre do |global, command, options, args|
|
62
|
+
SifttterRedux::Configuration.load(SifttterRedux::SRD_CONFIG_FILEPATH)
|
63
|
+
SifttterRedux::DBU.load(
|
64
|
+
File.join(
|
65
|
+
SifttterRedux::Configuration['db_uploader']['local_filepath'],
|
66
|
+
'dropbox_uploader.sh'
|
67
|
+
)
|
68
|
+
)
|
51
69
|
|
52
|
-
|
53
|
-
#| Pre, Post, and Error
|
54
|
-
#| ======================================================
|
55
|
-
|
56
|
-
pre do |global,command,options,args|
|
57
|
-
$config = ConfigManager.instance
|
58
|
-
$date_range_maker = DateRangeMaker.new
|
59
|
-
|
60
|
-
if !File.exists?(SifttterRedux::SRD_CONFIG_FILEPATH)
|
61
|
-
CliMessage.info("It doesn't look like you've initlized Sifttter Redux yet. Doing that now...")
|
62
|
-
initialize_procedures
|
63
|
-
end
|
64
|
-
|
65
|
-
$db_uploader = File.join($config.db_uploader["local_filepath"], "dropbox_uploader.sh")
|
66
|
-
true
|
67
|
-
end
|
68
|
-
|
69
|
-
post do |global,command,options,args|
|
70
|
-
# Post logic here
|
71
|
-
# Use skips_post before a command to skip this
|
72
|
-
# block on that command only
|
73
|
-
end
|
74
|
-
|
75
|
-
on_error do |exception|
|
76
|
-
# Error logic here
|
77
|
-
# return false to skip default error handling
|
70
|
+
init unless File.exists?(SifttterRedux::SRD_CONFIG_FILEPATH)
|
78
71
|
true
|
79
72
|
end
|
80
73
|
|
81
|
-
|
82
|
-
|
83
|
-
|
74
|
+
# ======================================================
|
75
|
+
# Commands
|
76
|
+
# ======================================================
|
84
77
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
78
|
+
# ------------------------------------------------------
|
79
|
+
# exec command
|
80
|
+
#
|
81
|
+
# Executes the script.
|
82
|
+
# ------------------------------------------------------
|
90
83
|
|
91
84
|
desc 'Execute the script'
|
92
|
-
command :exec do |c|
|
93
|
-
|
85
|
+
command :exec do |c|
|
86
|
+
|
94
87
|
c.flag(
|
95
88
|
[:f],
|
96
|
-
:
|
89
|
+
desc: 'Run catch-up mode with this start date'
|
97
90
|
)
|
98
|
-
|
91
|
+
|
99
92
|
c.flag(
|
100
93
|
[:n],
|
101
|
-
:
|
94
|
+
desc: 'Run catch-up mode for the last N days'
|
102
95
|
)
|
103
|
-
|
96
|
+
|
104
97
|
c.flag(
|
105
98
|
[:t],
|
106
|
-
:
|
99
|
+
desc: 'Run catch-up mode with this end date (must also have -f)'
|
107
100
|
)
|
108
|
-
|
101
|
+
|
109
102
|
c.flag(
|
110
103
|
[:w],
|
111
|
-
:
|
104
|
+
desc: 'Run catch-up mode for the last N weeks'
|
112
105
|
)
|
113
|
-
|
106
|
+
|
114
107
|
c.switch(
|
115
108
|
[:c],
|
116
|
-
:
|
109
|
+
desc: 'Run catch-up mode from the beginning of the week to yesterday'
|
117
110
|
)
|
118
|
-
|
111
|
+
|
119
112
|
c.switch(
|
120
113
|
[:i],
|
121
|
-
:
|
114
|
+
desc: "Include today's date in catch-up"
|
122
115
|
)
|
123
|
-
|
116
|
+
|
117
|
+
c.switch(
|
118
|
+
[:verbose],
|
119
|
+
desc: 'Turns on verbose output'
|
120
|
+
)
|
121
|
+
|
124
122
|
c.switch(
|
125
123
|
[:y],
|
126
|
-
:
|
124
|
+
desc: 'Run catch-up mode for yesterday'
|
127
125
|
)
|
128
|
-
|
126
|
+
|
129
127
|
c.action do |global_options, options, args|
|
130
|
-
command_complete = false
|
131
128
|
|
132
|
-
|
133
|
-
|
134
|
-
if (options[:c] || options[:n] || options[:w] || options[:y] || options[:f] || options[:t])
|
129
|
+
SifttterRedux.verbose = global_options[:verbose] || options[:verbose]
|
135
130
|
|
136
|
-
|
137
|
-
if
|
138
|
-
|
139
|
-
command_complete =
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
131
|
+
SifttterRedux::CliMessage.section_block('EXECUTING...') do
|
132
|
+
if options[:c] || options[:n] || options[:w] || options[:y] || options[:f] || options[:t]
|
133
|
+
|
134
|
+
command_complete = false
|
135
|
+
|
136
|
+
# Current Week
|
137
|
+
if !command_complete && options[:c]
|
138
|
+
dates = SifttterRedux::DateRangeMaker.last_n_weeks(0, options[:i])
|
139
|
+
command_complete = true
|
140
|
+
end
|
141
|
+
|
142
|
+
# Last N Days
|
143
|
+
if !command_complete && options[:n]
|
144
|
+
dates = SifttterRedux::DateRangeMaker.last_n_days(options[:n].to_i, options[:i])
|
145
|
+
command_complete = true
|
146
|
+
end
|
147
|
+
|
148
|
+
# Yesterday
|
149
|
+
if !command_complete && options[:y]
|
150
|
+
dates = SifttterRedux::DateRangeMaker.yesterday
|
151
|
+
command_complete = true
|
152
|
+
end
|
153
|
+
|
154
|
+
# Last N Weeks
|
155
|
+
if !command_complete && options[:w]
|
156
|
+
dates = SifttterRedux::DateRangeMaker.last_n_weeks(options[:w].to_i, options[:i])
|
157
|
+
command_complete = true
|
158
|
+
end
|
159
|
+
|
160
|
+
# Specific Range
|
161
|
+
if !command_complete && (options[:f] || options[:t])
|
162
|
+
begin
|
163
|
+
dates = SifttterRedux::DateRangeMaker.from_to(options[:f], options[:t], options[:i])
|
164
|
+
|
165
|
+
if dates.last > Date.today
|
166
|
+
SifttterRedux::CliMessage.warning("Ignoring overextended end date and using today's date (#{ Date.today })")
|
167
|
+
dates = (dates.first..Date.today)
|
168
|
+
end
|
169
|
+
rescue ArgumentError => e
|
170
|
+
SifttterRedux::CliMessage.error(e)
|
168
171
|
end
|
169
|
-
rescue DateRangeMakerError
|
170
|
-
CliMessage.error($!)
|
171
172
|
end
|
172
|
-
command_complete = true
|
173
|
-
end
|
174
|
-
else
|
175
|
-
dates = $date_range_maker.today
|
176
|
-
command_complete = true
|
177
|
-
end
|
178
|
-
|
179
|
-
if (!dates.nil?)
|
180
|
-
first_date = dates.first
|
181
|
-
second_date = dates.reverse_each.first
|
182
|
-
|
183
|
-
if (first_date == second_date)
|
184
|
-
CliMessage.info("Creating entry for #{first_date.strftime('%B %d, %Y')}...")
|
185
173
|
else
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
download_sifttter_files
|
190
|
-
|
191
|
-
dates.each do |date|
|
192
|
-
run_sifttter(date)
|
174
|
+
dates = SifttterRedux::DateRangeMaker.today
|
193
175
|
end
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
176
|
+
|
177
|
+
unless dates.nil?
|
178
|
+
first_date = dates.first
|
179
|
+
second_date = dates.reverse_each.first
|
180
|
+
|
181
|
+
if first_date == second_date
|
182
|
+
date_string = first_date.strftime('%B %d, %Y')
|
183
|
+
SifttterRedux::CliMessage.info("Creating entry for #{ date_string }...")
|
184
|
+
else
|
185
|
+
date_string = "#{ first_date.strftime('%B %d, %Y') } to #{ second_date.strftime('%B %d, %Y') }"
|
186
|
+
SifttterRedux::CliMessage.info("Creating entries for dates from #{ date_string }...")
|
187
|
+
end
|
188
|
+
|
189
|
+
SifttterRedux::DBU.local_target = '/tmp/sifttter'
|
190
|
+
SifttterRedux::DBU.remote_target = '/Apps/ifttt/sifttter'
|
191
|
+
SifttterRedux::DBU.message = 'Downloading Sifttter files...'
|
192
|
+
SifttterRedux::DBU.download
|
193
|
+
|
194
|
+
dates.each do |date|
|
195
|
+
SifttterRedux::Sifttter.run(date)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Upload any Day One entries to Dropbox (if there are any).
|
199
|
+
unless Dir[SifttterRedux::Configuration['sifttter_redux']['dayone_local_filepath'] + '/*'].empty?
|
200
|
+
SifttterRedux::DBU.local_target = "#{SifttterRedux::Configuration['sifttter_redux']['dayone_local_filepath']}/*"
|
201
|
+
SifttterRedux::DBU.remote_target = SifttterRedux::Configuration['sifttter_redux']['dayone_remote_filepath']
|
202
|
+
SifttterRedux::DBU.message = 'Uploading Day One entries to Dropbox...'
|
203
|
+
SifttterRedux::DBU.upload
|
204
|
+
end
|
205
|
+
|
206
|
+
# Remove any downloaded local files that we no longer need.
|
207
|
+
dirs = [
|
208
|
+
SifttterRedux::Configuration['sifttter_redux']['dayone_local_filepath'],
|
209
|
+
SifttterRedux::Configuration['sifttter_redux']['sifttter_local_filepath']
|
210
|
+
]
|
211
|
+
|
212
|
+
SifttterRedux::CliMessage.info_block('Removing temporary local files...') { dirs.each { |d| FileUtils.rm_rf(d) } }
|
200
213
|
end
|
201
|
-
|
202
|
-
# Remove any downloaded local files that we no longer need.
|
203
|
-
CliMessage.info("Removing downloaded Day One files...", false)
|
204
|
-
FileUtils.rm_rf($config.sifttter_redux["dayone_local_filepath"]) if Dir.exists?($config.sifttter_redux["dayone_local_filepath"])
|
205
|
-
CliMessage.finish_message('DONE.')
|
206
|
-
|
207
|
-
CliMessage.info("Removing downloaded Sifttter files...", false)
|
208
|
-
FileUtils.rm_rf($config.sifttter_redux["sifttter_local_filepath"]) if Dir.exists?($config.sifttter_redux["sifttter_local_filepath"])
|
209
|
-
CliMessage.finish_message('DONE.')
|
210
214
|
end
|
211
|
-
|
212
|
-
CliMessage.section('EXECUTION COMPLETE!')
|
213
215
|
end
|
216
|
+
|
214
217
|
end
|
215
218
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
219
|
+
# ------------------------------------------------------
|
220
|
+
# init command
|
221
|
+
#
|
222
|
+
# Initializes the script.
|
223
|
+
# ------------------------------------------------------
|
221
224
|
desc 'Install and initialize dependencies'
|
222
225
|
command :init do |c|
|
223
226
|
c.action do |global_options, options, args|
|
224
|
-
CliMessage.section('INITIALIZING...')
|
225
227
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
228
|
+
SifttterRedux::CliMessage.section_block('INITIALIZING...') do
|
229
|
+
if File.exists?(SifttterRedux::Configuration.config_path)
|
230
|
+
SifttterRedux.init if SifttterRedux::CliMessage.prompt("It looks like you've already initialized Sifttter Redux. Do you want to re-initialize?", 'N').downcase == 'y'
|
231
|
+
else
|
232
|
+
SifttterRedux.init
|
233
|
+
end
|
230
234
|
end
|
231
|
-
|
232
|
-
CliMessage.section('INITIALIZATION COMPLETE!')
|
235
|
+
|
233
236
|
end
|
234
237
|
end
|
235
238
|
|