sarnesjo-twhere 0.0.7 → 0.0.8

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/README.rdoc CHANGED
@@ -28,8 +28,6 @@ Put something like this in your crontab:
28
28
 
29
29
  === Twitter
30
30
 
31
- === Google Maps
32
-
33
31
  == Usage
34
32
 
35
33
  == Copyright
data/bin/twhere CHANGED
@@ -42,7 +42,7 @@ rescue Errno::ENOENT
42
42
  end
43
43
 
44
44
  # create Twhere instance and puts result
45
- twhere = Twhere.new(locations, template, config[:twitter][:username], config[:twitter][:password], config[:google_maps][:api_key], tweets)
45
+ twhere = Twhere.new(locations, template, config[:twitter][:username], config[:twitter][:password], tweets)
46
46
  puts twhere.result
47
47
 
48
48
  # save tweets to file
data/examples/config.yml CHANGED
@@ -6,5 +6,3 @@
6
6
  :twitter:
7
7
  :username: changeme
8
8
  :password: changeme
9
- :google_maps:
10
- :api_key: changeme
@@ -4,7 +4,7 @@
4
4
  <head>
5
5
  <title>Twhere</title>
6
6
 
7
- <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<%= @google_maps_api_key %>" type="text/javascript">
7
+ <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=changeme" type="text/javascript">
8
8
  </script>
9
9
 
10
10
  <script type="text/javascript">
data/lib/twhere.rb CHANGED
@@ -11,12 +11,11 @@ end
11
11
  class Twhere
12
12
  include TwhereHelperMethods
13
13
 
14
- def initialize(locations, template, twitter_username, twitter_password, google_maps_api_key, tweets = nil)
14
+ def initialize(locations, template, twitter_username, twitter_password, tweets = nil)
15
15
  @locations = locations
16
16
  @template = template
17
17
  @twitter_username = twitter_username
18
18
  @twitter_password = twitter_password
19
- @google_maps_api_key = google_maps_api_key
20
19
  @tweets = tweets || []
21
20
  end
22
21
 
@@ -0,0 +1,43 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'spec_helper'
3
+
4
+ describe 'hashtag method' do
5
+ include TwhereHelperMethods
6
+
7
+ it 'should find hashtags' do
8
+ # no hashtags
9
+ hashtag('').should == nil
10
+ hashtag('a').should == nil
11
+ hashtag('#').should == nil
12
+ hashtag('##').should == nil
13
+
14
+ # lowercase
15
+ hashtag('#a').should == 'a'
16
+ hashtag('#aa').should == 'aa'
17
+
18
+ # uppercase
19
+ hashtag('#A').should == 'A'
20
+ hashtag('#AA').should == 'AA'
21
+
22
+ # digits
23
+ hashtag('#1').should == '1'
24
+ hashtag('#11').should == '11'
25
+
26
+ # TODO: unicode?
27
+
28
+ # mixed character classes
29
+ hashtag('#aA').should == 'aA'
30
+ hashtag('#Aa').should == 'Aa'
31
+ hashtag('#a1').should == 'a1'
32
+ hashtag('#1a').should == '1a'
33
+ hashtag('#A1').should == 'A1'
34
+ hashtag('#1A').should == '1A'
35
+
36
+ # in text
37
+ hashtag('a #b').should == 'b'
38
+ hashtag('#a b').should == 'a'
39
+
40
+ # multiple hashtags, use first
41
+ hashtag('#a #b').should == 'a'
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'spec'
3
+ require 'twhere'
@@ -0,0 +1,24 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'spec_helper'
3
+
4
+ describe Twhere do
5
+ before :each do
6
+ # mock Twitter proxy object
7
+ user_timeline = []
8
+ user_timeline << Mash.new({:twitter_id=>1, :text=>'one #home', :created_at=>'Wed Apr 29 12:00:00 +0000 2009'})
9
+ user_timeline << Mash.new({:twitter_id=>2, :text=>'two #work', :created_at=>'Wed Apr 29 13:00:00 +0000 2009'})
10
+ mock_twitter = mock('twitter')
11
+ mock_twitter.should_receive(:user_timeline).and_return(user_timeline)
12
+ Twitter::Base.should_receive(:new).and_return(mock_twitter)
13
+
14
+ # create Twhere instance
15
+ locations = {'home'=>'59.35,18.066667', 'work'=>'59.35,18.066667'}
16
+ template = %Q{<% for location in @located_tweets.keys.sort %><%= location %>: <%= @located_tweets[location].map {|t| t[:text]}.join %>\n<% end %>}
17
+ @twhere = Twhere.new(locations, template, nil, nil, nil)
18
+ end
19
+
20
+ it 'should produce a result' do
21
+ expected_result = %Q{home: one #home\nwork: two #work\n}
22
+ @twhere.result.should == expected_result
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sarnesjo-twhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jesper S\xC3\xA4rnesj\xC3\xB6"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-29 00:00:00 -07:00
12
+ date: 2009-04-30 00:00:00 -07:00
13
13
  default_executable: twhere
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -29,21 +29,20 @@ executables:
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
- - README.rdoc
33
32
  - LICENSE
33
+ - README.rdoc
34
34
  files:
35
35
  - bin/twhere
36
36
  - examples/config.yml
37
37
  - examples/locations.yml
38
38
  - examples/template.html.erb
39
39
  - lib/twhere.rb
40
- - README.rdoc
41
40
  - LICENSE
41
+ - README.rdoc
42
42
  has_rdoc: true
43
43
  homepage: http://github.com/sarnesjo/twhere
44
44
  post_install_message:
45
45
  rdoc_options:
46
- - --inline-source
47
46
  - --charset=UTF-8
48
47
  require_paths:
49
48
  - lib
@@ -64,7 +63,9 @@ requirements: []
64
63
  rubyforge_project:
65
64
  rubygems_version: 1.2.0
66
65
  signing_key:
67
- specification_version: 2
66
+ specification_version: 3
68
67
  summary: Twitter/Google Maps mashup
69
- test_files: []
70
-
68
+ test_files:
69
+ - spec/hashtag_spec.rb
70
+ - spec/spec_helper.rb
71
+ - spec/twhere_spec.rb