jmazzi-atnotify 0.0.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.
Files changed (4) hide show
  1. data/bin/atnotify +30 -0
  2. data/lib/db.rb +25 -0
  3. data/lib/email.rb +7 -0
  4. metadata +90 -0
data/bin/atnotify ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '../lib')
3
+ require 'rubygems'
4
+ require 'yaml'
5
+ require 'twitter'
6
+ require 'db'
7
+ require 'email'
8
+
9
+ conf_file = "#{ENV['HOME']}/.atnotify.yml"
10
+
11
+ unless File.exists?(conf_file)
12
+ puts "#{conf_file} doesn't exists. Please create it!"
13
+ exit
14
+ end
15
+
16
+ config = YAML::load(File.open(conf_file))
17
+ twit = Twitter::Base.new(config['username'], config['password'])
18
+ post = Post.first(:order => [:last_post_id.desc])
19
+
20
+ if post
21
+ conditions = {:since_id => post.last_post_id}
22
+ else
23
+ conditions = {}
24
+ end
25
+ body = ""
26
+ twit.replies(conditions).each do |s|
27
+ Post.create(:username => s.user.screen_name, :name => s.user.name, :body => s.text, :last_post_id => s.id)
28
+ body << "#{s.user.name} said: #{s.text} At #{Time.parse(s.created_at).strftime("%I:%M %p %b %d")}\n"
29
+ end
30
+ send_mail(config['email'], body) unless body.empty?
data/lib/db.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'dm-core'
2
+ require 'dm-validations'
3
+
4
+ # Config
5
+ db = "#{ENV['HOME']}/.atnotify.db"
6
+ #DataMapper::Logger.new('db.log', :debug)
7
+ DataMapper.setup(:default, "sqlite3:///#{db}")
8
+
9
+ # Post
10
+ class Post
11
+ include DataMapper::Resource
12
+ property :id, Integer, :serial => true
13
+ property :username, String, :index => true
14
+ property :name, String
15
+ property :body, String
16
+ property :last_post_id, String, :index => true
17
+
18
+ validates_is_unique :last_post_id
19
+
20
+ end
21
+
22
+ # Create the db if it doesn't exist
23
+ unless File.exists?(db)
24
+ Post.auto_migrate!
25
+ end
data/lib/email.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'escape'
2
+
3
+ def send_mail(to, message)
4
+ m = Escape.shell_command(message)
5
+ t = Escape.shell_command(to)
6
+ system("echo #{m} | mail -s AtNotify #{t}")
7
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jmazzi-atnotify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Justin Mazzi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-07 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: dm-core
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: dm-validations
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: escape
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: twitter
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ description: ""
52
+ email: hh@mailheist.com
53
+ executables:
54
+ - atnotify
55
+ extensions: []
56
+
57
+ extra_rdoc_files: []
58
+
59
+ files:
60
+ - lib/db.rb
61
+ - lib/email.rb
62
+ - bin/atnotify
63
+ has_rdoc: false
64
+ homepage: http://r00tshell.com
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.2.0
86
+ signing_key:
87
+ specification_version: 2
88
+ summary: Sends you an email when someone @replies you on twitter.
89
+ test_files: []
90
+