twuckoo 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5084628fd99ac6c36ce572e0c30a150233c2dec6
4
+ data.tar.gz: e360bfc8272a1917a14e315464d14e27792d1e1f
5
+ SHA512:
6
+ metadata.gz: a0073530575514f57b11df36a845de30f400dde5c9fe0d6e2ba7e98b0ba8434026c32d76b649d6c37e09cf9791bc1b330a5641ff28452cff704d0fb6e83c1558
7
+ data.tar.gz: 699706841b081c8ec39cd1a8f018b4acdcb6ff986e2dfce0166662299ae6b6869e8a8951692ffa7841078190df83f407fb84d77d71aa8e3a5e897236451b8f7e
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ twuckoo (0.5.2)
5
+ hpricot (>= 0.6.164)
6
+ mail (>= 1.6.0)
7
+ tlsmail (>= 0.0.1)
8
+ twitter_oauth (~> 0.4.94)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ coderay (1.0.9)
14
+ columnize (0.3.6)
15
+ debugger (1.6.1)
16
+ columnize (>= 0.3.1)
17
+ debugger-linecache (~> 1.2.0)
18
+ debugger-ruby_core_source (~> 1.2.3)
19
+ debugger-linecache (1.2.0)
20
+ debugger-ruby_core_source (1.2.3)
21
+ diff-lcs (1.1.3)
22
+ ffi (1.9.0)
23
+ guard (1.5.4)
24
+ listen (>= 0.4.2)
25
+ lumberjack (>= 1.0.2)
26
+ pry (>= 0.9.10)
27
+ thor (>= 0.14.6)
28
+ guard-rspec (2.3.3)
29
+ guard (>= 1.1)
30
+ rspec (~> 2.11)
31
+ hpricot (0.8.6)
32
+ json (1.8.0)
33
+ listen (1.2.2)
34
+ rb-fsevent (>= 0.9.3)
35
+ rb-inotify (>= 0.9)
36
+ rb-kqueue (>= 0.2)
37
+ lumberjack (1.0.4)
38
+ mail (2.5.4)
39
+ mime-types (~> 1.16)
40
+ treetop (~> 1.4.8)
41
+ metaclass (0.0.1)
42
+ method_source (0.8.1)
43
+ mime-types (1.23)
44
+ mocha (0.14.0)
45
+ metaclass (~> 0.0.1)
46
+ oauth (0.4.7)
47
+ polyglot (0.3.3)
48
+ pry (0.9.12.2)
49
+ coderay (~> 1.0.5)
50
+ method_source (~> 0.8)
51
+ slop (~> 3.4)
52
+ rake (10.1.0)
53
+ rb-fsevent (0.9.3)
54
+ rb-inotify (0.9.0)
55
+ ffi (>= 0.5.0)
56
+ rb-kqueue (0.2.0)
57
+ ffi (>= 0.5.0)
58
+ rspec (2.12.0)
59
+ rspec-core (~> 2.12.0)
60
+ rspec-expectations (~> 2.12.0)
61
+ rspec-mocks (~> 2.12.0)
62
+ rspec-core (2.12.2)
63
+ rspec-expectations (2.12.1)
64
+ diff-lcs (~> 1.1.3)
65
+ rspec-mocks (2.12.2)
66
+ slop (3.4.5)
67
+ thor (0.18.1)
68
+ tlsmail (0.0.1)
69
+ treetop (1.4.14)
70
+ polyglot
71
+ polyglot (>= 0.3.1)
72
+ twitter_oauth (0.4.94)
73
+ json (>= 1.8.0)
74
+ mime-types (>= 1.16)
75
+ oauth (>= 0.4.7)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ debugger (~> 1.6.1)
82
+ guard (~> 1.5.4)
83
+ guard-rspec (~> 2.3.1)
84
+ mocha (>= 0.9.5)
85
+ rake (~> 10.1.0)
86
+ rb-fsevent (~> 0.9.1)
87
+ rspec (~> 2.12.0)
88
+ twuckoo!
data/Rakefile CHANGED
@@ -1,27 +1,6 @@
1
- require 'rake'
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
2
3
 
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |gemspec|
6
- gemspec.name = "twuckoo"
7
- gemspec.summary = "Need to tweet periodically in an automated fashion? Then Twuckoo is for you!"
8
- gemspec.description = <<-EOF
9
- A simple yet elegant solution to tweet a message regularly from a file (or from a webpage, a database, etc.)
10
- EOF
11
- gemspec.email = "balint.erdi@gmail.com"
12
- gemspec.homepage = "http://github.com/balinterdi/twuckoo"
13
- gemspec.authors = ["Balint Erdi"]
14
- gemspec.add_development_dependency("mocha", ">= 0.9.5")
15
- gemspec.add_development_dependency("rspec")
16
- gemspec.add_dependency("twitter_oauth", "~> 0.4.3")
17
- gemspec.add_dependency("hpricot", ">= 0.6.164")
18
- gemspec.add_dependency("mail", ">= 1.6.0")
19
- gemspec.add_dependency("tlsmail", ">= 0.0.1")
20
- end
21
- Jeweler::GemcutterTasks.new
22
- rescue LoadError
23
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
24
- end
25
-
26
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ Dir["#{lib}/tasks/*.rb"].each { |f| load(f) }
27
6
 
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- dir = File.join(File.dirname(__FILE__), '..', 'lib')
4
- require File.join(dir, 'twuckoo')
3
+ require 'bundler/setup'
5
4
 
