neufelry-twitter-sms 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/{twitter-sms.rb → checker.rb} +14 -10
- data/test/test_checker.rb +23 -0
- data/test/test_helper.rb +3 -2
- data/test/test_logger.rb +0 -0
- metadata +14 -4
- data/test/twitter_sms_test.rb +0 -7
data/VERSION.yml
CHANGED
@@ -22,6 +22,8 @@ module TwitterSms
|
|
22
22
|
|
23
23
|
class Checker
|
24
24
|
|
25
|
+
attr_reader :config
|
26
|
+
|
25
27
|
def initialize(config_file="#{ENV['HOME']}/.twitter-sms.conf", args=ARGV)
|
26
28
|
load_config(config_file)
|
27
29
|
load_opts(args) # Loaded options are intended to overide defaults
|
@@ -163,7 +165,6 @@ module TwitterSms
|
|
163
165
|
# Parse and store a config file (either as an initial load or as
|
164
166
|
# an update)
|
165
167
|
def load_config(config_file=@config_file['name'])
|
166
|
-
# Load config file -- Add try block here
|
167
168
|
loaded_config = YAML.load_file(config_file)
|
168
169
|
@config_file = { 'name' => config_file,
|
169
170
|
'modified_at' => File.mtime(config_file) }
|
@@ -172,23 +173,26 @@ module TwitterSms
|
|
172
173
|
@user = loaded_config['user']
|
173
174
|
@bot = loaded_config['bot']
|
174
175
|
|
176
|
+
# Extract this to YAML defaults file
|
175
177
|
config_defaults = { 'own_tweets' => false,
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
178
|
+
'keep_alive' => true,
|
179
|
+
'per_hour' => 30,
|
180
|
+
'debug' => false,
|
181
|
+
'dont_refresh' => false,
|
182
|
+
'active' => true,
|
183
|
+
'log_to' => 'file'}
|
182
184
|
|
183
185
|
# Merge specified config onto defaults
|
184
|
-
@config
|
186
|
+
@config = config_defaults.merge(loaded_config['config'])
|
185
187
|
|
186
188
|
set_wait
|
189
|
+
|
190
|
+
# Manually set "last_check" so update actually pulls prior tweets
|
187
191
|
@last_check = Time.now - @config['wait']
|
188
192
|
putd "Loaded config file"
|
189
193
|
end
|
190
194
|
|
191
|
-
#
|
195
|
+
# @config['wait'] is the number of seconds to wait
|
192
196
|
def set_wait
|
193
197
|
@config['wait'] = SEC_PER_HOUR / @config['per_hour']
|
194
198
|
end
|
@@ -244,7 +248,7 @@ module TwitterSms
|
|
244
248
|
"#{tweet.user.screen_name}: #{CGI.escapeHTML(tweet.text)}"
|
245
249
|
end
|
246
250
|
|
247
|
-
def self.
|
251
|
+
def self.filename_to_ary(path)
|
248
252
|
path.split('/')[-1]
|
249
253
|
end
|
250
254
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class CheckerTest < Test::Unit::TestCase
|
4
|
+
def test_truth
|
5
|
+
assert(true)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_space_stripper_removes_space
|
9
|
+
str = <<EOS
|
10
|
+
The line below has just one space
|
11
|
+
|
12
|
+
The line above has just one space
|
13
|
+
EOS
|
14
|
+
correct_str = <<EOS
|
15
|
+
The line below has just one space
|
16
|
+
|
17
|
+
The line above has just one space
|
18
|
+
EOS
|
19
|
+
TwitterSms::space_stripper!(str)
|
20
|
+
assert_equal(str,correct_str)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -3,8 +3,9 @@ require 'test/unit'
|
|
3
3
|
require 'shoulda'
|
4
4
|
require 'mocha'
|
5
5
|
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
require '
|
6
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
|
7
|
+
require 'checker'
|
8
|
+
require 'logger'
|
8
9
|
|
9
10
|
class Test::Unit::TestCase
|
10
11
|
end
|
data/test/test_logger.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neufelry-twitter-sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Neufeld
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-03 00:00:00 -08:00
|
13
13
|
default_executable: twitter-sms
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,6 +30,15 @@ dependencies:
|
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: "0"
|
32
32
|
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rmail
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
33
42
|
description: Twitter-SMS provides a persistent command line tool to send SMS updates to your mobile phone via a gmail account.
|
34
43
|
email: neufelry@gmail.com
|
35
44
|
executables:
|
@@ -42,10 +51,11 @@ files:
|
|
42
51
|
- README.md
|
43
52
|
- VERSION.yml
|
44
53
|
- bin/twitter-sms
|
54
|
+
- lib/checker.rb
|
45
55
|
- lib/logger.rb
|
46
|
-
-
|
56
|
+
- test/test_checker.rb
|
47
57
|
- test/test_helper.rb
|
48
|
-
- test/
|
58
|
+
- test/test_logger.rb
|
49
59
|
has_rdoc: true
|
50
60
|
homepage: http://github.com/neufelry/twitter-sms
|
51
61
|
post_install_message:
|
data/test/twitter_sms_test.rb
DELETED