bgetting-chirp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ h1. Chirp
2
+
3
+ Chirp is a GemPlugin designed to make it easy to submit tweets to Twitter. You can provide an optional URL that you want to link to in your tweet, which will be shortened automatically and included at the end of your tweet.
4
+
5
+ h2. Installation
6
+
7
+ There are a few options for installing Chirp. Please note that Chirp expects to find a configuration file at @/config/chirp.yml@. If you are using Chirp as a GemPlugin, you will need to be sure and create this file. If you are using Chirp as a normal Rails plugin, this file will be created automatically when the plugin is installed.
8
+
9
+ h3. Install as a Rails plugin:
10
+
11
+ <pre><code>script/plugin install git://github.com/bgetting/Chirp.git</code></pre>
12
+
13
+ h3. Install as a Gem:
14
+
15
+ <pre><code>sudo gem install bgetting-chirp</code></pre>
16
+
17
+ In your Rails project, put the following lines in your @environment.rb@ file:
18
+
19
+ <pre><code>config.gem "bgetting-chirp", :lib => 'chirp', :source => "http://gems.github.com"
20
+ config.gem "shorturl", :version => '>= 0.8.4'
21
+ config.gem "twitter4r", :version => '>= 0.3.1', :lib => 'twitter'</code></pre>
22
+
23
+ h2. Example
24
+
25
+ First, edit @config/chirp.yml@ to include your Twitter login and password for each environment. It's probably a good idea to set up a development Twitter account to play around with.
26
+
27
+ To post a tweet to Twitter:
28
+
29
+ <pre><code>tweet_to_twitter("This is an example tweet.")</code></pre>
30
+
31
+ Optionally, you can include a link:
32
+
33
+ <pre><code>tweet_to_twitter("This is an example tweet.", "http://www.github.com/")</code></pre>
34
+
35
+ When you include a link with your tweet, Chirp will truncate your tweet to 115 characters to leave room for a short URL at the end of the tweet. When you **do not** include a link, Chirp will truncate your tweet to the usual 140 characters allowed by Twitter.
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 0
@@ -0,0 +1,24 @@
1
+ class Chirp
2
+
3
+ def initialize
4
+ load_twitter_config
5
+ return self
6
+ end
7
+
8
+ def load_twitter_config
9
+ config = YAML.load(File.open("#{RAILS_ROOT}/config/chirp.yml"))[RAILS_ENV].symbolize_keys
10
+ @beak ||= Twitter::Client.new(:login => config[:login].to_s, :password => config[:password].to_s)
11
+ end
12
+
13
+ def tweet_to_twitter(tweet, url = nil)
14
+ unless url.blank?
15
+ message = tweet[0..115]
16
+ tinyURL = ShortURL.shorten(url)
17
+ message += " #{tinyURL}" unless tinyURL.blank?
18
+ else
19
+ message = tweet[0..139]
20
+ end
21
+ twitter.status(:post, "#{message}")
22
+ end
23
+
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class ChirpTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+
9
+ ## TODO: Write tests to verify each method
10
+
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bgetting-chirp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Getting
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-21 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shorturl
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.8.4
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: twitter4r
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.1
34
+ version:
35
+ description: Chirp is a Rails gemplugin for easily posting to Twitter
36
+ email: brian@terra-firma-design.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.textile
43
+ files:
44
+ - README.textile
45
+ - VERSION.yml
46
+ - lib/chirp.rb
47
+ - test/chirp_test.rb
48
+ - test/test_helper.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/bgetting/Chirp
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --inline-source
54
+ - --charset=UTF-8
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project:
72
+ rubygems_version: 1.2.0
73
+ signing_key:
74
+ specification_version: 2
75
+ summary: Chirp is a Rails gemplugin for easily posting to Twitter
76
+ test_files: []
77
+