5
+ require 'twuckoo'
6
+
7
+ #FIXME: Show usage banner when no args are given
6
8
  @runner = Twuckoo::Runner.new(ARGV.shift, nil, ARGV)
7
- # @runner.set_testing
8
9
  @runner.run
@@ -0,0 +1,4 @@
1
+ require 'bundler/setup'
2
+ require 'pry'
3
+
4
+ # pry
@@ -1,13 +1,9 @@
1
1
  $:.unshift File.expand_path(File.dirname(__FILE__))
2
2
 
3
- module Twuckoo
4
-
5
- end
6
-
7
- require 'environments'
8
- require 'duration_string'
9
- require 'modules'
3
+ module Twuckoo; end
10
4
 
11
5
  require 'twuckoo/config'
6
+ require 'twuckoo/duration_string'
7
+ require 'twuckoo/feeders'
12
8
  require 'twuckoo/runner'
13
9
  require 'twuckoo/twitter_oauth_module'
@@ -1,6 +1,9 @@
1
- class Twuckoo::Config < Hash
2
- def initialize
3
- self[:time_to_sleep] = "1d"
4
- self[:tweet_limit] = 0
1
+ module Twuckoo
2
+ class Config < Hash
3
+ #TODO: Get rid of this mess
4
+ def initialize
5
+ self[:time_to_sleep] = "0"
6
+ self[:tweet_limit] = 0
7
+ end
5
8
  end
