youpy-net-twitter-status 0.0.1

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 (5) hide show
  1. data/ChangeLog +4 -0
  2. data/README +32 -0
  3. data/Rakefile +140 -0
  4. data/lib/net/twitter/status.rb +75 -0
  5. metadata +78 -0
@@ -0,0 +1,4 @@
1
+ == 0.0.1 / 2008-07-25
2
+
3
+ * initial release
4
+
data/README ADDED
@@ -0,0 +1,32 @@
1
+ = net-twitter-status
2
+
3
+ == Description
4
+ library to get Twitter's current status information
5
+
6
+ == Installation
7
+
8
+ === Archive Installation
9
+
10
+ rake install
11
+
12
+ === Gem Installation
13
+
14
+ gem install net-twitter-status
15
+
16
+ == Features/Problems
17
+
18
+ == Synopsis
19
+
20
+ >> status = Net::Twitter::Status.new
21
+ >> features = status.features
22
+ >> features['IM'].status
23
+ => :offline
24
+ >> features['IM'].message
25
+ => "Offline. Working on additional capacity."
26
+
27
+ == Copyright
28
+
29
+ Author:: youpy <youpy@>
30
+ Copyright:: Copyright (c) 2008 youpy
31
+ License:: MIT
32
+
@@ -0,0 +1,140 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'spec/rake/spectask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'rake/contrib/sshpublisher'
10
+ require 'fileutils'
11
+
12
+ $LOAD_PATH << File.dirname(__FILE__) + '/lib/'
13
+ require 'net/twitter/status'
14
+
15
+ include FileUtils
16
+
17
+ NAME = "net-twitter-status"
18
+ AUTHOR = "youpy"
19
+ EMAIL = "youpy@buycheapviagraonlinenow.com"
20
+ DESCRIPTION = ""
21
+ RUBYFORGE_PROJECT = "nettwitterstatus"
22
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
23
+ BIN_FILES = %w( )
24
+ VERS = Net::Twitter::Status::VERSION
25
+
26
+ REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
27
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
28
+ RDOC_OPTS = [
29
+ '--title', "#{NAME} documentation",
30
+ "--charset", "utf-8",
31
+ "--opname", "index.html",
32
+ "--line-numbers",
33
+ "--main", "README",
34
+ "--inline-source",
35
+ ]
36
+
37
+ task :default => [:spec]
38
+ task :package => [:clean]
39
+
40
+ Spec::Rake::SpecTask.new do |t|
41
+ t.spec_opts = ['--options', "spec/spec.opts"]
42
+ t.spec_files = FileList['spec/*_spec.rb']
43
+ t.rcov = true
44
+ end
45
+
46
+ spec = Gem::Specification.new do |s|
47
+ s.name = NAME
48
+ s.version = VERS
49
+ s.platform = Gem::Platform::RUBY
50
+ s.has_rdoc = true
51
+ s.extra_rdoc_files = ["README", "ChangeLog"]
52
+ s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
53
+ s.summary = DESCRIPTION
54
+ s.description = DESCRIPTION
55
+ s.author = AUTHOR
56
+ s.email = EMAIL
57
+ s.homepage = HOMEPATH
58
+ s.executables = BIN_FILES
59
+ s.rubyforge_project = RUBYFORGE_PROJECT
60
+ s.bindir = "bin"
61
+ s.require_path = "lib"
62
+ s.autorequire = ""
63
+ s.test_files = Dir["test/test_*.rb"]
64
+
65
+ s.add_dependency('hpricot', '>= 0')
66
+ #s.required_ruby_version = '>= 1.8.2'
67
+
68
+ s.files = %w(README ChangeLog Rakefile) +
69
+ Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
70
+ Dir.glob("ext/**/*.{h,c,rb}") +
71
+ Dir.glob("examples/**/*.rb") +
72
+ Dir.glob("tools/*.rb")
73
+
74
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
75
+ end
76
+
77
+ Rake::GemPackageTask.new(spec) do |p|
78
+ p.need_tar = true
79
+ p.gem_spec = spec
80
+ end
81
+
82
+ task :install do
83
+ name = "#{NAME}-#{VERS}.gem"
84
+ sh %{rake package}
85
+ sh %{sudo gem install pkg/#{name}}
86
+ end
87
+
88
+ task :uninstall => [:clean] do
89
+ sh %{sudo gem uninstall #{NAME}}
90
+ end
91
+
92
+
93
+ Rake::RDocTask.new do |rdoc|
94
+ rdoc.rdoc_dir = 'html'
95
+ rdoc.options += RDOC_OPTS
96
+ rdoc.template = "resh"
97
+ #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
98
+ if ENV['DOC_FILES']
99
+ rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
100
+ else
101
+ rdoc.rdoc_files.include('README', 'ChangeLog')
102
+ rdoc.rdoc_files.include('lib/**/*.rb')
103
+ rdoc.rdoc_files.include('ext/**/*.c')
104
+ end
105
+ end
106
+
107
+ desc "Publish to RubyForge"
108
+ task :rubyforge => [:rdoc, :package] do
109
+ require 'rubyforge'
110
+ Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'youpy').upload
111
+ end
112
+
113
+ desc 'Package and upload the release to rubyforge.'
114
+ task :release => [:clean, :package] do |t|
115
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
116
+ abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
117
+ pkg = "pkg/#{NAME}-#{VERS}"
118
+
119
+ rf = RubyForge.new
120
+ puts "Logging in"
121
+ rf.login
122
+
123
+ c = rf.userconfig
124
+ # c["release_notes"] = description if description
125
+ # c["release_changes"] = changes if changes
126
+ c["preformatted"] = true
127
+
128
+ files = [
129
+ "#{pkg}.tgz",
130
+ "#{pkg}.gem"
131
+ ].compact
132
+
133
+ puts "Releasing #{NAME} v. #{VERS}"
134
+ rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
135
+ end
136
+
137
+ desc 'Show information about the gem.'
138
+ task :debug_gem do
139
+ puts spec.to_ruby
140
+ end
@@ -0,0 +1,75 @@
1
+ require 'rubygems'
2
+ require 'hpricot'
3
+ require 'open-uri'
4
+
5
+ module Net
6
+ module Twitter
7
+ class Status
8
+ VERSION = '0.0.1'
9
+
10
+ class Features
11
+ include Enumerable
12
+
13
+ def initialize(elements)
14
+ @elements = elements
15
+ end
16
+
17
+ def each
18
+ @elements.each do |element|
19
+ yield Feature.new(element)
20
+ end
21
+ end
22
+
23
+ def size
24
+ @elements.size
25
+ end
26
+
27
+ def names
28
+ map do |feature|
29
+ feature.name
30
+ end
31
+ end
32
+
33
+ def [](name)
34
+ find do |feature|
35
+ feature.name == name
36
+ end
37
+ end
38
+ end
39
+
40
+ class Feature
41
+ def initialize(element)
42
+ @element = element
43
+ end
44
+
45
+ def name
46
+ @element.inner_text
47
+ end
48
+
49
+ def status
50
+ case @element['style'].gsub(/^background-color:/, '')
51
+ when 'orange'
52
+ :problem
53
+ when 'yellowgreen'
54
+ :ok
55
+ when 'darkred'
56
+ :offline
57
+ end
58
+ end
59
+
60
+ def message
61
+ @element['title']
62
+ end
63
+ end
64
+
65
+ def features
66
+ doc = Hpricot(open('http://status.twitter.com/').read)
67
+ elements = doc.search('//div[@id="description"]//span').map do |element|
68
+ element
69
+ end
70
+
71
+ Features.new(elements)
72
+ end
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: youpy-net-twitter-status
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - youpy
8
+ autorequire: ""
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-25 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hpricot
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: ""
25
+ email: youpy@buycheapviagraonlinenow.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README
32
+ - ChangeLog
33
+ files:
34
+ - README
35
+ - ChangeLog
36
+ - Rakefile
37
+ - lib/net
38
+ - lib/net/twitter
39
+ - lib/net/twitter/status.rb
40
+ has_rdoc: true
41
+ homepage: http://nettwitterstatus.rubyforge.org
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --title
45
+ - net-twitter-status documentation
46
+ - --charset
47
+ - utf-8
48
+ - --opname
49
+ - index.html
50
+ - --line-numbers
51
+ - --main
52
+ - README
53
+ - --inline-source
54
+ - --exclude
55
+ - ^(examples|extras)/
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project: nettwitterstatus
73
+ rubygems_version: 1.2.0
74
+ signing_key:
75
+ specification_version: 2
76
+ summary: ""
77
+ test_files: []
78
+