biffbot 0.0.1 → 0.0.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/README.md CHANGED
@@ -18,7 +18,20 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Usage example:
22
+
23
+ biff = Biffbot::Base.new("your developer token")
24
+ article = biff.parse("the url you want to parse",options)
25
+
26
+ You can use the options hash to set the following: tags, stats, dontStripAds, comments, summary, html
27
+
28
+ example:
29
+
30
+ options = Hash.new
31
+ options[:tags] = true
32
+ options[:stats] = true
33
+ biff = Biffbot::Base.new("your developer token")
34
+ article = biff.parse("the url you want to parse",options)
22
35
 
23
36
  ## Contributing
24
37
 
data/lib/biffbot/base.rb CHANGED
@@ -1,18 +1,18 @@
1
1
  require 'httparty'
2
2
  module Biffbot
3
- class Base
4
- def parse(token,url,options={})
3
+ class Base
4
+ def initialize(token)
5
5
  @token = token
6
+ end
7
+ def parse(url,options={})
6
8
  @url = url
7
9
  output = Hash.new
8
10
  request = "http://www.diffbot.com/api/article?token=#{@token}&url=#{@url}"
9
- raise request.to_s
10
11
  options.each_pair do |key,value|
11
12
  if key.match(/html|dontStripAds|tags|comments|summary|stats/) && value == true
12
13
  request = request + "&#{key}"
13
14
  end
14
15
  end
15
- puts request
16
16
  response = HTTParty.get(request)
17
17
  response.parsed_response.each_pair do |key,value|
18
18
  output[key.to_sym] = value
@@ -1,3 +1,3 @@
1
1
  module Biffbot
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/biffbot_spec.rb CHANGED
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
  # more tests to come...
3
3
  describe Biffbot do
4
4
  before :each do
5
- @biffbot = Biffbot::Base.new
6
5
  @token = "YOUR TOKEN HERE"
6
+ @biffbot = Biffbot::Base.new(@token)
7
7
  end
8
8
 
9
9
  describe "#get_huffinton_post_article" do
10
10
  it "not nil" do
11
- @biffbot.parse(@token,"http://www.huffingtonpost.ca/2012/10/11/amanda-todd-teen-bullying-suicide-youtube_n_1959668.html").size.should_not be_nil
11
+ @biffbot.parse("http://www.huffingtonpost.ca/2012/10/11/amanda-todd-teen-bullying-suicide-youtube_n_1959668.html").size.should_not be_nil
12
12
  end
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biffbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70132709867900 !ruby/object:Gem::Requirement
16
+ requirement: &70114508161420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70132709867900
24
+ version_requirements: *70114508161420
25
25
  description: Ruby gem to connect to diffbot's article api
26
26
  email:
27
27
  - anurag@columbia.edu