6
- end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Twuckoo
2
+ module DurationString
3
+ class << self
4
+ MULTIPLIERS = { "s" => 1, "m" => 60, "h" => 60 * 60, "d" => 60 * 60 * 24, "w" => 60 * 60 * 24 * 7 }
5
+ def to_seconds(duration)
6
+ duration.scan(/(\d+)([smhdw])/).inject(0) do |seconds, match|
7
+ num, dur_chr = match
8
+ multiplier = MULTIPLIERS[dur_chr]
9
+ seconds + num.to_i * multiplier
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'feeders/one_line_from_file'
2
+ require_relative 'feeders/wikipedia_tfa'
3
+
@@ -0,0 +1,77 @@
1
+ module Twuckoo
2
+ class OneLineFromFile
3
+ # read all lines from the file that contains the strategies
4
+ # select the strategies that are not used yet
5
+ # pick a random strategy
6
+
7
+ # store used strategies in a file with (store the md5 sum of the strategies' text)
8
+ attr_reader :lines
9
+
10
+ LINES_FILE = 'lines.txt'
11
+ USED_LINES_FILE = 'used_lines.txt'
12
+
13
+ def setup
14
+ @lines = []
15
+ end
16
+
17
+ #TODO: This could be merged into setup
18
+ def load_tweets
19
+ load_lines
20
+ end
21
+
22
+ def get_lines_from_file
23
+ IO::readlines(LINES_FILE).map { |line| line.chomp }
24
+ end
25
+
26
+ def get_all_lines
27
+ @fresh_lines ||= get_lines_from_file
28
+ end
29
+
30
+ def get_used_lines_from_file
31
+ begin
32
+ IO::readlines(USED_LINES_FILE).map { |line| line.chomp }
33
+ rescue Errno::ENOENT
34
+ []
35
+ end
36
+ end
37
+
38
+ def get_used_lines
39
+ @used_lines ||= get_used_lines_from_file
40
+ end
41
+
42
+ def get_unused_lines
43
+ unused_lines = get_all_lines.reject { |line| get_used_lines.include?(line) }
44
+ p unused_lines
45
+ unused_lines
46
+ end
47
+
48
+ def load_lines
49
+ add_lines(*get_unused_lines)
50
+ end
51
+
52
+ def add_lines(*new_lines)
53
+ @lines.concat(new_lines)
54
+ end
55
+
56
+ def pick
57
+ rand(lines.length)
58
+ end
59
+
60
+ def store(line)
61
+ open(USED_LINES_FILE, "a") do |file|
62
+ file.write(line + "\n")
63
+ end
64
+ end
65
+
66
+ def next
67
+ @lines.delete_at(pick)
68
+ end
69
+
70
+ def reset
71
+ File.delete(USED_LINES_FILE) rescue nil
72
+ @used_lines = nil
73
+ load_lines
74
+ end
75
+ end
76
+ end
77
+
@@ -0,0 +1,35 @@
1
+ require "open-uri"
2
+ require "hpricot"
3
+
4
+ # Grabs the headline of Wikipedia's Today's Featured Article (TFA)
5
+ module Twuckoo
6
+ class WikipediaTFA
7
+
8
+ WIKIPEDIA_HOST = "http://en.wikipedia.org"
9
+
10
+ def setup
11
+ end
12
+
13
+ def load_tweets; end
14
+ def store(line); end
15
+ def reset; end
16
+
17
+ def fetch_main_page
18
+ Hpricot(open("#{WIKIPEDIA_HOST}/wiki/Main_Page"))
19
+ end
20
+
21
+ def fetch_tfa
22
+ doc = fetch_main_page
23
+ tfa = doc.at("#mp-tfa b a")
24
+ tfa_link = WIKIPEDIA_HOST + tfa["href"]
25
+ "#{tfa.inner_html}: #{tfa_link}"
26
+ end
27
+
28
+ def next
29
+ prev_tweet = twitter_module.latest_tweet(config)
30
+ next_tweet = fetch_tfa
31
+ prev_tweet == next_tweet ? '' : next_tweet
32
+ end
33
+
34
+ end
35
+ end
@@ -2,43 +2,56 @@ require "optparse"
2
2
  require "ostruct"
3
3
  require "mail"
4
4
 
5
- class TwuckooException < Exception
5
+ require 'bundler/setup'
6
+
7
+ module Twuckoo
8
+ class Exception < StandardError
9
+ end
6
10
  end
7
11
 
8
12
  class Twuckoo::Runner
9
- # the idea is to include a module with a well-defined API with three methods:
10
- # - load_tweets
13
+ # the idea is to instantiate a feeder with a well-defined API:
14
+ # - setup
15
+ # - load_tweets (TODO: merge into setup)
11
16
  # - next
12
17
  # - store(tweet)
13
18
 
14
19
  def run
15
20
  setup_from_file
16
- load_tweets
17
- next_tweet = self.next
21
+ @feeder.load_tweets
22
+ next_tweet = @feeder.next
23
+ #TODO: Fetching @feeder.next twice seems too complicated
24
+ p next_tweet
18
25
  while (next_tweet and !tweet_limit_reached?) do
19
26
  tweet(next_tweet)
20
27
  wait if wait_between_tweets?
21
- next_tweet = self.next
28
+ next_tweet = @feeder.next
22
29
  if next_tweet.nil?
