chmeee-twitter-fusefs 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 chmeee
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.markdown ADDED
@@ -0,0 +1,71 @@
1
+ # twitter-fusefs
2
+
3
+ twitter-fusefs is a program to mount your twitter account as a filesystem.
4
+
5
+ ## Directory structure
6
+ When you run it it will generate the following directory structure:
7
+
8
+ direct_messages followers/ friends/ README replies timeline updates
9
+
10
+ ### Files
11
+ * `direct_messages`: when 'read' will output your direct_messages
12
+ * `README`: when 'read' will output some info about twitter-fusefs
13
+ * `replies`: when 'read' will output your replies
14
+ * `timeline`: when 'read' will output your timeline (with your friends)
15
+ * `updates`: when 'read' will output your tweets, when 'written to` will create a new tweet with the msg
16
+
17
+ ### Directories
18
+ * `followers/`: has a list of files, each with a follower's nick
19
+ * `friends/`: has a list of files, each with a friend's nick
20
+
21
+ When 'read' from users' files will output his/her timeline, when 'written to' users' files will update your timeline adding @user.
22
+
23
+ ## Install and Use
24
+
25
+ Until there's a ruby gem you can do the following
26
+
27
+ 1. Install the twitter gem: `sudo gem install twitter`
28
+ 2. Install [Ruby FuseFS][1] (as far as I know, there's no ruby gem)
29
+ 3. Download twitter-fusefs, uncompress
30
+ 4. Create a directory ~/.twitter with
31
+
32
+ email: yourtwitteraccountmail
33
+ password: yourcomplexpassword
34
+
35
+ 5. `mkdir` a directory where you want to mount
36
+ 6. `./bin/twitter-fusefs yourdirectory`
37
+
38
+ [1]: http://rubyforge.org/projects/fusefs
39
+
40
+ Please, note that this script does not require rubygems, as you may not be using it. If you do you'll have to tell ruby so. The best way I think is through
41
+
42
+ export RUBYOPT="rubygems"
43
+
44
+ ## TO-DO
45
+
46
+ twitter-fusefs is still in design and development. I'm still thinking about some of the details, so here's a to-do list:
47
+
48
+ * Use SSL
49
+ * Access user status: /status for the mounting user and 'maybe' /(followers|friends)/user_status for the rest of users
50
+ * Unfollow people with rm on /friends
51
+ * Follow with touch on /friends
52
+ * Block with rm on /followers
53
+ * Reformat the output of tweets and add more information (like time, app, in respond to, etc.)
54
+ * Access to Twitter trends (whatever that is)
55
+ * Produce a ruby-gem
56
+ * Make a github page for the project
57
+
58
+ ## Note on Patches/Pull Requests
59
+
60
+ * Fork the project.
61
+ * Make your feature addition or bug fix.
62
+ * Add tests for it. This is important so I don't break it in a
63
+ future version unintentionally.
64
+ * Commit, do not mess with rakefile, version, or history.
65
+ (if you want to have your own version, that is fine but
66
+ bump version in a commit by itself I can ignore when I pull)
67
+ * Send me a pull request. Bonus points for topic branches.
68
+
69
+ ## Copyright
70
+
71
+ Copyright (c) 2009 chmeee. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "twitter-fusefs"
8
+ gem.summary = %Q{Access twitter as a filesystem}
9
+ gem.description = %Q{Mount your twitter account as a userspace filesystem, access your tweets as files, update echo'ing over files}
10
+ gem.email = "chmeee@gmail.com"
11
+ gem.homepage = "http://github.com/chmeee/twitter-fusefs"
12
+ gem.authors = ["chmeee"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ gem.files = FileList["[A-Z]*", "{bin,helpers,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
15
+ gem.bindir = 'bin'
16
+ gem.executables = ['twitter-fusefs']
17
+ gem.add_dependency 'twitter'
18
+ end
19
+
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/*_test.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/*_test.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+
45
+
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ if File.exist?('VERSION')
52
+ version = File.read('VERSION')
53
+ else
54
+ version = ""
55
+ end
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "twitter-fusefs #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter-fusefs')
4
+
5
+ tfs = TwitterFuseFS.new
6
+ FuseFS.set_root(tfs)
7
+ FuseFS.mount_under ARGV[0] || "/home/jmpavon/Mount/twitter"
8
+ FuseFS.run
@@ -0,0 +1,40 @@
1
+ # Created by John Nunemaker for ruby twitter gem: http://twitter.rubyforge.org/
2
+
3
+ class ConfigStore
4
+ attr_reader :file
5
+
6
+ def initialize(file)
7
+ @file = file
8
+ end
9
+
10
+ def load
11
+ @config ||= YAML::load(open(file))
12
+ self
13
+ end
14
+
15
+ def [](key)
16
+ load
17
+ @config[key]
18
+ end
19
+
20
+ def []=(key, value)
21
+ @config[key] = value
22
+ end
23
+
24
+ def delete(*keys)
25
+ keys.each { |key| @config.delete(key) }
26
+ save
27
+ self
28
+ end
29
+
30
+ def update(c={})
31
+ @config.merge!(c)
32
+ save
33
+ self
34
+ end
35
+
36
+ def save
37
+ File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
38
+ self
39
+ end
40
+ end
@@ -0,0 +1,74 @@
1
+ require File.join(File.dirname(__FILE__), 'twitter_account.rb')
2
+ require 'fusefs'
3
+ include FuseFS
4
+ require 'pp'
5
+
6
+ class TwitterFuseFS < FuseFS::FuseDir
7
+ def initialize
8
+ @twitter_user = TwitterAccount.new
9
+ @files = %w{ direct_messages updates timeline replies README}
10
+ @dirs = %w{ followers friends }
11
+ end
12
+
13
+ def contents(path)
14
+ case path
15
+ when "/"
16
+ @dirs + @files
17
+ when "/friends"
18
+ @twitter_user.friends
19
+ when "/followers"
20
+ @twitter_user.followers
21
+ end
22
+ end
23
+
24
+ def file?(path)
25
+ dir, base = scan_path(path)
26
+
27
+ root_cond = (@files.include? dir and base.nil?)
28
+ dirs_cond = (@dirs.include? dir and (@twitter_user.friends.include? base or @twitter_user.followers.include? base))
29
+
30
+ root_cond or dirs_cond
31
+ end
32
+
33
+ def directory?(path)
34
+ dir_items = scan_path(path)
35
+ @dirs.include?(dir_items.last)
36
+ end
37
+
38
+ def read_file(path)
39
+ case path
40
+ when "/timeline"
41
+ @twitter_user.friends_timeline
42
+ when "/direct_messages"
43
+ @twitter_user.direct_messages
44
+ when "/updates"
45
+ @twitter_user.updates
46
+ when "/replies"
47
+ @twitter_user.replies
48
+ when "/README"
49
+ "twitter-fusefs\n"
50
+ when /\/(followers|friends)\/(.*)/
51
+ @twitter_user.user_timeline($2)
52
+ end
53
+ end
54
+
55
+ def write_to(path, body)
56
+ if !body.empty? # don't know why it gets executed twice, first time without body
57
+ case path
58
+ when "/updates"
59
+ @twitter_user.update body
60
+ when /\/(followers|friends)\/(.*)$/
61
+ body = "@#{$2} #{body}"
62
+ @twitter_user.update body
63
+ end
64
+ end
65
+ end
66
+
67
+ def can_write?(path)
68
+ path == "/updates" or path =~ /\/(followers|friends)\/.*/
69
+ end
70
+
71
+ def can_delete?(path)
72
+ can_write?(path)
73
+ end
74
+ end
@@ -0,0 +1,52 @@
1
+ require 'twitter'
2
+ require File.join(File.dirname(__FILE__), '..', 'helpers', 'config_store')
3
+
4
+ class TwitterAccount
5
+ attr_reader :friends, :followers
6
+
7
+ def initialize
8
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
9
+ httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
10
+ @account = Twitter::Base.new(httpauth)
11
+
12
+ @friends = @account.friends.map do |friend|
13
+ friend.screen_name
14
+ end
15
+
16
+ @followers = @account.followers.map do |follower|
17
+ follower.screen_name
18
+ end
19
+ end
20
+
21
+ # wating for a better formating (see twitter gem bien)
22
+ # this methods are looking for some factoring
23
+ def friends_timeline
24
+ texts = @account.friends_timeline.map {|t| "#{t.user.screen_name}> #{t.text}"}
25
+ texts.join("\n") + "\n"
26
+ end
27
+
28
+ def direct_messages
29
+ texts = @account.direct_messages.map {|t| "#{t.sender.screen_name}> #{t.text}"}
30
+ texts.join("\n") + "\n"
31
+ end
32
+
33
+ def updates
34
+ texts = @account.user_timeline.map {|t| "#{t.user.screen_name}> #{t.text}"}
35
+ texts.join("\n") + "\n"
36
+ end
37
+
38
+ def replies
39
+ texts = @account.replies.map {|t| "#{t.user.screen_name}> #{t.text}"}
40
+ texts.join("\n") + "\n"
41
+ end
42
+
43
+ def update(msg)
44
+ @account.update msg
45
+ end
46
+
47
+ def user_timeline(user)
48
+ texts = Twitter::Search.new(user).map {|t| "#{t.from_user}> #{t.text}"}
49
+ texts.join("\n") + "\n"
50
+ end
51
+
52
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'twitter-fusefs'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class TwitterFusefsTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chmeee-twitter-fusefs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - chmeee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-20 00:00:00 -07:00
13
+ default_executable: twitter-fusefs
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: twitter
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Mount your twitter account as a userspace filesystem, access your tweets as files, update echo'ing over files
26
+ email: chmeee@gmail.com
27
+ executables:
28
+ - twitter-fusefs
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.markdown
34
+ files:
35
+ - LICENSE
36
+ - README.markdown
37
+ - Rakefile
38
+ - VERSION
39
+ - bin/twitter-fusefs
40
+ - helpers/config_store.rb
41
+ - lib/twitter-fusefs.rb
42
+ - lib/twitter_account.rb
43
+ - test/test_helper.rb
44
+ - test/twitter-fusefs_test.rb
45
+ has_rdoc: false
46
+ homepage: http://github.com/chmeee/twitter-fusefs
47
+ licenses:
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Access twitter as a filesystem
72
+ test_files:
73
+ - test/test_helper.rb
74
+ - test/twitter-fusefs_test.rb