pingfm 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +26 -0
- data/{README → README.rdoc} +40 -50
- data/Rakefile +11 -26
- data/bin/pingfm +37 -31
- data/lib/pingfm.rb +5 -53
- data/lib/pingfm/client.rb +194 -179
- data/lib/pingfm/config.rb +36 -0
- data/pingfm.gemspec +27 -0
- data/spec/pingfm/client_spec.rb +300 -0
- data/spec/pingfm/config_spec.rb +21 -0
- data/spec/pingfm_spec.rb +3 -305
- data/spec/pingfm_spec.yml +2 -0
- data/spec/spec_helper.rb +28 -40
- metadata +63 -60
- data/History.txt +0 -12
- data/Manifest.txt +0 -25
- data/lib/pingfm/keyloader.rb +0 -58
- data/spec/keyloader_spec.rb +0 -43
- data/tasks/ann.rake +0 -81
- data/tasks/bones.rake +0 -21
- data/tasks/gem.rake +0 -126
- data/tasks/git.rake +0 -41
- data/tasks/manifest.rake +0 -49
- data/tasks/notes.rake +0 -28
- data/tasks/post_load.rake +0 -39
- data/tasks/rdoc.rake +0 -51
- data/tasks/rubyforge.rake +0 -57
- data/tasks/setup.rb +0 -268
- data/tasks/spec.rake +0 -55
- data/tasks/svn.rake +0 -48
- data/tasks/test.rake +0 -38
data/spec/spec_helper.rb
CHANGED
@@ -1,33 +1,22 @@
|
|
1
|
-
|
1
|
+
require 'rspec'
|
2
|
+
require "#{File.dirname(__FILE__)}/../lib/pingfm"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# RSpec uses it's own mocking framework by default. If you prefer to
|
10
|
-
# use mocha, flexmock or RR, uncomment the appropriate line:
|
11
|
-
#
|
12
|
-
# config.mock_with :mocha
|
13
|
-
# config.mock_with :flexmock
|
14
|
-
# config.mock_with :rr
|
15
|
-
# end
|
16
|
-
|
17
|
-
def init_ok_response(service_type)
|
18
|
-
@service_type = service_type
|
19
|
-
@response = <<EOXML
|
4
|
+
# TODO: Replace this XML string bullshit.
|
5
|
+
RSpec.configure do |config|
|
6
|
+
def init_ok_response(service_type)
|
7
|
+
@service_type = service_type
|
8
|
+
@response = <<EOXML
|
20
9
|
<?xml version="1.0"?>
|
21
10
|
<rsp status="OK">
|
22
11
|
<transaction>12345</transaction>
|
23
12
|
<method>#{@service_type}</method>
|
24
13
|
</rsp>
|
25
14
|
EOXML
|
26
|
-
end
|
15
|
+
end
|
27
16
|
|
28
|
-
def init_fail_response(service_type)
|
29
|
-
|
30
|
-
|
17
|
+
def init_fail_response(service_type)
|
18
|
+
@service_type = service_type
|
19
|
+
@response = <<EOXML
|
31
20
|
<?xml version="1.0"?>
|
32
21
|
<rsp status="FAIL">
|
33
22
|
<transaction>12345</transaction>
|
@@ -35,11 +24,11 @@ def init_fail_response(service_type)
|
|
35
24
|
<message>You suck</message>
|
36
25
|
</rsp>
|
37
26
|
EOXML
|
38
|
-
end
|
27
|
+
end
|
39
28
|
|
40
|
-
def init_service_response
|
41
|
-
|
42
|
-
|
29
|
+
def init_service_response
|
30
|
+
@service_type = 'user.services'
|
31
|
+
@response = <<EOXML
|
43
32
|
<?xml version="1.0"?>
|
44
33
|
<rsp status="OK">
|
45
34
|
<transaction>12345</transaction>
|
@@ -60,11 +49,11 @@ def init_service_response
|
|
60
49
|
</services>
|
61
50
|
</rsp>
|
62
51
|
EOXML
|
63
|
-
end
|
52
|
+
end
|
64
53
|
|
65
|
-
def init_system_services_response
|
66
|
-
|
67
|
-
|
54
|
+
def init_system_services_response
|
55
|
+
@service_type = 'system.services'
|
56
|
+
@response = <<EOXML
|
68
57
|
<rsp status="OK">
|
69
58
|
<transaction>12345</transaction>
|
70
59
|
<method>system.services</method>
|
@@ -82,11 +71,11 @@ def init_system_services_response
|
|
82
71
|
</services>
|
83
72
|
</rsp>
|
84
73
|
EOXML
|
85
|
-
end
|
74
|
+
end
|
86
75
|
|
87
|
-
def init_trigger_response
|
88
|
-
|
89
|
-
|
76
|
+
def init_trigger_response
|
77
|
+
@service_type = 'user.triggers'
|
78
|
+
@response = <<EOXML
|
90
79
|
<?xml version="1.0"?>
|
91
80
|
<rsp status="OK">
|
92
81
|
<transaction>12345</transaction>
|
@@ -105,11 +94,11 @@ def init_trigger_response
|
|
105
94
|
</triggers>
|
106
95
|
</rsp>
|
107
96
|
EOXML
|
108
|
-
end
|
97
|
+
end
|
109
98
|
|
110
|
-
def init_latest_response
|
111
|
-
|
112
|
-
|
99
|
+
def init_latest_response
|
100
|
+
@service_type = 'user.latest'
|
101
|
+
@response = <<EOXML
|
113
102
|
<?xml version="1.0"?>
|
114
103
|
<rsp status="OK">
|
115
104
|
<transaction>12345</transaction>
|
@@ -148,6 +137,5 @@ def init_latest_response
|
|
148
137
|
</messages>
|
149
138
|
</rsp>
|
150
139
|
EOXML
|
140
|
+
end
|
151
141
|
end
|
152
|
-
|
153
|
-
# EOF
|
metadata
CHANGED
@@ -1,85 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingfm
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
- Krunoslav Husak
|
7
|
+
authors:
|
8
8
|
- Dale Campbell
|
9
9
|
- Kevin Williams
|
10
|
+
- Krunoslav Husak
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
-
|
14
|
+
date: 2011-06-12 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: slop
|
18
|
+
requirement: &75088130 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *75088130
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: &75087470 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.6.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *75087470
|
38
|
+
description: Ping.fm (http://ping.fm) is a simple service that makes updating your
|
39
|
+
social networks a snap, and this it's Ruby library.
|
40
|
+
email:
|
41
|
+
- oshuma@gmail.com
|
21
42
|
- kevwil@gmail.com
|
22
|
-
executables:
|
43
|
+
executables:
|
23
44
|
- pingfm
|
24
45
|
extensions: []
|
25
|
-
|
26
|
-
|
27
|
-
- History.txt
|
28
|
-
- bin/pingfm
|
29
|
-
files:
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
30
48
|
- .gitignore
|
31
|
-
-
|
32
|
-
-
|
33
|
-
- README
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.rdoc
|
34
52
|
- Rakefile
|
35
53
|
- bin/pingfm
|
36
54
|
- lib/pingfm.rb
|
37
55
|
- lib/pingfm/client.rb
|
38
|
-
- lib/pingfm/
|
39
|
-
-
|
56
|
+
- lib/pingfm/config.rb
|
57
|
+
- pingfm.gemspec
|
58
|
+
- spec/pingfm/client_spec.rb
|
59
|
+
- spec/pingfm/config_spec.rb
|
40
60
|
- spec/pingfm_spec.rb
|
61
|
+
- spec/pingfm_spec.yml
|
41
62
|
- spec/spec_helper.rb
|
42
|
-
|
43
|
-
- tasks/bones.rake
|
44
|
-
- tasks/gem.rake
|
45
|
-
- tasks/git.rake
|
46
|
-
- tasks/manifest.rake
|
47
|
-
- tasks/notes.rake
|
48
|
-
- tasks/post_load.rake
|
49
|
-
- tasks/rdoc.rake
|
50
|
-
- tasks/rubyforge.rake
|
51
|
-
- tasks/setup.rb
|
52
|
-
- tasks/spec.rake
|
53
|
-
- tasks/svn.rake
|
54
|
-
- tasks/test.rake
|
55
|
-
has_rdoc: true
|
56
|
-
homepage: http://pingfm.rubyforge.org/
|
63
|
+
homepage: http://github.com/Oshuma/pingfm
|
57
64
|
licenses: []
|
58
|
-
|
59
65
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
- --
|
62
|
-
|
63
|
-
require_paths:
|
66
|
+
rdoc_options:
|
67
|
+
- --inline-source
|
68
|
+
require_paths:
|
64
69
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
77
82
|
requirements: []
|
78
|
-
|
79
83
|
rubyforge_project: pingfm
|
80
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.8.5
|
81
85
|
signing_key:
|
82
86
|
specification_version: 3
|
83
|
-
summary: Ping.fm
|
87
|
+
summary: A Ping.fm Ruby library.
|
84
88
|
test_files: []
|
85
|
-
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
.gitignore
|
2
|
-
History.txt
|
3
|
-
Manifest.txt
|
4
|
-
README
|
5
|
-
Rakefile
|
6
|
-
bin/pingfm
|
7
|
-
lib/pingfm.rb
|
8
|
-
lib/pingfm/client.rb
|
9
|
-
lib/pingfm/keyloader.rb
|
10
|
-
spec/keyloader_spec.rb
|
11
|
-
spec/pingfm_spec.rb
|
12
|
-
spec/spec_helper.rb
|
13
|
-
tasks/ann.rake
|
14
|
-
tasks/bones.rake
|
15
|
-
tasks/gem.rake
|
16
|
-
tasks/git.rake
|
17
|
-
tasks/manifest.rake
|
18
|
-
tasks/notes.rake
|
19
|
-
tasks/post_load.rake
|
20
|
-
tasks/rdoc.rake
|
21
|
-
tasks/rubyforge.rake
|
22
|
-
tasks/setup.rb
|
23
|
-
tasks/spec.rake
|
24
|
-
tasks/svn.rake
|
25
|
-
tasks/test.rake
|
data/lib/pingfm/keyloader.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Pingfm
|
4
|
-
|
5
|
-
class KeyloadingError < Exception; end
|
6
|
-
|
7
|
-
# manages the YAML file containing the keys - encryption might be nice, might be overkill
|
8
|
-
class Keyloader
|
9
|
-
|
10
|
-
# Path to YAML file containing keys
|
11
|
-
attr_accessor :keyfile
|
12
|
-
|
13
|
-
# ping.fm uses this as the key for the registered application
|
14
|
-
attr_accessor :api_key
|
15
|
-
|
16
|
-
# ping.fm uses this as the key for the user
|
17
|
-
attr_accessor :app_key
|
18
|
-
|
19
|
-
KEY_PATH = (RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'])
|
20
|
-
KEY_FILE = '.pingfm_keys.yml'
|
21
|
-
|
22
|
-
def initialize(keyfile = File.expand_path(File.join(KEY_PATH, KEY_FILE)))
|
23
|
-
@api_key = nil
|
24
|
-
@keyfile = keyfile
|
25
|
-
|
26
|
-
# load keys on init
|
27
|
-
load_keys!
|
28
|
-
end
|
29
|
-
|
30
|
-
# load a new set of keys
|
31
|
-
def load_keys(keyfile)
|
32
|
-
if File.exist?(keyfile) and File.readable?(keyfile)
|
33
|
-
data = YAML::load_file(keyfile)
|
34
|
-
@keyfile = keyfile if @keyfile.nil?
|
35
|
-
@api_key = data['api_key']
|
36
|
-
@app_key = data['app_key']
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# load keys using the known keyfile
|
41
|
-
def load_keys!
|
42
|
-
load_keys(@keyfile)
|
43
|
-
end
|
44
|
-
|
45
|
-
# if keys have been loaded successfully
|
46
|
-
def has_keys?
|
47
|
-
return true unless @api_key.nil? or @app_key.nil?
|
48
|
-
return false
|
49
|
-
end
|
50
|
-
|
51
|
-
# save key data to keyfile
|
52
|
-
def save
|
53
|
-
File.open( @keyfile, 'w+' ) do |out|
|
54
|
-
YAML::dump( {'api_key' => @api_key, 'app_key' => @app_key}, out )
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/spec/keyloader_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
describe Pingfm::Keyloader do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
@keydata = {'api_key' => 'foo', 'app_key' => 'bar'}
|
8
|
-
@tf = Tempfile.new('keys.yml')
|
9
|
-
YAML::dump(@keydata, @tf)
|
10
|
-
@tmp_path = @tf.path
|
11
|
-
@tf.close
|
12
|
-
end
|
13
|
-
|
14
|
-
after(:each) do
|
15
|
-
@tf.unlink
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should use keys from yaml file if found" do
|
19
|
-
loader = Pingfm::Keyloader.new(@tmp_path)
|
20
|
-
loader.has_keys?.should be_true
|
21
|
-
loader.keyfile.should eql(@tmp_path)
|
22
|
-
loader.api_key.should eql(@keydata['api_key'])
|
23
|
-
loader.app_key.should eql(@keydata['app_key'])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should save keys to keyfile" do
|
27
|
-
loader = Pingfm::Keyloader.new(@tmp_path)
|
28
|
-
loader.app_key = 'baz'
|
29
|
-
loader.save
|
30
|
-
|
31
|
-
loader.has_keys?.should be_true
|
32
|
-
File.exist?(loader.keyfile).should be_true
|
33
|
-
File.readable?(loader.keyfile).should be_true
|
34
|
-
YAML::load_file(loader.keyfile)['app_key'].should eql('baz')
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should behave if keys cannot be loaded" do
|
38
|
-
loader = Pingfm::Keyloader.new('/tmp/nofile')
|
39
|
-
loader.has_keys?.should be_false
|
40
|
-
loader.api_key.should be_nil
|
41
|
-
loader.app_key.should be_nil
|
42
|
-
end
|
43
|
-
end
|
data/tasks/ann.rake
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'bones/smtp_tls'
|
5
|
-
rescue LoadError
|
6
|
-
require 'net/smtp'
|
7
|
-
end
|
8
|
-
require 'time'
|
9
|
-
|
10
|
-
namespace :ann do
|
11
|
-
|
12
|
-
# A prerequisites task that all other tasks depend upon
|
13
|
-
task :prereqs
|
14
|
-
|
15
|
-
file PROJ.ann.file do
|
16
|
-
ann = PROJ.ann
|
17
|
-
puts "Generating #{ann.file}"
|
18
|
-
File.open(ann.file,'w') do |fd|
|
19
|
-
fd.puts("#{PROJ.name} version #{PROJ.version}")
|
20
|
-
fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
|
21
|
-
fd.puts(" #{PROJ.url}") if PROJ.url.valid?
|
22
|
-
fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
|
23
|
-
fd.puts
|
24
|
-
fd.puts("== DESCRIPTION")
|
25
|
-
fd.puts
|
26
|
-
fd.puts(PROJ.description)
|
27
|
-
fd.puts
|
28
|
-
fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
|
29
|
-
fd.puts
|
30
|
-
ann.paragraphs.each do |p|
|
31
|
-
fd.puts "== #{p.upcase}"
|
32
|
-
fd.puts
|
33
|
-
fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
|
34
|
-
fd.puts
|
35
|
-
end
|
36
|
-
fd.puts ann.text if ann.text
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
desc "Create an announcement file"
|
41
|
-
task :announcement => ['ann:prereqs', PROJ.ann.file]
|
42
|
-
|
43
|
-
desc "Send an email announcement"
|
44
|
-
task :email => ['ann:prereqs', PROJ.ann.file] do
|
45
|
-
ann = PROJ.ann
|
46
|
-
from = ann.email[:from] || PROJ.email
|
47
|
-
to = Array(ann.email[:to])
|
48
|
-
|
49
|
-
### build a mail header for RFC 822
|
50
|
-
rfc822msg = "From: #{from}\n"
|
51
|
-
rfc822msg << "To: #{to.join(',')}\n"
|
52
|
-
rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
|
53
|
-
rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
|
54
|
-
rfc822msg << "\n"
|
55
|
-
rfc822msg << "Date: #{Time.new.rfc822}\n"
|
56
|
-
rfc822msg << "Message-Id: "
|
57
|
-
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
|
58
|
-
rfc822msg << File.read(ann.file)
|
59
|
-
|
60
|
-
params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
|
61
|
-
ann.email[key]
|
62
|
-
end
|
63
|
-
|
64
|
-
params[3] = PROJ.email if params[3].nil?
|
65
|
-
|
66
|
-
if params[4].nil?
|
67
|
-
STDOUT.write "Please enter your e-mail password (#{params[3]}): "
|
68
|
-
params[4] = STDIN.gets.chomp
|
69
|
-
end
|
70
|
-
|
71
|
-
### send email
|
72
|
-
Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
|
73
|
-
end
|
74
|
-
end # namespace :ann
|
75
|
-
|
76
|
-
desc 'Alias to ann:announcement'
|
77
|
-
task :ann => 'ann:announcement'
|
78
|
-
|
79
|
-
CLOBBER << PROJ.ann.file
|
80
|
-
|
81
|
-
# EOF
|