23
- notify
24
- reset
25
- next_tweet = self.next
30
+ send_email(name, config)
31
+ @feeder.reset
32
+ next_tweet = @feeder.next
26
33
  end
27
34
  end
28
35
  end
29
36
 
30
37
  attr_accessor :tweets_sent
31
38
 
32
- def initialize(module_name, twitter_module=nil, args=[])
33
- unless module_name.nil?
34
- _module = self.class.get_module(module_name)
35
- class_eval { include _module }
39
+ def initialize(feeder_class, tweeter_module=nil, args=[])
40
+ #TODO: Fail if feeder_class is nil or better: parse options first
41
+ unless feeder_class.nil?
42
+ feeder_class = self.class.get_feeder_class(feeder_class)
43
+ @feeder = feeder_class.new
36
44
  end
45
+
46
+ #TODO: This should be stored in the tweeter, not the runner
37
47
  @tweets_sent = 0
38
- @twitter_module = twitter_module.nil? ? Twuckoo::TwitterOauth : twitter_module
48
+
49
+ # tweeter_module should be a class instance instead. Then everything falls into place
50
+ @tweeter_module = tweeter_module.nil? ? Twuckoo::TwitterOauth : tweeter_module
51
+
39
52
  @options = OpenStruct.new
40
53
  parse_options!(args)
41
- setup_for_module
54
+ @feeder.setup
42
55
  end
43
56
 
44
57
  def parse_options!(args)
@@ -54,11 +67,6 @@ class Twuckoo::Runner
54
67
  end
55
68
  end
56
69
 
57
- # opts.on_tail("--version", "Show version") do
58
- # File.read(...)
59
- # exit
60
- # end
61
-
62
70
  opts.parse!(args)
63
71
  end
64
72
 
@@ -71,26 +79,14 @@ class Twuckoo::Runner
71
79
  end
72
80
 
73
81
  def wait
74
- seconds_to_sleep = DurationString.to_seconds(config[:time_to_sleep])
82
+ seconds_to_sleep = Twuckoo::DurationString.to_seconds(config[:time_to_sleep])
75
83
  sleep(seconds_to_sleep)
76
84
  end
77
85
 
78
- def notify
79
- send_email(name, config)
80
- end
81
-
82
86
  def tweet(message)
83
- unless message.nil? or message.empty?
84
- begin
85
- send_tweet(message, config)
86
- rescue twitter_module.exception
87
- return message
88
- else
89
- inc_tweet_counter
90
- store(message)
91
- end
92
- end
93
- message
87
+ send_tweet(message, config)
88
+ inc_tweet_counter
89
+ @feeder.store(message)
94
90
  end
95
91
 
96
92
  def config
@@ -120,25 +116,23 @@ class Twuckoo::Runner
120
116
  end
121
117
 
122
118
  private
123
- def self.get_module(module_name)
124
- case module_name
125
- when "file"
126
- OneLineFromFile
127
- when "from_file"
128
- OneLineFromFile
119
+ def self.get_feeder_class(name)
120
+ case name
121
+ when "file", "from_file"
122
+ Twuckoo::OneLineFromFile
129
123
  when "wikipedia_tfa"
130
- WikipediaTFA
124
+ Twuckoo::WikipediaTFA
131
125
  else
132
- raise TwuckooException, "Invalid module: #{module_name.inspect}"
126
+ raise Twuckoo::Exception, "Invalid feeder class: #{name}"
133
127
  end
134
128
  end
135
129
 
136
- def twitter_module
137
- @twitter_module
130
+ def tweeter_module
131
+ @tweeter_module
138
132
  end
139
133
 
140
134
  def send_tweet(message, options)
141
- twitter_module._tweet(message, options)
135
+ tweeter_module._tweet(message, options)
142
136
  end
143
137
 
144
138
  def inc_tweet_counter
@@ -150,22 +144,24 @@ class Twuckoo::Runner
150
144
  end
151
145
 
152
146
  def send_email(name, config)
153
- Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
147
+ #FIXME: `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
148
+ # Maybe just get rid of the whole email sending thingie?
149
+ Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE, nil)
154
150
  Mail.defaults do
