burghers 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: defd1c5e3e6fb553ea3c2f86d99865c8f29bb888
4
- data.tar.gz: b9f5a028a13e0deae8a439a86604ba7d235e8bfd
3
+ metadata.gz: 1d5016ecadb007cdb522ecb1054b2d1978811ee7
4
+ data.tar.gz: a8c05eac6d8c6a6ab6a4a0ed3f90c42d2424d292
5
5
  SHA512:
6
- metadata.gz: ffccaf465da9168da37a664a30547537232dec026e09d136ad1047a74802939215da520ca768f28587884bfd3e434e575f62f088cdb9fc2ed35b24ada765467c
7
- data.tar.gz: 313b260e7b743b4f5aeb3652378ea8e432a635dfb7ec14bfb5a7ae1bac6fb38c68f3bc1665dcb8f32e8b0963f23c9b14e063e7c2bddc1e7821cb8a18f3a60c29
6
+ metadata.gz: 615907fc781daab3d08bafaca8fb40ae79c7b31f28fca7e6d9a3e3800b7ab7885aa3ed1a6feaf3ad66dfef9fe4c4e1dcea73eacd7ba77b3fb81ada616a474f3b
7
+ data.tar.gz: e5205056ababade184aaf90b60dbc5c6f8f6a2133a58f88f731dd53ed454b38a9e865ade5c30e597d16dbe3a780c0c7c15444e6092da0968e926c7361290b9e1
@@ -43,4 +43,16 @@ Responses to enrich will all respond to topics, tags, entities, and relations wi
43
43
  == Documentation
44
44
  Run:
45
45
 
46
- bundle exec rake doc
46
+ bundle exec rake doc
47
+
48
+ == OpenCalais Test Account
49
+ This was an account made just for the tests.
50
+
51
+ username: createbubbles
52
+ email: createbubbles@mailinator.com
53
+ password: T3E3gCppAD
54
+ api key: 3zjwnzgr6ptek99nqgebwx9r
55
+
56
+ == Running tests
57
+
58
+ rake
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rdoc/task'
3
+ require 'rake/testtask'
3
4
 
4
5
  RDoc::Task.new("doc") { |rdoc|
5
6
  rdoc.title = "Burghers - Yet another Open Calais gem"
@@ -7,3 +8,10 @@ RDoc::Task.new("doc") { |rdoc|
7
8
  rdoc.rdoc_files.include('README.rdoc')
8
9
  rdoc.rdoc_files.include('lib/**/*.rb')
9
10
  }
11
+
12
+ Rake::TestTask.new do |t|
13
+ t.test_files = FileList['test/*_test.rb']
14
+ t.verbose = true
15
+ end
16
+
17
+ task :default => :test
@@ -7,15 +7,16 @@ Gem::Specification.new do |gem|
7
7
  gem.version = Burghers::VERSION
8
8
  gem.authors = ["Brian Muller"]
9
9
  gem.email = ["bamuller@gmail.com"]
10
- gem.description = %q{Use Open Calais. Easily.}
11
- gem.summary = %q{Use Open Calais. Easily.}
10
+ gem.description = %q{Use Open Calais. Easily.}
11
+ gem.summary = %q{Use Open Calais. Easily.}
12
12
  gem.homepage = "https://github.com/bmuller/burghers"
13
13
 
14
14
  gem.files = `git ls-files`.split($/)
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.test_files = gem.files.grep(%r{^(test)/})
17
17
  gem.require_paths = ["lib"]
18
18
  gem.add_dependency("httparty", ">= 0.9.0")
19
19
  gem.add_development_dependency("rake")
20
20
  gem.add_development_dependency("rdoc")
21
+ gem.add_development_dependency("minitest", ">= 5.3.3")
21
22
  end
@@ -14,10 +14,12 @@ module Burghers
14
14
  content_type = "text/html"
15
15
  end
16
16
 
17
- if content_type.nil? and content.include?("<") and content.include(">")
18
- content_type = "text/html"
19
- elsif content_type.nil?
20
- content_type = "text/raw"
17
+ if content_type.nil?
18
+ if html?(content)
19
+ content_type = "text/html"
20
+ else
21
+ content_type = "text/raw"
22
+ end
21
23
  end
22
24
 
23
25
  headers = {
@@ -30,8 +32,14 @@ module Burghers
30
32
  if response.code != 200
31
33
  raise "Got response code of #{response.code}: #{response}"
32
34
  end
33
-
35
+
34
36
  Response.new response.parsed_response
35
37
  end
38
+
39
+ private
40
+
41
+ def html?(content)
42
+ content && content.include?("<") && content.include?(">")
43
+ end
36
44
  end
37
45
  end
@@ -1,3 +1,3 @@
1
1
  module Burghers
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require 'minitest/autorun'
2
+ require 'burghers'
3
+
4
+ class BurghersTest < MiniTest::Test
5
+ def setup
6
+ # NOTE: these tests make real HTTP calls, so they probably
7
+ # can't be run often due to API rate limits, but can be
8
+ # used to help catch regressions
9
+ @client = Burghers::Client.new("3zjwnzgr6ptek99nqgebwx9r")
10
+ @expected = [{:name=>"Education", :score=>1.0},
11
+ {:name=>"Labor", :score=>0.952},
12
+ {:name=>"Business_Finance", :score=>0.875},
13
+ {:name=>"Politics", :score=>0.566}]
14
+ end
15
+
16
+ def test_with_text
17
+ content = "The government of the United Kingdom has given corporations like fast food chain McDonald's the right to award high school qualifications to employees who complete a company training program."
18
+ assert_equal @expected, @client.enrich(content).topics
19
+ end
20
+
21
+ def test_with_html
22
+ content = "<html><body>The government of the United Kingdom has given corporations like fast food chain McDonald's the right to award high school qualifications to employees who complete a company training program.</html></body>"
23
+ assert_equal @expected, @client.enrich(content).topics
24
+ end
25
+
26
+ def test_with_url
27
+ content = "http://www.washingtonpost.com/lifestyle/style/rep-vance-mcallister-kissed-now-can-he-make-up-with-voters-after-the-scandal/2014/04/16/9a898fde-c57c-11e3-9f37-7ce307c56815_story.html"
28
+ expected = [{:name=>"Politics", :score=>0.57}]
29
+ assert_equal expected, @client.enrich(content).topics
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: burghers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Muller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -52,7 +52,21 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Use Open Calais. Easily.
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 5.3.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 5.3.3
69
+ description: Use Open Calais. Easily.
56
70
  email:
57
71
  - bamuller@gmail.com
58
72
  executables: []
@@ -70,6 +84,7 @@ files:
70
84
  - lib/burghers/client.rb
71
85
  - lib/burghers/response.rb
72
86
  - lib/burghers/version.rb
87
+ - test/burghers_test.rb
73
88
  homepage: https://github.com/bmuller/burghers
74
89
  licenses: []
75
90
  metadata: {}
@@ -92,5 +107,6 @@ rubyforge_project:
92
107
  rubygems_version: 2.2.2
93
108
  signing_key:
94
109
  specification_version: 4
95
- summary: Use Open Calais. Easily.
96
- test_files: []
110
+ summary: Use Open Calais. Easily.
111
+ test_files:
112
+ - test/burghers_test.rb