sifttter-redux 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_helper.rb CHANGED
@@ -5,5 +5,5 @@ require 'test/unit'
5
5
  class Test::Unit::TestCase
6
6
 
7
7
  # Add global extensions to the test case class here
8
-
8
+
9
9
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sifttter-redux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
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-16 00:00:00.000000000 Z
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.10.2
41
- - !ruby/object:Gem::Dependency
42
- name: colored
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: '1.2'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: '1.2'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: gli
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,8 +52,8 @@ dependencies:
66
52
  - - '='
67
53
  - !ruby/object:Gem::Version
68
54
  version: 2.9.0
69
- description: Sifttter Redux is a modification of Craig Eley's Sifttter that allows
70
- for smart installation on a standalone *NIX device (such as a Raspberry Pi).
55
+ description: A customized IFTTT-to-Day One service that allows for smart installation
56
+ and automated running on a standalone *NIX device (such as a Raspberry Pi).
71
57
  email: bachya1208@gmail.com
72
58
  executables:
73
59
  - srd
@@ -77,21 +63,23 @@ extra_rdoc_files:
77
63
  - HISTORY.md
78
64
  - LICENSE
79
65
  files:
80
- - .gitignore
66
+ - ".gitignore"
81
67
  - Gemfile
82
68
  - HISTORY.md
83
69
  - LICENSE
84
70
  - README.md
85
71
  - Rakefile
86
72
  - bin/srd
87
- - lib/sifttter-redux.rb
88
- - lib/sifttter-redux/cli-message.rb
89
- - lib/sifttter-redux/config-manager.rb
90
- - lib/sifttter-redux/constants.rb
91
- - lib/sifttter-redux/date-range-maker.rb
92
- - lib/sifttter-redux/methods.rb
93
- - lib/sifttter-redux/os.rb
94
- - sifttter-redux.gemspec
73
+ - lib/sifttter_redux.rb
74
+ - lib/sifttter_redux/cli_message.rb
75
+ - lib/sifttter_redux/configuration.rb
76
+ - lib/sifttter_redux/date_range_maker.rb
77
+ - lib/sifttter_redux/dbu.rb
78
+ - lib/sifttter_redux/extensions.rb
79
+ - lib/sifttter_redux/os.rb
80
+ - lib/sifttter_redux/sifttter.rb
81
+ - lib/sifttter_redux/version.rb
82
+ - sifttter_redux.gemspec
95
83
  - test/catch_up_test.rb
96
84
  - test/test_helper.rb
97
85
  homepage: https://github.com/bachya/sifttter-redux
@@ -100,18 +88,18 @@ licenses:
100
88
  metadata: {}
101
89
  post_install_message:
102
90
  rdoc_options:
103
- - --charset=UTF-8
91
+ - "--charset=UTF-8"
104
92
  require_paths:
105
93
  - lib
106
94
  - lib
107
95
  required_ruby_version: !ruby/object:Gem::Requirement
108
96
  requirements:
109
- - - ! '>='
97
+ - - ">="
110
98
  - !ruby/object:Gem::Version
111
99
  version: '0'
112
100
  required_rubygems_version: !ruby/object:Gem::Requirement
113
101
  requirements:
114
- - - ! '>='
102
+ - - ">="
115
103
  - !ruby/object:Gem::Version
116
104
  version: '0'
117
105
  requirements: []
@@ -123,3 +111,4 @@ summary: Automated IFTTT to Day One engine.
123
111
  test_files:
124
112
  - test/catch_up_test.rb
125
113
  - test/test_helper.rb