155
- smtp do
156
- host "smtp.gmail.com"
157
- port 25
158
- user config[:user]
159
- pass config[:password]
160
- disable_tls
161
- end
151
+ delivery_method(:smtp, {
152
+ host: "smtp.gmail.com",
153
+ port: 25,
154
+ user: config[:user],
155
+ pass: config[:password],
156
+ enable_starttls_auto: false
157
+ })
162
158
  end
163
159
 
164
160
  Mail.deliver do
165
- from 'twuckoo@nowhere.com'
166
- to config[:email]
161
+ from 'twuckoo@nowhere.com'
162
+ to config[:email]
167
163
  subject %([twuckoo]: instance "#{name}" has done a reset)
168
- body "And is now going full speed again."
164
+ body "And is now going full speed again."
169
165
  end
170
166
  end
171
167
  end
@@ -2,6 +2,7 @@ require 'twitter_oauth/client'
2
2
  require 'twitter_oauth'
3
3
 
4
4
  module Twuckoo::TwitterOauth
5
+ #TODO: This should be a class and instantiated as @tweeter in Twuckoo::Runner
5
6
 
6
7
  def self._tweet(message, options)
7
8
  client(options).update(message)
@@ -0,0 +1,3 @@
1
+ module Twuckoo
2
+ VERSION = '0.5.2'
3
+ end
@@ -1,91 +1,33 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'twuckoo/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{twuckoo}
8
- s.version = "0.5.1"
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "twuckoo"
8
+ gem.version = Twuckoo::VERSION
9
+ gem.authors = ["Balint Erdi"]
10
+ gem.email = ["balint.erdi@gmail.com"]
11
+ gem.description = %q{A simple yet elegant solution to tweet a message regularly from a store (file, webpage, etc.)}
12
+ gem.summary = %q{Need to tweet periodically in an automated fashion? Then Twuckoo is for you!}
13
+ gem.homepage = ""
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Balint Erdi"]
12
- s.date = %q{2010-09-12}
13
- s.default_executable = %q{twuckoo}
14
- s.description = %q{ A simple yet elegant solution to tweet a message regularly from a file (or from a webpage, a database, etc.)
15
- }
16
- s.email = %q{balint.erdi@gmail.com}
17
- s.executables = ["twuckoo"]
18
- s.extra_rdoc_files = [
19
- "README.markdown"
20
- ]
21
- s.files = [
22
- ".gitignore",
23
- "CHANGELOG",
24
- "MIT-LICENSE",
25
- "Manifest",
26
- "README.markdown",
27
- "Rakefile",
28
- "VERSION",
29
- "bin/twuckoo",
30
- "lib/duration_string.rb",
31
- "lib/environments.rb",
32
- "lib/modules.rb",
33
- "lib/modules/one_line_from_file.rb",
34
- "lib/modules/wikipedia_tfa.rb",
35
- "lib/twuckoo.rb",
36
- "lib/twuckoo/config.rb",
37
- "lib/twuckoo/runner.rb",
38
- "lib/twuckoo/twitter_oauth_module.rb",
39
- "spec/duration_string_spec.rb",
40
- "spec/one_line_from_file_spec.rb",
41
- "spec/spec.opts",
42
- "spec/spec_helper.rb",
43
- "spec/twuckoo/config_spec.rb",
44
- "spec/twuckoo/runner_spec.rb",
45
- "spec/wikipedia_tfa_spec.rb",
46
- "tasks/spec.rake",
47
- "twuckoo.gemspec"
48
- ]
49
- s.homepage = %q{http://github.com/balinterdi/twuckoo}
50
- s.rdoc_options = ["--charset=UTF-8"]
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.7}
53
- s.summary = %q{Need to tweet periodically in an automated fashion? Then Twuckoo is for you!}
54
- s.test_files = [
55
- "spec/duration_string_spec.rb",
56
- "spec/one_line_from_file_spec.rb",
57
- "spec/spec_helper.rb",
58
- "spec/twuckoo/config_spec.rb",
59
- "spec/twuckoo/runner_spec.rb",
60
- "spec/wikipedia_tfa_spec.rb"
61
- ]
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
62
19
 
