fb_utils 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +20 -0
- data/README.md +59 -0
- data/Rakefile +29 -0
- data/fb_utils.gemspec +26 -0
- data/lib/fb_utils/comment.rb +59 -0
- data/lib/fb_utils/string.rb +5 -0
- data/lib/fb_utils/version.rb +3 -0
- data/lib/fb_utils/writers/base.rb +19 -0
- data/lib/fb_utils/writers/csv.rb +22 -0
- data/lib/fb_utils/writers/txt.rb +13 -0
- data/lib/fb_utils.rb +13 -0
- data/test/comment_test.rb +36 -0
- data/test/fixtures/vcr_cassettes/poland_com.yml +61 -0
- data/test/support/vcr.rb +6 -0
- data/test/test_helper.rb +6 -0
- data/test/writers/base_test.rb +12 -0
- data/test/writers/csv_test.rb +16 -0
- data/test/writers/txt_test.rb +15 -0
- metadata +132 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fb_utils (0.0.1)
|
5
|
+
activesupport
|
6
|
+
i18n
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (3.1.1)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
fakeweb (1.3.0)
|
14
|
+
i18n (0.5.0)
|
15
|
+
multi_json (1.0.3)
|
16
|
+
rake (0.9.2.2)
|
17
|
+
shoulda-context (1.0.0)
|
18
|
+
vcr (1.11.3)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
fakeweb
|
25
|
+
fb_utils!
|
26
|
+
rake
|
27
|
+
shoulda-context
|
28
|
+
vcr
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Lukasz Krystkowiak
|
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.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# FbUtils
|
2
|
+
|
3
|
+
fb_utils is Ruby gem that lets you get and save facebook comments.
|
4
|
+
You can save comment in txt or csv file.
|
5
|
+
# Installation
|
6
|
+
Type
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem install fb_utils
|
10
|
+
```
|
11
|
+
|
12
|
+
or
|
13
|
+
|
14
|
+
add this to your Gemfile and run the bundle command
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'fb_utils'
|
18
|
+
```
|
19
|
+
|
20
|
+
#Usage
|
21
|
+
### Get comments
|
22
|
+
If you need to just get comments, call get method with URL
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
# return Array of comments
|
26
|
+
comments = FbUtils::Comment.get('http://www.example.com')
|
27
|
+
comment = comments.first
|
28
|
+
puts comment.id #=> "388101711259_17396935"
|
29
|
+
puts comment.message #=> "Hello world"
|
30
|
+
puts comment.created_time #=> "2011-07-26T01:23:34+0000"
|
31
|
+
puts comment.from_name #=> "Lukasz Kr"
|
32
|
+
puts comment.from_id #=> "123456789101112"
|
33
|
+
```
|
34
|
+
|
35
|
+
### Save comments
|
36
|
+
In order to save comments in file system, call save method with URL and file name.
|
37
|
+
You can choose txt or csv file type (or write your own writer).
|
38
|
+
Default is txt.
|
39
|
+
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# Save comments in example_com.txt file
|
43
|
+
FbUtils::Comment.save('http://www.example.com', 'example_com')
|
44
|
+
|
45
|
+
# Save comments in example_com.csv file
|
46
|
+
FbUtils::Comment.save('http://www.example.com', 'example_com', :format => :csv)
|
47
|
+
|
48
|
+
# For csv file you can pass additional parameters
|
49
|
+
FbUtils::Comment.save('http://www.example.com', 'example_com',
|
50
|
+
:format => :csv,
|
51
|
+
:fields_terminated_by => ";",
|
52
|
+
:fields_enclosed_by => "'",
|
53
|
+
:lines_terminated_by => "\n"
|
54
|
+
)
|
55
|
+
```
|
56
|
+
|
57
|
+
# References
|
58
|
+
http://developers.facebook.com/docs/reference/plugins/comments/
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rdoc/task'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.libs << 'test'
|
17
|
+
t.pattern = 'test/**/*_test.rb'
|
18
|
+
t.verbose = false
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
22
|
+
|
23
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
+
rdoc.rdoc_dir = 'rdoc'
|
25
|
+
rdoc.title = 'fb_utils'
|
26
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
28
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
end
|
data/fb_utils.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "fb_utils/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "fb_utils"
|
7
|
+
s.version = FbUtils::VERSION
|
8
|
+
s.authors = ["Lukasz Krystkowiak"]
|
9
|
+
s.email = ["lukasz.krystkowiak@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/lukkry/fb_utils"
|
11
|
+
s.summary = %q{Get Facebook comments and save those in txt, csv file.}
|
12
|
+
s.description = %q{Get Facebook comments and save those in txt, csv file.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency "activesupport"
|
20
|
+
s.add_dependency "i18n"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "vcr"
|
23
|
+
s.add_development_dependency "fakeweb"
|
24
|
+
s.add_development_dependency "shoulda-context"
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module FbUtils
|
2
|
+
class Comment
|
3
|
+
LINK = "http://graph.facebook.com/comments/?ids="
|
4
|
+
|
5
|
+
attr_accessor :id, :message, :created_time, :from_name, :from_id
|
6
|
+
|
7
|
+
def initialize(hash={})
|
8
|
+
return if hash.empty?
|
9
|
+
@id = hash["id"]
|
10
|
+
@from_name = hash["from"]["name"]
|
11
|
+
@from_id = hash["from"]["id"]
|
12
|
+
@message = hash["message"]
|
13
|
+
@created_time = hash["created_time"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
to_array.join(' ')
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_array
|
21
|
+
[@id, @message, @from_name, @from_id, @created_time]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get comments and save these in file system
|
25
|
+
#
|
26
|
+
# The rightmost argument is an optional hash of options,
|
27
|
+
# which is pass further to particular writer, specified from :format key
|
28
|
+
# Default is: :format => 'txt'
|
29
|
+
#
|
30
|
+
# For example:
|
31
|
+
#
|
32
|
+
# FbUtils::Comment.save('http://www.example.com', 'example_com')
|
33
|
+
#
|
34
|
+
# FbUtils::Comment.save('http://www.example.com', 'example_com',
|
35
|
+
# :format => :csv,
|
36
|
+
# :fields_terminated_by => ";",
|
37
|
+
# :fields_enclosed_by => "'",
|
38
|
+
# :lines_terminated_by => "\n"
|
39
|
+
def self.save(href, filename, *args)
|
40
|
+
options = args.extract_options!
|
41
|
+
options[:format] ||= "txt"
|
42
|
+
|
43
|
+
comments = get(href)
|
44
|
+
writer = "FbUtils::Writer::#{options[:format].to_s.camelize}".constantize.new(filename, options)
|
45
|
+
writer.write(comments)
|
46
|
+
comments
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get comments related to href
|
50
|
+
# Return array of comments
|
51
|
+
def self.get(href)
|
52
|
+
result = JSON.parse(Net::HTTP.get_response(URI(LINK + href)).body)
|
53
|
+
data = result[href]["data"]
|
54
|
+
data.inject([]) do |comments, c|
|
55
|
+
comments << Comment.new(c)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FbUtils
|
2
|
+
module Writer
|
3
|
+
class Base
|
4
|
+
attr_accessor :filename, :options
|
5
|
+
|
6
|
+
def initialize(filename, options={})
|
7
|
+
@options = options
|
8
|
+
@options[:format] ||= "txt"
|
9
|
+
@filename = File.basename(filename, ".#{options[:format]}") + ".#{options[:format]}"
|
10
|
+
f = File.new(@filename, "w")
|
11
|
+
f.close
|
12
|
+
end
|
13
|
+
|
14
|
+
def write
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module FbUtils
|
2
|
+
module Writer
|
3
|
+
class Csv < FbUtils::Writer::Base
|
4
|
+
def write(arr)
|
5
|
+
@options = {
|
6
|
+
:fields_terminated_by => ";",
|
7
|
+
:fields_enclosed_by => "\"",
|
8
|
+
:lines_terminated_by => "\n"
|
9
|
+
}.merge(@options)
|
10
|
+
|
11
|
+
File.open(@filename, "w") do |f|
|
12
|
+
arr.each{ |a|
|
13
|
+
fields = a.to_array.collect{|x| x.surround(@options[:fields_enclosed_by])}
|
14
|
+
fields = fields.join(@options[:fields_terminated_by])
|
15
|
+
fields.insert(-1, @options[:lines_terminated_by])
|
16
|
+
f.puts fields
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/fb_utils.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'active_support/all'
|
3
|
+
require 'fb_utils/string'
|
4
|
+
|
5
|
+
module FbUtils
|
6
|
+
autoload :Comment, 'fb_utils/comment'
|
7
|
+
|
8
|
+
module Writer
|
9
|
+
autoload :Base, 'fb_utils/writers/base'
|
10
|
+
autoload :Txt, 'fb_utils/writers/txt'
|
11
|
+
autoload :Csv, 'fb_utils/writers/csv'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CommentTest < Test::Unit::TestCase
|
4
|
+
context "Comment" do
|
5
|
+
should "get comments from Facebook" do
|
6
|
+
VCR.use_cassette('poland_com') do
|
7
|
+
comments = FbUtils::Comment.get("http://poland.com")
|
8
|
+
assert_kind_of Array, comments
|
9
|
+
assert_equal "hey there!", comments[0].message
|
10
|
+
assert_equal "10150114889322623_19119228", comments[0].id
|
11
|
+
assert_equal "1039207562", comments[0].from_id
|
12
|
+
assert_equal "Lukasz Kr", comments[0].from_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
should "get comments from Facebook and save them in txt, csv file" do
|
17
|
+
VCR.use_cassette('poland_com') do
|
18
|
+
comments = FbUtils::Comment.save("http://poland.com", "poland_com")
|
19
|
+
c = comments.first
|
20
|
+
assert_kind_of Array, comments
|
21
|
+
|
22
|
+
assert File.exists?("poland_com.txt")
|
23
|
+
File.open("poland_com.txt") do |f|
|
24
|
+
assert_equal "#{c.to_array.join(' ')}\n", f.readline
|
25
|
+
end
|
26
|
+
File.delete("poland_com.txt")
|
27
|
+
|
28
|
+
comments = FbUtils::Comment.save("http://poland.com", "poland_com", :format => :csv)
|
29
|
+
File.open("poland_com.csv") do |f|
|
30
|
+
assert_equal "\"#{c.id}\";\"#{c.message}\";\"#{c.from_name}\";\"#{c.from_id}\";\"#{c.created_time}\"\n", f.readline
|
31
|
+
end
|
32
|
+
File.delete("poland_com.csv")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://graph.facebook.com:80/comments/?ids=http://poland.com
|
6
|
+
body: !!null
|
7
|
+
headers: !!null
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
access-control-allow-origin:
|
14
|
+
- ! '*'
|
15
|
+
cache-control:
|
16
|
+
- private, no-cache, no-store, must-revalidate
|
17
|
+
content-type:
|
18
|
+
- text/javascript; charset=UTF-8
|
19
|
+
etag:
|
20
|
+
- ! '"410e0d777d51e246753ba20ce54db4633417e64d"'
|
21
|
+
expires:
|
22
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
23
|
+
pragma:
|
24
|
+
- no-cache
|
25
|
+
x-fb-rev:
|
26
|
+
- '473143'
|
27
|
+
x-fb-server:
|
28
|
+
- 10.32.42.122
|
29
|
+
x-cnection:
|
30
|
+
- close
|
31
|
+
date:
|
32
|
+
- Wed, 16 Nov 2011 16:03:29 GMT
|
33
|
+
content-length:
|
34
|
+
- '3781'
|
35
|
+
body: ! '{"http:\/\/poland.com":{"data":[{"id":"10150114889322623_19119228","from":{"name":"Lukasz
|
36
|
+
Kr","id":"1039207562"},"message":"hey there!","created_time":"2011-10-28T07:46:16+0000"},{"id":"10150114889322623_19119241","from":{"name":"Lukasz
|
37
|
+
Kr","id":"1039207562"},"message":"hey there again!","created_time":"2011-10-28T07:47:37+0000"},{"id":"10150114889322623_19119248","from":{"name":"Lukasz
|
38
|
+
Kr","id":"1039207562"},"message":"Programming motherfucker manifesto!","created_time":"2011-10-28T07:48:04+0000"},{"id":"10150114889322623_19119317","from":{"name":"Lukasz
|
39
|
+
Kr","id":"1039207562"},"message":"lkkl","created_time":"2011-10-28T07:58:14+0000"},{"id":"10150114889322623_19119354","from":{"name":"Lucy
|
40
|
+
Moore","id":"100002075427828"},"message":"blah","created_time":"2011-10-28T08:02:36+0000"},{"id":"10150114889322623_19119433","from":{"name":"Lucy
|
41
|
+
Moore","id":"100002075427828"},"message":"hello world","created_time":"2011-10-28T08:12:36+0000"},{"id":"10150114889322623_19119488","from":{"name":"Lucy
|
42
|
+
Moore","id":"100002075427828"},"message":"ruby on rails, love it.","created_time":"2011-10-28T08:20:32+0000"},{"id":"10150114889322623_19119508","from":{"name":"Lucy
|
43
|
+
Moore","id":"100002075427828"},"message":"love it","created_time":"2011-10-28T08:23:09+0000"},{"id":"10150114889322623_19199110","from":{"name":"Lukasz
|
44
|
+
Kr","id":"1039207562"},"message":"kol","created_time":"2011-11-02T14:56:10+0000"},{"id":"10150114889322623_19199142","from":{"name":"Lukasz
|
45
|
+
Kr","id":"1039207562"},"message":"kjh","created_time":"2011-11-02T14:59:54+0000"},{"id":"10150114889322623_19199428","from":{"name":"Lukasz
|
46
|
+
Kr","id":"1039207562"},"message":"huiuhiuh","created_time":"2011-11-02T15:27:36+0000"},{"id":"10150114889322623_19212705","from":{"name":"Lukasz
|
47
|
+
Kr","id":"1039207562"},"message":"dskaj","created_time":"2011-11-03T08:43:49+0000"},{"id":"10150114889322623_19212964","from":{"name":"Lukasz
|
48
|
+
Kr","id":"1039207562"},"message":"lok","created_time":"2011-11-03T09:21:40+0000"},{"id":"10150114889322623_19216328","from":{"name":"Lukasz
|
49
|
+
Kr","id":"1039207562"},"message":"hello world","created_time":"2011-11-03T15:02:01+0000"},{"id":"10150114889322623_19277426","from":{"name":"Lukasz
|
50
|
+
Kr","id":"1039207562"},"message":"kol","created_time":"2011-11-07T14:40:22+0000"},{"id":"10150114889322623_19277557","from":{"name":"Lukasz
|
51
|
+
Kr","id":"1039207562"},"message":"oo","created_time":"2011-11-07T14:49:03+0000"},{"id":"10150114889322623_19279743","from":{"name":"Lukasz
|
52
|
+
Kr","id":"1039207562"},"message":"jui","created_time":"2011-11-07T17:28:24+0000"},{"id":"10150114889322623_19279800","from":{"name":"Lukasz
|
53
|
+
Kr","id":"1039207562"},"message":"kiop","created_time":"2011-11-07T17:30:52+0000"},{"id":"10150114889322623_19279808","from":{"name":"Lukasz
|
54
|
+
Kr","id":"1039207562"},"message":"tyu","created_time":"2011-11-07T17:31:26+0000"},{"id":"10150114889322623_19279822","from":{"name":"Lukasz
|
55
|
+
Kr","id":"1039207562"},"message":"ert","created_time":"2011-11-07T17:32:00+0000"},{"id":"10150114889322623_19279833","from":{"name":"Lukasz
|
56
|
+
Kr","id":"1039207562"},"message":"bnm","created_time":"2011-11-07T17:32:35+0000"},{"id":"10150114889322623_19279850","from":{"name":"Lukasz
|
57
|
+
Kr","id":"1039207562"},"message":"nm","created_time":"2011-11-07T17:33:35+0000"},{"id":"10150114889322623_19279858","from":{"name":"Lukasz
|
58
|
+
Kr","id":"1039207562"},"message":"zxc","created_time":"2011-11-07T17:34:08+0000"},{"id":"10150114889322623_19294062","from":{"name":"Lukasz
|
59
|
+
Kr","id":"1039207562"},"message":"polska","created_time":"2011-11-08T13:45:05+0000"},{"id":"10150114889322623_19294081","from":{"name":"Lukasz
|
60
|
+
Kr","id":"1039207562"},"message":"hoi","created_time":"2011-11-08T13:47:10+0000"}],"paging":{"next":"http:\/\/graph.facebook.com\/comments?ids=http\u00253A\u00252F\u00252Fpoland.com&limit=25&offset=25"}}}'
|
61
|
+
http_version: '1.1'
|
data/test/support/vcr.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BaseTest < Test::Unit::TestCase
|
4
|
+
should "create blank file during initialization, default format: txt" do
|
5
|
+
writer = FbUtils::Writer::Base.new("test")
|
6
|
+
assert File.exists?("test.txt")
|
7
|
+
assert_raise NotImplementedError do
|
8
|
+
writer.write
|
9
|
+
end
|
10
|
+
File.delete("test.txt")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CsvTest < Test::Unit::TestCase
|
4
|
+
should "write to csv file" do
|
5
|
+
VCR.use_cassette('poland_com') do
|
6
|
+
comments = FbUtils::Comment.get("http://poland.com")
|
7
|
+
writer = FbUtils::Writer::Csv.new("test", :format => "csv", :fields_terminated_by => ";", :fields_enclosed_by => "'", :lines_terminated_by => "\n")
|
8
|
+
writer.write(comments)
|
9
|
+
c = comments.first
|
10
|
+
File.open("test.csv") do |f|
|
11
|
+
assert_equal "'#{c.id}';'#{c.message}';'#{c.from_name}';'#{c.from_id}';'#{c.created_time}'\n", f.readline
|
12
|
+
end
|
13
|
+
File.delete("test.csv")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TxtTest < Test::Unit::TestCase
|
4
|
+
should "write to txt file" do
|
5
|
+
VCR.use_cassette('poland_com') do
|
6
|
+
comments = FbUtils::Comment.get("http://poland.com")
|
7
|
+
writer = FbUtils::Writer::Txt.new("test", :format => "txt")
|
8
|
+
writer.write(comments)
|
9
|
+
File.open("test.txt") do |f|
|
10
|
+
assert_equal "#{comments.first.to_array.join(' ')}\n", f.readline
|
11
|
+
end
|
12
|
+
File.delete("test.txt")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fb_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lukasz Krystkowiak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-23 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: &82125440 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *82125440
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
requirement: &82125230 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *82125230
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &82125020 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *82125020
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: vcr
|
49
|
+
requirement: &82124810 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *82124810
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: fakeweb
|
60
|
+
requirement: &82124600 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *82124600
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: shoulda-context
|
71
|
+
requirement: &82124390 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *82124390
|
80
|
+
description: Get Facebook comments and save those in txt, csv file.
|
81
|
+
email:
|
82
|
+
- lukasz.krystkowiak@gmail.com
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .gitignore
|
88
|
+
- Gemfile
|
89
|
+
- Gemfile.lock
|
90
|
+
- LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- fb_utils.gemspec
|
94
|
+
- lib/fb_utils.rb
|
95
|
+
- lib/fb_utils/comment.rb
|
96
|
+
- lib/fb_utils/string.rb
|
97
|
+
- lib/fb_utils/version.rb
|
98
|
+
- lib/fb_utils/writers/base.rb
|
99
|
+
- lib/fb_utils/writers/csv.rb
|
100
|
+
- lib/fb_utils/writers/txt.rb
|
101
|
+
- test/comment_test.rb
|
102
|
+
- test/fixtures/vcr_cassettes/poland_com.yml
|
103
|
+
- test/support/vcr.rb
|
104
|
+
- test/test_helper.rb
|
105
|
+
- test/writers/base_test.rb
|
106
|
+
- test/writers/csv_test.rb
|
107
|
+
- test/writers/txt_test.rb
|
108
|
+
homepage: https://github.com/lukkry/fb_utils
|
109
|
+
licenses: []
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 1.8.6
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: Get Facebook comments and save those in txt, csv file.
|
132
|
+
test_files: []
|