ravicious-blipmimoza 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +32 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/bin/blipmimoza +66 -0
- data/lib/blipmimoza.rb +61 -0
- data/spec/blipmimoza_spec.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- metadata +84 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Rafal Cieslak
|
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.rdoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= Blipmimoza
|
2
|
+
|
3
|
+
== Czym jest Blipmimoza?
|
4
|
+
|
5
|
+
To prosty skrypt, który wykonuje następujące czynności:
|
6
|
+
|
7
|
+
* Odwiedza Twój kokpit, Bliposferę oraz tag #anonim w poszukiwaniu wiadomości, które zawierają słowo +anonim+ i które nie są starsze niż 5 minut. Jeśli takie znajdzie - zapisuje nicki autorów.
|
8
|
+
* Wchodzi na kokpit każdej osoby, która umieściła w swoim statusie słowo anonim ;-)
|
9
|
+
|
10
|
+
== Jak tego używać?
|
11
|
+
|
12
|
+
* W opcjach na Blipie "przebierasz się" za anonima.
|
13
|
+
* Pobierasz Ruby - {wersja dla Windows}[http://rubyforge.org/frs/download.php/29263/ruby186-26.exe] i instalujesz (użytkownicy innych systemów niż Windows powinni dać sobie radę...).
|
14
|
+
* Odpalasz konsolę i wpisujesz:
|
15
|
+
|
16
|
+
gem sources -a http://gems.github.com
|
17
|
+
gem install ravicious-clothmark
|
18
|
+
|
19
|
+
* Później już tylko wystarczy wklepać w konsoli:
|
20
|
+
|
21
|
+
blipmimoza -u twojnick -p twojehaslo
|
22
|
+
|
23
|
+
* Twoje hasło *nie* *jest* nigdzie zapisywane lub wysyłane. Używane jest tylko i wyłącznie w celu uwierzytelnienia użytkownika, co jest wymagane przez blipowe API.
|
24
|
+
* Zostawiasz sobie programik w tle, a resztę zrobi on sam ;)
|
25
|
+
|
26
|
+
== Leo, why?!
|
27
|
+
|
28
|
+
Just for fun.
|
29
|
+
|
30
|
+
Nazwa +Blipmimoza+ wywodzi się z {określenia użytego przez reuptake'a}[http://blip.pl/s/12657367].
|
31
|
+
|
32
|
+
Copyright (c) 2009 Rafal Cieslak. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "blipmimoza"
|
8
|
+
gem.summary = %Q{Funny tool for Blip.pl}
|
9
|
+
gem.description = %Q{Funny tool for Blip.pl}
|
10
|
+
gem.email = "ravicious@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/ravicious/blipmimoza"
|
12
|
+
gem.authors = ["Rafal Cieslak"]
|
13
|
+
gem.add_dependency "rest-client"
|
14
|
+
gem.add_dependency "crack"
|
15
|
+
gem.executables = ['blipmimoza']
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.spec_opts = %w(-fs)
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
spec.rcov_opts = ['--exclude', "spec"]
|
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
|
+
if File.exist?('VERSION')
|
43
|
+
version = File.read('VERSION')
|
44
|
+
else
|
45
|
+
version = ""
|
46
|
+
end
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "Blipmimoza #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*', 'LICENSE')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/blipmimoza
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/blipmimoza')
|
5
|
+
require "curses"
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
optparse = OptionParser.new do |opts|
|
10
|
+
@usage = opts
|
11
|
+
opts.on('-h', '--help', 'Wyswietla pomoc') do
|
12
|
+
puts opts
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
options[:user] = ""
|
17
|
+
opts.on('-u', '--user USERNAME', 'Ustawia nazwe uzytkownika') do |user|
|
18
|
+
options[:user] = user
|
19
|
+
end
|
20
|
+
|
21
|
+
options[:password] = ""
|
22
|
+
opts.on('-p', '--password PASSWORD', 'Ustawia haslo uzytkownika') do |password|
|
23
|
+
options[:password] = password
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def timestamp(time)
|
28
|
+
time.strftime('%H:%M:%S')
|
29
|
+
end
|
30
|
+
|
31
|
+
if ARGV.size < 1
|
32
|
+
puts @usage
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
optparse.parse!
|
38
|
+
rescue => e
|
39
|
+
puts e
|
40
|
+
puts "Aby zobaczyc pomoc, wpisz:"
|
41
|
+
puts "$ #{File.basename(__FILE__)} -h"
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
45
|
+
begin
|
46
|
+
@blipmimoza = Blipmimoza.new options[:user], options[:password]
|
47
|
+
rescue RestClient::Unauthorized => e
|
48
|
+
puts e
|
49
|
+
puts "Podales zly login lub haslo"
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
# Czyści ekran
|
53
|
+
Curses.refresh
|
54
|
+
puts "ALL SYSTEMS GO - #{timestamp(Time.now)}"
|
55
|
+
|
56
|
+
loop do
|
57
|
+
puts "Pobieram wiadomosci z zasobow - #{timestamp(Time.now)}"
|
58
|
+
@blipmimoza.fetch_resources
|
59
|
+
|
60
|
+
puts "Wchodze na kokpity użytkownikow - #{timestamp(Time.now)}"
|
61
|
+
@blipmimoza.fetch_users
|
62
|
+
|
63
|
+
puts "Czekam 5 minut na nastepne pobranie wiadomosci... - #{timestamp(Time.now)}"
|
64
|
+
sleep 300
|
65
|
+
puts # Dla lepszej czytelności
|
66
|
+
end
|
data/lib/blipmimoza.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "restclient"
|
2
|
+
require "crack"
|
3
|
+
|
4
|
+
class Blipmimoza
|
5
|
+
attr_reader :dashboard, :tag, :bliposphere
|
6
|
+
# Tworzy nowa klase, przy okazji sprawdzajac poprawnosc wprowadzonych danych
|
7
|
+
def initialize(login, password)
|
8
|
+
@login = login
|
9
|
+
@password = password
|
10
|
+
|
11
|
+
# Tablica z nickami uzytkownikow, ktorych wiadomosci zawieraly slowo 'anonim'
|
12
|
+
@users = []
|
13
|
+
|
14
|
+
# Przechowuje glowny zasob
|
15
|
+
@blip = RestClient::Resource.new 'http://api.blip.pl', :user => @login, :password => @password, :accept => 'application/json', :headers => {:blip_api => 0.02}
|
16
|
+
|
17
|
+
# Przechowuje poszczegolne zasoby
|
18
|
+
@resources = {
|
19
|
+
:dashboard => @blip['/dashboard'],
|
20
|
+
:tag => @blip['/tags/anonim'],
|
21
|
+
:bliposphere => @blip['/bliposphere']}
|
22
|
+
|
23
|
+
# Sprawdza poprawnosc loginu i hasla
|
24
|
+
@blip['/dashboard?limit=1'].get :accept => 'application/json'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Odwiedza kokpit pojedynczego uzytkownika
|
28
|
+
def get_dashboard_of(user)
|
29
|
+
@blip["/users/#{user}/dashboard?limit=1"].get :accept => 'application/json'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Pobiera wiadomosci z danego zasobu
|
33
|
+
def messages_from(resource)
|
34
|
+
resource = resource.to_sym
|
35
|
+
raise ArgumentError, "Invalid resource - #{resource}" unless @resources.include?(resource)
|
36
|
+
|
37
|
+
Crack::JSON.parse(@resources[resource].get :accept => 'application/json')
|
38
|
+
end
|
39
|
+
|
40
|
+
# Jesli wiadomosc zawiera slowo 'anonim' i powstala w przeciagu ostatnich 5 minut,
|
41
|
+
# dodaje nick autora wiadomosci do tablicy @users
|
42
|
+
def fetch_resources
|
43
|
+
@resources.each_key do |resource|
|
44
|
+
messages_from(resource).each do |msg|
|
45
|
+
if (msg['body'].match(/anonim/i) and Time.parse(msg['created_at']) > Time.now - 300)
|
46
|
+
@users.push(msg['user_path'].gsub('/users/', ''))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Odwiedza kokpit kazdego uzytkownika z tablicy @users
|
53
|
+
def fetch_users
|
54
|
+
puts "Lista uzytkownikow jest pusta" if @users.empty?
|
55
|
+
@users.uniq.each do |user|
|
56
|
+
get_dashboard_of user
|
57
|
+
puts "Odwiedzilem kokpit uzytkownika #{user}"
|
58
|
+
end
|
59
|
+
@users.clear
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Blipmimoza" do
|
4
|
+
# TODO: Full test coverage ;-)
|
5
|
+
before :all do
|
6
|
+
@blipmimoza = Blipmimoza.new(ENV['blipuser'], ENV['blippass'])
|
7
|
+
end
|
8
|
+
it 'should raise an error if invalid credentials were specified' do
|
9
|
+
lambda {Blipmimoza.new('pokapulpit', 'test')}.should raise_error RestClient::Unauthorized
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should raise an error if invalid resource was specified' do
|
13
|
+
lambda {@blipmimoza.messages_from :facebook}.should raise_error ArgumentError
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ravicious-blipmimoza
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rafal Cieslak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-29 00:00:00 -07:00
|
13
|
+
default_executable: blipmimoza
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rest-client
|
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
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: crack
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Funny tool for Blip.pl
|
36
|
+
email: ravicious@gmail.com
|
37
|
+
executables:
|
38
|
+
- blipmimoza
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- bin/blipmimoza
|
52
|
+
- lib/blipmimoza.rb
|
53
|
+
- spec/blipmimoza_spec.rb
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/ravicious/blipmimoza
|
57
|
+
licenses:
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.5
|
79
|
+
signing_key:
|
80
|
+
specification_version: 2
|
81
|
+
summary: Funny tool for Blip.pl
|
82
|
+
test_files:
|
83
|
+
- spec/blipmimoza_spec.rb
|
84
|
+
- spec/spec_helper.rb
|