63
- if s.respond_to? :specification_version then
64
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
- s.specification_version = 3
20
+ gem.add_development_dependency 'mocha', ['>= 0.9.5']
21
+ gem.add_development_dependency 'rspec', ['~> 2.12.0']
22
+ gem.add_development_dependency 'guard', ['~> 1.5.4']
23
+ gem.add_development_dependency 'guard-rspec', ['~> 2.3.1']
24
+ gem.add_development_dependency 'rb-fsevent', ['~> 0.9.1']
25
+ gem.add_development_dependency 'debugger', ['~> 1.6.1']
26
+ gem.add_development_dependency 'rake', ['~> 10.1.0']
66
27
 
67
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
68
- s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
69
- s.add_development_dependency(%q<rspec>, [">= 0"])
70
- s.add_runtime_dependency(%q<twitter_oauth>, ["~> 0.4.3"])
71
- s.add_runtime_dependency(%q<hpricot>, [">= 0.6.164"])
72
- s.add_runtime_dependency(%q<mail>, [">= 1.6.0"])
73
- s.add_runtime_dependency(%q<tlsmail>, [">= 0.0.1"])
74
- else
75
- s.add_dependency(%q<mocha>, [">= 0.9.5"])
76
- s.add_dependency(%q<rspec>, [">= 0"])
77
- s.add_dependency(%q<twitter_oauth>, ["~> 0.4.3"])
78
- s.add_dependency(%q<hpricot>, [">= 0.6.164"])
79
- s.add_dependency(%q<mail>, [">= 1.6.0"])
80
- s.add_dependency(%q<tlsmail>, [">= 0.0.1"])
81
- end
82
- else
83
- s.add_dependency(%q<mocha>, [">= 0.9.5"])
84
- s.add_dependency(%q<rspec>, [">= 0"])
85
- s.add_dependency(%q<twitter_oauth>, ["~> 0.4.3"])
86
- s.add_dependency(%q<hpricot>, [">= 0.6.164"])
87
- s.add_dependency(%q<mail>, [">= 1.6.0"])
88
- s.add_dependency(%q<tlsmail>, [">= 0.0.1"])
89
- end
28
+ gem.add_dependency 'twitter_oauth', ['~> 0.4.94']
29
+ gem.add_dependency 'hpricot', ['>= 0.6.164']
30
+ gem.add_dependency 'mail', [">= 1.6.0"]
31
+ gem.add_dependency 'tlsmail', [">= 0.0.1"]
90
32
  end
91
33
 
metadata CHANGED
@@ -1,143 +1,198 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: twuckoo
3
- version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 5
9
- - 1
10
- version: 0.5.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Balint Erdi
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2010-09-12 00:00:00 +02:00
19
- default_executable: twuckoo
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-07-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: mocha
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 49
30
- segments:
31
- - 0
32
- - 9
33
- - 5
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
34
19
  version: 0.9.5
35
20
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.5
27
+ - !ruby/object:Gem::Dependency
38
28
  name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.12.0
34
+ type: :development
39
35
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.12.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.5.4
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.3.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.3.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rb-fsevent
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: debugger
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 10.1.0
49
104
  type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: twitter_oauth
53
105
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
57
108
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 9
60
- segments:
61
- - 0
62
- - 4
63
- - 3
64
- version: 0.4.3
109
+ - !ruby/object:Gem::Version
110
+ version: 10.1.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: twitter_oauth
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.94
65
118
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: hpricot
69
119
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 335
76
- segments:
77
- - 0
78
- - 6
79
- - 164
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 0.4.94
125
+ - !ruby/object:Gem::Dependency
126
+ name: hpricot
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
80
131
  version: 0.6.164
81
132
  type: :runtime
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: mail
85
133
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 15
92
- segments:
93
- - 1
94
- - 6
95
- - 0
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.6.164
139
+ - !ruby/object:Gem::Dependency
140
+ name: mail
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
96
145
  version: 1.6.0
97
146
  type: :runtime
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: tlsmail
101
147
  prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 29
108
- segments:
109
- - 0
110
- - 0
111
- - 1
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.6.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: tlsmail
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
112
159
  version: 0.0.1
