twiq 0.0.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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 tily
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.
@@ -0,0 +1,44 @@
1
+ Twiq
2
+ ====
3
+
4
+ Description
5
+ -----------
6
+
7
+ Simple queue system for Twitter.
8
+
9
+ Usage
10
+ -----
11
+
12
+ enq user [text] enqueue status text (if text is not specified, read STDIN lines)
13
+ deq user dequeue to post to twitter
14
+ list [user] list queue
15
+ help show this help
16
+ clear [user] clear queues (if user is not specified, delete all records)
17
+
18
+ Note
19
+ ----
20
+
21
+ * creates pit entry "twiq-[username]"
22
+ * creates database file "~/.twiq"
23
+
24
+ Requirement
25
+ -----------
26
+
27
+ * sequel
28
+ * oauth-cli-twitter
29
+
30
+ Install
31
+ -------
32
+
33
+ ### Archive Installation
34
+
35
+ rake install
36
+
37
+ ### Gem Installation
38
+
39
+ gem install twiq
40
+
41
+ Copyright
42
+ ---------
43
+
44
+ Copyright (c) 2010 tily. See LICENSE for details.
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "twiq"
8
+ gem.summary = %Q{simple queue system for twitter}
9
+ gem.description = %Q{simple queue system for twitter}
10
+ gem.email = "tily05@gmail.com"
11
+ gem.homepage = "http://github.com/tily/ruby-twiq"
12
+ gem.authors = ["tily"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "sequel"
15
+ gem.add_dependency "oauth-cli-twitter"
16
+ gem.executables = ["twiq"]
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ #require 'spec/rake/spectask'
25
+ #Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ # spec.libs << 'lib' << 'spec'
27
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ #end
29
+ #
30
+ #Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ # spec.libs << 'lib' << 'spec'
32
+ # spec.pattern = 'spec/**/*_spec.rb'
33
+ # spec.rcov = true
34
+ #end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :spec
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "twiq #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+ require 'twiq'
4
+
5
+ cmd = ARGV.shift
6
+ cmds = %w(deq enq list clear)
7
+
8
+ begin
9
+ if cmd && cmds.include?(cmd)
10
+ Twiq::Commands.stdout = STDOUT
11
+ Twiq::Commands.stdin = STDIN
12
+ Twiq::Commands.send(cmd, ARGV)
13
+ else
14
+ raise Twiq::Error, 'command not found.'
15
+ end
16
+ rescue Twiq::Error => e
17
+ puts "Error: #{e}"
18
+ puts <<-EOS
19
+ Usage: twiq command arg1 [arg2]
20
+ enq user [text] enqueue status text (if text is not specified, read STDIN lines)
21
+ deq user dequeue to post to twitter
22
+ list [user] list queue
23
+ help show this help
24
+ clear [user] clear queues (if user is not specified, delete all records)
25
+ EOS
26
+ exit 1
27
+ end
28
+
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'sequel'
3
+ require 'oauth/cli/twitter'
4
+
5
+ require 'twiq/statuses'
6
+ require 'twiq/commands'
7
+
8
+ module Twiq
9
+ class Error < StandardError; end
10
+ end
11
+
@@ -0,0 +1,56 @@
1
+
2
+ module Twiq
3
+ module Commands
4
+ extend self
5
+ extend OAuth::CLI::Twitter
6
+
7
+ CONSUMER_KEY = '9gu06q0SOcJLOwKpAeaClA'
8
+ CONSUMER_SECRET = 'K8Kb6JpfRkzjQl4IRn2CWbCL67rEtO0mSeoqKCQdSFQ'
9
+
10
+ attr_accessor :stdout, :stdin
11
+
12
+ def enq(args)
13
+ case args.size
14
+ when 0
15
+ raise Error, 'arguments required (at least 1)'
16
+ when 1
17
+ while text = stdin.gets
18
+ Statuses.insert(:user => args[0], :text => text)
19
+ end
20
+ else
21
+ Statuses.insert(:user => args[0], :text => args[1])
22
+ end
23
+ end
24
+
25
+ def deq(args)
26
+ raise Error, 'user not specified.' if args.size == 0
27
+ s = Statuses.filter(:user => args[0]).first
28
+ Statuses.filter(:id => s[:id]).delete
29
+ at = get_access_token(CONSUMER_KEY, CONSUMER_SECRET, :pit => 'twiq-' + s[:user])
30
+ at.post('/statuses/update.json', 'status' => s[:text])
31
+ end
32
+
33
+ def list(args)
34
+ statuses = args.size > 0 ? Statuses.filter(:user => args[0]) : Statuses.all
35
+ stdout.puts "id\tuser\ttext"
36
+ statuses.each do |s|
37
+ stdout.puts "#{s[:id]}\t#{s[:user]}\t#{s[:text]}"
38
+ end
39
+ end
40
+
41
+ def clear(args)
42
+ if args.size == 0
43
+ Statuses.delete
44
+ else
45
+ args.each do |arg|
46
+ case arg
47
+ when String then key = :user
48
+ when Integer then key = :id
49
+ else next
50
+ end
51
+ Statuses[key => arg].delete
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,13 @@
1
+ Sequel::Model.plugin(:schema)
2
+ Sequel.sqlite(ENV['HOME'] + '/.twiq')
3
+
4
+ module Twiq
5
+ class Statuses < Sequel::Model
6
+ set_schema do
7
+ primary_key :id
8
+ column :user, :string
9
+ column :text, :string
10
+ end
11
+ create_table! unless table_exists?
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'ruby-twiq'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "RubyTwiq" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twiq
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - tily
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-13 00:00:00 +09:00
19
+ default_executable: twiq
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: sequel
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: oauth-cli-twitter
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ description: simple queue system for twitter
66
+ email: tily05@gmail.com
67
+ executables:
68
+ - twiq
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - LICENSE
73
+ - README.md
74
+ files:
75
+ - .document
76
+ - .gitignore
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - VERSION
81
+ - bin/twiq
82
+ - lib/twiq.rb
83
+ - lib/twiq/commands.rb
84
+ - lib/twiq/statuses.rb
85
+ - spec/spec.opts
86
+ - spec/spec_helper.rb
87
+ - spec/twiq_commands_speq.rb
88
+ has_rdoc: true
89
+ homepage: http://github.com/tily/ruby-twiq
90
+ licenses: []
91
+
92
+ post_install_message:
93
+ rdoc_options:
94
+ - --charset=UTF-8
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ requirements: []
116
+
117
+ rubyforge_project:
118
+ rubygems_version: 1.3.7
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: simple queue system for twitter
122
+ test_files:
123
+ - spec/twiq_commands_speq.rb
124
+ - spec/spec_helper.rb