114
+ has_rdoc:
@@ -1,6 +0,0 @@
1
- require 'sifttter-redux/cli-message.rb'
2
- require 'sifttter-redux/config-manager.rb'
3
- require 'sifttter-redux/constants.rb'
4
- require 'sifttter-redux/date-range-maker.rb'
5
- require 'sifttter-redux/methods.rb'
6
- require 'sifttter-redux/os.rb'
@@ -1,135 +0,0 @@
1
- #| ======================================================
2
- #| CliManager Module
3
- #| Singleton to manage common CLI interfacing
4
- #| ======================================================
5
- module CliMessage
6
-
7
- ERROR = 1
8
- INFO = 2
9
- SECTION = 3
10
- WARNING = 4
11
-
12
- #| ------------------------------------------------------
13
- #| error method
14
- #|
15
- #| Outputs a formatted-red error message.
16
- #| @param message The message to output
17
- #| @return Void
18
- #| ------------------------------------------------------
19
- def self.error(message, addNewline = true)
20
- if addNewline
21
- puts "---> ERROR: #{message}".red
22
- else
23
- print "---> ERROR: #{message}".red
24
- end
25
-
26
- @@last_message_type = ERROR
27
- end
28
-
29
- #| ------------------------------------------------------
30
- #| finish_message method
31
- #|
32
- #| Finishes a previous message by appending "DONE" in the
33
- #| correct color.
34
- #| @return Void
35
- #| ------------------------------------------------------
36
- def self.finish_message(message)
37
- case @@last_message_type
38
- when ERROR
39
- puts message.red
40
- when INFO
41
- puts message.blue
42
- when SECTION
43
- puts message.green
44
- when WARNING
45
- puts message.yellow
46
- end
47
- end
48
-
49
- #| ------------------------------------------------------
50
- #| info method
51
- #|
52
- #| Outputs a formatted-blue informational message.
53
- #| @param message The message to output
54
- #| @return Void
55
- #| ------------------------------------------------------
56
- def self.info(message, addNewline = true)
57
- if addNewline
58
- puts "---> INFO: #{message}".blue
59
- else
60
- print "---> INFO: #{message}".blue
61
- end
62
-
63
- @@last_message_type = INFO
64
- end
65
-
66
- #| ------------------------------------------------------
67
- #| prompt method
68
- #|
69
- #| Outputs a prompt, collects the user's response, and
70
- #| returns it.
71
- #| @param prompt The prompt to output
72
- #| @param default The default option
73
- #| @return String
74
- #| ------------------------------------------------------
75
- def self.prompt(prompt, default)
76
- print "#{prompt} [default: #{default}]: "
77
- choice = $stdin.gets.chomp
78
- if choice.empty?
79
- return default
80
- else
81
- return choice
82
- end
83
- end
84
-
85
- #| ------------------------------------------------------
86
- #| section method
87
- #|
88
- #| Outputs a formatted-orange section message.
89
- #| @param message The message to output
90
- #| @return Void
91
- #| ------------------------------------------------------
92
- def self.section(message, addNewline = true)
93
- if addNewline
94
- puts "#### #{message}".green
95
- else
96
- print "#### #{message}".green
97
- end
98
-
99
- @@last_message_type = SECTION
100
- end
101
-
102
- #| ------------------------------------------------------
103
- #| success method
104
- #|
105
- #| Outputs a formatted-green success message.
106
- #| @param message The message to output
107
- #| @return Void
108
- #| ------------------------------------------------------
109
- def self.success(message, addNewline = true)
110
- if addNewline
111
- puts "---> SUCCESS: #{message}".green
112
- else
113
- print "---> SUCCESS: #{message}".green
114
- end
115
-
116
- @@last_message_type = WARNING
117
- end
118
-
119
- #| ------------------------------------------------------
120
- #| warning method
121
- #|
122
- #| Outputs a formatted-yellow warning message.
123
- #| @param message The message to output
124
- #| @return Void
125
- #| ------------------------------------------------------
126
- def self.warning(message, addNewline = true)
127
- if addNewline
128
- puts "---> WARNING: #{message}".yellow
129
- else
130
- print "---> WARNING: #{message}".yellow
131
- end
132
-
133
- @@last_message_type = WARNING
134
- end
135
- end
@@ -1,136 +0,0 @@
1
- require 'singleton'
2
-
3
- #| ======================================================
4
- #| ConfigManager Class
5
- #|
6
- #| Singleton to manage the YAML config file
7
- #| for this script
8
- #| ======================================================
9
-
10
- class ConfigManager
11
- include Singleton
12
-
13
- attr_accessor :configFile
14
-
15
- #| ------------------------------------------------------
16
- #| initialize method
17
- #|
18
- #| Initializes this singleton with data from the config
19
- #| file. If the file doesn't exist, an empty hash is
20
- #| created in anticipation of future config saves.
21
- #| @return Void
22
- #| ------------------------------------------------------
23
- def initialize
24
- @configFile = SifttterRedux::SRD_CONFIG_FILEPATH
25
-
26
- if File.exists?(SifttterRedux::SRD_CONFIG_FILEPATH)
27
- @data = YAML.load_file(SifttterRedux::SRD_CONFIG_FILEPATH)
28
- @data.each do |k, v|
29
- define_singleton_method(k) { return v }
30
- end
31
- else
32
- @data = {}
33
- end
34
- end
35
-
36
- #| ------------------------------------------------------
37
- #| _dump method
38
- #|
39
- #| Convenience method that dumps the configuration hash's
40
- #| data.
41
- #| @return Void
42
- #| ------------------------------------------------------
43
- def _dump
44
- puts @data
45
- end
46
-
47
- #| ------------------------------------------------------
48
- #| add_to_section method
49
- #|
50
- #| Adds a hash to the configuration data.
51
- #| @param hash The hash to add to configuration
52
- #| @param section The section into which the hash goes
53
- #| @return Void
54
- #| ------------------------------------------------------
55
- def add_to_section(hash, section)
56
- unless @data.has_key?(section)
57
- CliMessage.warning("Attempting to insert into a non-existing section: #{section}; skipping...")
58
- return
59
- end
60
-
61
- @data[section].merge!(hash)
62
- end
63
-
64
- #| ------------------------------------------------------
65
- #| create_section method
66
- #|
67
- #| Creates a new section in the configuration hash.
68
- #| @param section The section to create
69
- #| @return Void
70
- #| ------------------------------------------------------
71
- def create_section(section)
72
- if @data.has_key?(section)
73
- CliMessage.warning("Attempting to create existing section (#{section}); skipping...")
74
- return
75
- end
76
-
77
- define_singleton_method(section) { return @data[section] }
78
- @data.merge!(section => {})
79
- end
80
-
81
- #| ------------------------------------------------------
82
- #| delete_section method
83
- #|
84
- #| Deletes a section in the configuration hash.
85
- #| @param section The section to delete
86
- #| @return Void
87
- #| ------------------------------------------------------
88
- def delete_section(section)
89
- unless @data.has_key?(section)
90
- CliMessage.warning("Attempting to delete non-existing section (#{section}); skipping...")
91
- return
92
- end
93
-
94
- remove_singleton_method(section)
95
- @data.delete(section)
96
- end
97
-
98
- #| ------------------------------------------------------
99
- #| remove_singleton_method method
100
- #|
101
- #| Removes a hash from the configuration data based on
102
- #| its key.
103
- #| @param hash The hash key remove
104
- #| @param section The section from which the key comes
105
- #| @return Void
106
- #| ------------------------------------------------------
107
- def remove_from_section(key, section)
108
- unless @data.has_key?(section) && @data[section].has_key?(key)
109
- CliMessage.warning("Attempting to remove a non-existing key: #{section}.#{key}; skipping...")
110
- return
111
- end
112
-
113
- @data[section].delete(key)
114
- end
115
-
116
- #| ------------------------------------------------------
117
- #| reset method
118
- #|
119
- #| Clears out the configuration data by resetting the hash.
120
- #| @return Void
121
- #| ------------------------------------------------------
122
- def reset
123
- @data = {}
124
- end
125
-
126
- #| ------------------------------------------------------
127
- #| save_configuration method
128
- #|
129
- #| Saves the configuration data to the filesystem.
130
- #| @return File
131
- #| ------------------------------------------------------
132
- def save_configuration
133
- return File.open(@configFile, 'w') { |f| f.write(@data.to_yaml) }
134
- end
135
-
136
- end
@@ -1,15 +0,0 @@
1
- module SifttterRedux
2
- VERSION = "0.3.1"
3
-
4
- # Sifttter and Sifttter Redux Constants
5
- SRD_CONFIG_FILEPATH = File.join(ENV['HOME'], '.sifttter_redux')
6
- SFT_LOCAL_FILEPATH = "/tmp/sifttter"
7
- SFT_REMOTE_FILEPATH = "/Apps/ifttt/sifttter"
8
-
9
- # Dropbox Upload Constants
10
- DBU_LOCAL_FILEPATH = "/usr/local/opt"
11
-
12
- # Day One Constants
13
- DO_REMOTE_FILEPATH = "/Apps/Day\\ One/Journal.dayone/entries"
14
- DO_LOCAL_FILEPATH = "/tmp/dayone"
15
- end
@@ -1,208 +0,0 @@
1
- require 'chronic'
2
-
3
- #| ======================================================
4
- #| DateRangeMakerError Class
5
- #| ======================================================
6
- class DateRangeMakerError < StandardError
7
- def initialize(msg = "You've triggered a DateRangeMakerError")
8
- super
9
- end
10
- end
11
-
12
- #| ======================================================
13
- #| BadChronicDateError Class
14
- #| ======================================================
15
- class BadChronicDateError < DateRangeMakerError
16
- def initialize(msg = "Invalid date provided to Chronic...")
17
- super
18
- end
19
- end
20
-
21
- #| ======================================================
22
- #| BadDateOrderError Class
23
- #| ======================================================
24
- class BadDateOrderError < DateRangeMakerError
25
- def initialize(msg = "The start date must be before or equal to the end date...")
26
- super
27
- end
28
- end
29
-
30
- #| ======================================================
31
- #| InvalidFlagsError Class
32
- #| ======================================================
33
- class InvalidFlagsError < DateRangeMakerError
34
- def initialize(msg = "You can't specify -t without specifying -f...")
35
- super
36
- end
37
- end
38
-
39
- #| ======================================================
40
- #| NegativeDaysError Class
41
- #| ======================================================
42
- class NegativeDaysError < DateRangeMakerError
43
- def initialize(msg = "You must specify a positive number of days to look back...")
44
- super
45
- end
46
- end
47
-
48
- #| ======================================================
49
- #| DateRangeMaker Class
50
- #|
51
- #| Singleton to manage the YAML config file
52
- #| for this script
53
- #| ======================================================
54
- class DateRangeMaker
55
-
56
- #| ------------------------------------------------------
57
- #| initialize method
58
- #| @return Void
59
- #| ------------------------------------------------------
60
- def initialize
61
-
62
- end
63
-
64
- #| ------------------------------------------------------
65
- #| last_n_days method
66
- #|
67
- #| Returns a date range for the last N days (including
68
- #| today's date if specified).
69
- #| @param num_days The number of days to look back
70
- #| @param options Miscellaneous options hash
71
- #| @return Range
72
- #| ------------------------------------------------------
73
- def last_n_days(num_days, options = {})
74
- raise NegativeDaysError if num_days < 0
75
-
76
- opts = {
77
- :include_today => false
78
- }
79
-
80
- options.each do |k, v|
81
- k = k.to_sym
82
- raise ArgumentError, "Unknown property: #{k}" unless opts.key?(k)
83
- opts[k] = v
84
- end
85
-
86
- if (opts[:include_today])
87
- _r = (Date.today - num_days..Date.today)
88
- else
89
- _r = (Date.today - num_days...Date.today)
90
- end
91
-
92
- return _r
93
- end
94
-
95
- #| ------------------------------------------------------
96
- #| last_n_weeks method
97
- #|
98
- #| Returns a date range for the last N weeks (including
99
- #| today's date if specified).
100
- #| @param num_days The number of weeks to look back
101
- #| @param options Miscellaneous options hash
102
- #| @return Range
103
- #| ------------------------------------------------------
104
- def last_n_weeks(num_weeks = 0, options = {})
105
- raise NegativeDaysError if num_weeks < 0
106
-
107
- opts = {
108
- :include_today => false
109
- }
110
-
111
- options.each do |k, v|
112
- k = k.to_sym
113
- raise ArgumentError, "Unknown property: #{k}" unless opts.key?(k)
114
- opts[k] = v
115
- end
116
-
117
- beginning_date = Date.today - Date.today.wday + 1
118
- end_date = Date.today - Date.today.wday + 7
119
-
120
- # We're currently before the end of the week, so
121
- # reset the new ending date to today.
122
- if (end_date > Date.today)
123
- end_date = Date.today
124
- end
125
-
126
- if (opts[:include_today])
127
- _r = (beginning_date - num_weeks * 7..end_date)
128
- else
129
- _r = (beginning_date - num_weeks * 7...end_date)
130
- end
131
-
132
- return _r
133
- end
134
-
135
- #| ------------------------------------------------------
136
- #| range method
137
- #|
138
- #| Returns a date range for specified start dates and
139
- #| end dates. Note that specifying an end date greater
140
- #| than today's date will force today to be the end date.
141
- #| @param start_date The start date
142
- #| @param end_date The end date
143
- #| @param options Miscellaneous options hash
144
- #| @return Range
145
- #| ------------------------------------------------------
146
- def range(start_date, end_date, options = {})
147
- opts = {
148
- :include_today => false
149
- }
150
-
151
- options.each do |k, v|
152
- k = k.to_sym
153
- raise ArgumentError, "Unknown property: #{k}" unless opts.key?(k)
154
- opts[k] = v
155
- end
156
-
157
- begin
158
- chronic_start_date = Chronic.parse(start_date).to_date
159
- rescue
160
- raise BadChronicDateError.new("Invalid date provided to Chronic: #{start_date}") if !start_date.nil?
161
- nil
162
- end
163
-
164
- begin
165
- chronic_end_date = Chronic.parse(end_date).to_date
166
- rescue
167
- raise BadChronicDateError.new("Invalid date provided to Chronic: #{end_date}") if !end_date.nil?
168
- nil
169
- end
170
-
171
- raise InvalidFlagsError.new if (start_date.nil? && !end_date.nil?)
172
- raise BadDateOrderError.new if (chronic_end_date && chronic_start_date > chronic_end_date)
173
-
174
- if (!chronic_start_date.nil?)
175
- if (chronic_end_date.nil?)
176
- if (opts[:include_today])
177
- dates = (chronic_start_date..Date.today)
178
- else
179
- dates = (chronic_start_date...Date.today)
180
- end
181
- else
182
- dates = (chronic_start_date..chronic_end_date)
183
- end
184
- end
185
-
186
- return dates
187
- end
188
-
189
- #| ------------------------------------------------------
190
- #| today method
191
- #|
192
- #| Returns a date range for today
193
- #| @return Range
194
- #| ------------------------------------------------------
195
- def today
196
- return (Date.today..Date.today)
197
- end
198
-
199
- #| ------------------------------------------------------
200
- #| yesterday method
201
- #|
202
- #| Returns a date range for yesterday
203
- #| @return Range
204
- #| ------------------------------------------------------
205
- def yesterday
206
- return (Date.today - 1..Date.today - 1)
207
- end
208
- end