113
160
  type: :runtime
114
- version_requirements: *id006
115
- description: " A simple yet elegant solution to tweet a message regularly from a file (or from a webpage, a database, etc.)\n"
116
- email: balint.erdi@gmail.com
117
- executables:
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.0.1
167
+ description: A simple yet elegant solution to tweet a message regularly from a store
168
+ (file, webpage, etc.)
169
+ email:
170
+ - balint.erdi@gmail.com
171
+ executables:
118
172
  - twuckoo
119
173
  extensions: []
120
-
121
- extra_rdoc_files:
122
- - README.markdown
123
- files:
174
+ extra_rdoc_files: []
175
+ files:
124
176
  - .gitignore
125
177
  - CHANGELOG
178
+ - Gemfile
179
+ - Gemfile.lock
126
180
  - MIT-LICENSE
127
181
  - Manifest
128
182
  - README.markdown
129
183
  - Rakefile
130
184
  - VERSION
131
185
  - bin/twuckoo
132
- - lib/duration_string.rb
133
- - lib/environments.rb
134
- - lib/modules.rb
135
- - lib/modules/one_line_from_file.rb
136
- - lib/modules/wikipedia_tfa.rb
186
+ - lib/tasks/console.rb
137
187
  - lib/twuckoo.rb
138
188
  - lib/twuckoo/config.rb
189
+ - lib/twuckoo/duration_string.rb
190
+ - lib/twuckoo/feeders.rb
191
+ - lib/twuckoo/feeders/one_line_from_file.rb
192
+ - lib/twuckoo/feeders/wikipedia_tfa.rb
139
193
  - lib/twuckoo/runner.rb
140
194
  - lib/twuckoo/twitter_oauth_module.rb
195
+ - lib/twuckoo/version.rb
141
196
  - spec/duration_string_spec.rb
142
197
  - spec/one_line_from_file_spec.rb
143
198
  - spec/spec.opts
@@ -145,45 +200,34 @@ files:
145
200
  - spec/twuckoo/config_spec.rb
146
201
  - spec/twuckoo/runner_spec.rb
147
202
  - spec/wikipedia_tfa_spec.rb
148
- - tasks/spec.rake
149
203
  - twuckoo.gemspec
150
- has_rdoc: true
151
- homepage: http://github.com/balinterdi/twuckoo
204
+ homepage: ''
152
205
  licenses: []
153
-
206
+ metadata: {}
154
207
  post_install_message:
155
- rdoc_options:
156
- - --charset=UTF-8
157
- require_paths:
208
+ rdoc_options: []
209
+ require_paths:
158
210
  - lib
159
- required_ruby_version: !ruby/object:Gem::Requirement
160
- none: false
161
- requirements:
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- hash: 3
165
- segments:
166
- - 0
167
- version: "0"
168
- required_rubygems_version: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- hash: 3
174
- segments:
175
- - 0
176
- version: "0"
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
177
221
  requirements: []
178
-
179
222
  rubyforge_project:
180
- rubygems_version: 1.3.7
223
+ rubygems_version: 2.0.2
181
224
  signing_key:
182
- specification_version: 3
225
+ specification_version: 4
183
226
  summary: Need to tweet periodically in an automated fashion? Then Twuckoo is for you!
184
- test_files:
227
+ test_files:
185
228
  - spec/duration_string_spec.rb
186
229
  - spec/one_line_from_file_spec.rb
230
+ - spec/spec.opts
187
231
  - spec/spec_helper.rb
188
232
  - spec/twuckoo/config_spec.rb
189
233
  - spec/twuckoo/runner_spec.rb
