SRUG-twitter-clone-client 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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Szymon Nowak
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,7 @@
1
+ = twitter-clone-client
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Szymon Nowak. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "twitter-clone-client"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "szimek@gmail.com"
10
+ gem.homepage = "http://github.com/szimek/twitter-clone-client"
11
+ gem.authors = ["Szymon Nowak"]
12
+
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = false
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "twitter-clone-client #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 2
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'trollop'
5
+ require 'activeresource'
6
+
7
+ module TwitterClone
8
+
9
+ class Status < ActiveResource::Base
10
+ self.site = "http://localhost:3000/"
11
+ Status.prefix = "/users/:user_id/"
12
+
13
+ def to_s
14
+ "#{user.login}:\t #{body} at #{created_at}"
15
+ end
16
+ end
17
+
18
+ class Client
19
+
20
+ SUB_COMMANDS = %w(show create delete)
21
+
22
+ def initialize
23
+ @opts = Trollop::options do
24
+ banner "Twitter clone RESTful client"
25
+ version "0.0.1"
26
+ stop_on SUB_COMMANDS
27
+ end
28
+
29
+ @cmd = ARGV.shift # get the subcommand
30
+ @cmd_opts = case @cmd
31
+ when "show"
32
+ Trollop::options do
33
+ opt :user, "User name or id that you want to show tweets for", :type => :string
34
+ end
35
+ when "create"
36
+ Trollop::options do
37
+ opt :login, "Login", :type => :string, :required => true
38
+ opt :password, "Password", :type => :string, :required => true
39
+ opt :text, "Your status", :type => :string, :required => true
40
+ end
41
+ when "delete"
42
+ Trollop::options do
43
+ opt :login, "Login", :type => :string, :required => true
44
+ opt :password, "Password", :type => :string, :required => true
45
+ opt :id, "ID of the tweet you want to delete", :type => :int, :required => true
46
+ end
47
+ else
48
+ Trollop::die "unknown subcommand #{@cmd.inspect}"
49
+ end
50
+
51
+ self.send(@cmd) # execute the subcommand
52
+ end
53
+
54
+ def show
55
+ if @cmd_opts[:user]
56
+ params = {:user_id => @cmd_opts[:user]}
57
+ else
58
+ params = {}
59
+ Status.prefix = "/"
60
+ end
61
+ @statuses = Status.find(:all, :params => params)
62
+ @statuses.each do |status|
63
+ puts status
64
+ end
65
+ end
66
+
67
+ def create
68
+ setup_credentials
69
+ Status.create(:body => @cmd_opts[:text], :user_id => @cmd_opts[:login])
70
+ puts "Status created successfully"
71
+ end
72
+
73
+ def delete
74
+ setup_credentials
75
+ Status.delete(@cmd_opts[:id], :user_id => @cmd_opts[:login])
76
+ puts "Status destroy successfully"
77
+ end
78
+
79
+ private
80
+ def setup_credentials
81
+ if @cmd_opts[:login] && @cmd_opts[:password]
82
+ Status.user = @cmd_opts[:login]
83
+ Status.password = @cmd_opts[:password]
84
+ end
85
+ end
86
+
87
+ end
88
+ end
89
+
90
+ TwitterClone::Client.new
@@ -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_clone_client'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class TwitterCloneClientTest < 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,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SRUG-twitter-clone-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Szymon Nowak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-26 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: szimek@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION.yml
30
+ - lib/twitter_clone_client.rb
31
+ - test/test_helper.rb
32
+ - test/twitter_clone_client_test.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/szimek/twitter-clone-client
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --charset=UTF-8
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.2.0
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: TODO
59
+ test_files:
60
+ - test/test_helper.rb
61
+ - test/twitter_clone_client_test.rb