trendy 0.1.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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ = Trendy
2
+ Trendy is a simple Twitter Search API Wrapper that does one thing: gives you the current Trends on Twitter.
3
+
4
+ == Installation
5
+ gem install trendy
6
+
7
+ == Example
8
+ Remember to add a "config.gem trendy" line in your environment.rb.
9
+
10
+ require 'trendy'
11
+ current_trends = Trendy::Trends.new
12
+ current_trends.each do |trend|
13
+ puts trend.name
14
+ puts trend.url
15
+ end
16
+
17
+ == Tests
18
+ To run the rspec tests for this gem, just run 'rake' in the main directory.
19
+
20
+
21
+ Copyright (c) 2010 Paul Fedory, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/rdoctask'
3
+ require 'spec/rake/spectask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :spec
7
+
8
+ desc 'Test the plugin.'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.libs << 'lib'
11
+ t.verbose = true
12
+ end
13
+
14
+
15
+ desc 'Generate documentation for the trendy plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Trendy'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+
25
+ begin
26
+ require 'jeweler'
27
+ Jeweler::Tasks.new do |gemspec|
28
+ gemspec.name = "trendy"
29
+ gemspec.summary = "A wrapper for the Twitter API that gets trends."
30
+ gemspec.description = "A wrapper for the Twitter API that gets trends."
31
+ gemspec.homepage = "http://github.com/paulfedory/trendy"
32
+ gemspec.authors = ["Paul Fedory"]
33
+ gemspec.add_dependency('json_pure', '>= 1.2.0')
34
+ end
35
+ Jeweler::GemcutterTasks.new
36
+ rescue LoadError
37
+ puts "Jeweler not available. Install it with: gem install jeweler"
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.2
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init.rb"
data/lib/trendy.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'open-uri'
2
+ require 'rubygems'
3
+ require 'json/pure'
4
+
5
+ # Trendy
6
+ module Trendy
7
+
8
+ # Trends is an array which contains Trend objects
9
+ # use these Trend objects to access information about a particular trend
10
+ class Trends < Array
11
+ attr_reader :url, :datetime
12
+
13
+ def initialize
14
+ @url = 'http://search.twitter.com/trends.json'
15
+ result = read_twitter
16
+
17
+ trends = result['trends']
18
+
19
+ @datetime = result['as_of']
20
+
21
+ trends.each do |subject|
22
+ trend = Trend.new
23
+ trend.name = subject['name']
24
+ trend.url = subject['url']
25
+ self.push(trend)
26
+ end
27
+ end
28
+
29
+ private
30
+ def read_twitter
31
+ buffer = open(@url, "UserAgent" => "Ruby-Wget").read
32
+
33
+ # convert JSON data into a hash
34
+ result = JSON.parse(buffer)
35
+ end
36
+
37
+ end
38
+
39
+ # Trend contains the name, url (for current trends) of a single trending topic
40
+ class Trend
41
+ attr_accessor :name, :url
42
+ end
43
+ end
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'trendy'
@@ -0,0 +1 @@
1
+ require 'trendy'
@@ -0,0 +1,58 @@
1
+ #require 'spec_helper'
2
+ require File.join(File.dirname(__FILE__), "spec_helper" )
3
+
4
+ #describe
5
+ module Trendy
6
+ describe Trends do
7
+ context "starting up with no parameters" do
8
+ before (:all) do
9
+ @trends = Trends.new
10
+ end
11
+
12
+ it "should exist" do
13
+ @trends.should_not be_nil
14
+ end
15
+
16
+ it "should contain at least 1 Trend" do
17
+ @trends.should have_at_least(1).trend
18
+ end
19
+
20
+ it "should contain only Trend objects" do
21
+ @trends.each do |trend|
22
+ trend.should be_instance_of(Trend)
23
+ end
24
+ end
25
+
26
+ it "should contain a URL" do
27
+ @trends.url.should_not be_nil
28
+ end
29
+
30
+ it "should contain a date or time" do
31
+ @trends.datetime.should_not be_nil
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ describe Trend do
39
+ before(:all) do
40
+ trends = Trends.new
41
+ @trend = trends.first
42
+ end
43
+
44
+ it "should exist" do
45
+ @trend.should_not be_nil
46
+ end
47
+
48
+ it "should have a name" do
49
+ @trend.name.should_not be_nil
50
+ end
51
+
52
+ it "should have a url" do
53
+ #(!@trend.query.nil? || !@trend.url.nil?).should be_true
54
+ @trend.url.should_not be_nil
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :trendy do
3
+ # # Task goes here
4
+ # end
data/trendy.gemspec ADDED
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{trendy}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Paul Fedory"]
12
+ s.date = %q{2010-01-26}
13
+ s.description = %q{A wrapper for the Twitter API that gets trends.}
14
+ s.extra_rdoc_files = [
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ "MIT-LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "init.rb",
23
+ "lib/trendy.rb",
24
+ "rails/init.rb",
25
+ "spec/spec_helper.rb",
26
+ "spec/trendy_spec.rb",
27
+ "tasks/trendy_tasks.rake",
28
+ "trendy.gemspec"
29
+ ]
30
+ s.homepage = %q{http://github.com/paulfedory/trendy}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.5}
34
+ s.summary = %q{A wrapper for the Twitter API that gets trends.}
35
+ s.test_files = [
36
+ "spec/spec_helper.rb",
37
+ "spec/trendy_spec.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
46
+ else
47
+ s.add_dependency(%q<json_pure>, [">= 1.2.0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<json_pure>, [">= 1.2.0"])
51
+ end
52
+ end
53
+
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trendy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Paul Fedory
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-26 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json_pure
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.0
24
+ version:
25
+ description: A wrapper for the Twitter API that gets trends.
26
+ email:
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION
38
+ - init.rb
39
+ - lib/trendy.rb
40
+ - rails/init.rb
41
+ - spec/spec_helper.rb
42
+ - spec/trendy_spec.rb
43
+ - tasks/trendy_tasks.rake
44
+ - trendy.gemspec
45
+ has_rdoc: true
46
+ homepage: http://github.com/paulfedory/trendy
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options:
51
+ - --charset=UTF-8
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: A wrapper for the Twitter API that gets trends.
73
+ test_files:
74
+ - spec/spec_helper.rb
75
+ - spec/trendy_spec.rb