@@ -1,12 +0,0 @@
1
- module DurationString
2
- class << self
3
- MULTIPLIERS = { "s" => 1, "m" => 60, "h" => 60 * 60, "d" => 60 * 60 * 24, "w" => 60 * 60 * 24 * 7 }
4
- def to_seconds(duration)
5
- duration.scan(/(\d+)([smhdw])/).inject(0) do |seconds, match|
6
- num, dur_chr = match
7
- multiplier = MULTIPLIERS[dur_chr]
8
- seconds + num.to_i * multiplier
9
- end
10
- end
11
- end
12
- end
@@ -1,8 +0,0 @@
1
- module TwuckooEnvironment
2
- def set_testing
3
- ENV["CUCKOO_ENV"] = "testing"
4
- end
5
- def testing?
6
- ENV["CUCKOO_ENV"] == "testing"
7
- end
8
- end
@@ -1,2 +0,0 @@
1
- require 'modules/one_line_from_file'
2
- require 'modules/wikipedia_tfa'
@@ -1,76 +0,0 @@
1
- module OneLineFromFile
2
- # read all lines from the file that contains the strategies
3
- # select the strategies that are not used yet
4
- # pick a random strategy
5
-
6
- # store used strategies in a file with (store the md5 sum of the strategies' text)
7
- attr_reader :lines
8
-
9
- LINES_FILE = 'lines.txt'
10
- USED_LINES_FILE = 'used_lines.txt'
11
-
12
- def setup_for_module
13
- @lines = []
14
- end
15
-
16
- def load_tweets
17
- load_lines
18
- end
19
-
20
- def get_lines_from_file
21
- begin
22
- IO::readlines(LINES_FILE).map { |line| line.chomp }
23
- rescue Errno::ENOENT
24
- []
25
- end
26
- end
27
-
28
- def get_all_lines
29
- @fresh_lines ||= get_lines_from_file
30
- end
31
-
32
- def get_used_lines_from_file
33
- begin
34
- IO::readlines(USED_LINES_FILE).map { |line| line.chomp }
35
- rescue Errno::ENOENT
36
- []
37
- end
38
- end
39
-
40
- def get_used_lines
41
- @used_lines ||= get_used_lines_from_file
42
- end
43
-
44
- def get_unused_lines
45
- get_all_lines.reject { |line| get_used_lines.include?(line) }
46
- end
47
-
48
- def load_lines
49
- add_lines(*get_unused_lines)
50
- end
51
-
52
- def add_lines(*new_lines)
53
- @lines.concat(new_lines)
54
- end
55
-
56
- def pick
57
- rand(lines.length)
58
- end
59
-
60
- def store(line)
61
- open(USED_LINES_FILE, "a") do |file|
62
- file.write(line + "\n")
63
- end
64
- end
65
-
66
- def next
67
- @lines.delete_at(pick)
68
- end
69
-
70
- def reset
71
- File.delete(USED_LINES_FILE) rescue nil
72
- @used_lines = nil
73
- load_lines
74
- end
75
- end
76
-
@@ -1,32 +0,0 @@
1
- require "open-uri"
2
- require "hpricot"
3
-
4
- # Grabs the headline of Wikipedia's Today's Featured Article (TFA)
5
- module WikipediaTFA
6
-
7
- WIKIPEDIA_HOST = "http://en.wikipedia.org"
8
- def setup_for_module
9
- end
10
-
11
- def load_tweets; end
12
- def store(line); end
13
- def reset; end
14
-
15
- def fetch_main_page
16
- Hpricot(open("#{WIKIPEDIA_HOST}/wiki/Main_Page"))
17
- end
18
-
19
- def fetch_tfa
20
- doc = fetch_main_page
21
- tfa = doc.at("#mp-tfa b a")
22
- tfa_link = WIKIPEDIA_HOST + tfa["href"]
23
- "#{tfa.inner_html}: #{tfa_link}"
24
- end
25
-
26
- def next
27
- prev_tweet = twitter_module.latest_tweet(config)
28
- next_tweet = fetch_tfa
29
- prev_tweet == next_tweet ? '' : next_tweet
30
- end
31
-
32
- end
@@ -1,10 +0,0 @@
1
- require "rake"
2
- require "spec/rake/spectask"
3
-
4
- ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
5
-
6
- desc "Run all specs"
7
- Spec::Rake::SpecTask.new(:spec) do |t|
8
- t.spec_opts << '--options' << ROOT + '/spec/spec.opts'
9
- t.spec_files = Dir.glob('spec/**/*_spec.rb').map { |f| f.to_s }
10
- end