brainspace 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/brainspace/article.rb +7 -0
- data/lib/brainspace/version.rb +1 -1
- data/test/article/article_test.rb +28 -0
- data/test/fixtures/concept_discovery.yml +2507 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afef5a7196cca2f35c7ce8fec7eccc7732adb172
|
4
|
+
data.tar.gz: 920b3dc387da1780b8ed263712f584f771bad6c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496b2849e314b1f3c645651967c0871a2fc5727789cf67685e7b4b0d54b20bfabcf17d83d90381ed912f5b05b3f168be513077ac8ac979bf2be152167700e1fc
|
7
|
+
data.tar.gz: 396aa54eec4e172a90c8dc6eaa9eb1491b55bbce983c4b0229a6e13b2022a4881ae8d5d2f810efca2021105d2ea7d9873a157185b76453fa6324058c0d03b9cf
|
data/Gemfile.lock
CHANGED
data/lib/brainspace/article.rb
CHANGED
@@ -10,6 +10,13 @@ module Brainspace
|
|
10
10
|
@mash.send(method_sym, arguments)
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.discover(query)
|
14
|
+
response = Faraday.get("#{Brainspace.config.host}/discovery/concept", apikey: Brainspace.apikey, query: query)
|
15
|
+
result = JSON.parse(response.body)
|
16
|
+
articles = Hashie::Mash.new(result).data.map {|d| d.articles.first.merge(source: d.id) }
|
17
|
+
articles.map { |article| Brainspace::Article.new(article) }
|
18
|
+
end
|
19
|
+
|
13
20
|
def to_json(opts)
|
14
21
|
@mash.to_json(opts)
|
15
22
|
end
|
data/lib/brainspace/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
class BrainspaceArticleTest < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Brainspace.config.user = 'dummy@dummy.com'
|
7
|
+
Brainspace.config.password = 'DUMMY'
|
8
|
+
|
9
|
+
VCR.use_cassette('auth') do
|
10
|
+
Brainspace.apikey
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_exists
|
16
|
+
assert Brainspace::Article
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_it_discovers_based_on_query
|
20
|
+
VCR.use_cassette('concept discovery') do
|
21
|
+
result = Brainspace::Article.discover("BlockChain.info raises major capital today pulling in $30M in today's round. The investment featured contributions from Virgin Group founder, Richard Branson, who has a substantial investment in Bitpay, the largest payment service provider of digital currencies in the world. There are a few key differences in Blockchain from its main competitor, Coinbase. -- It is positioned to act as a usable wallet for users who actually want to spend their #bitcoin as opposed to speculate on price as \"it doesn't allow people to purchase or sell bitcoin for fiat currency\".\r\n\r\nDespite the dramatic price fluctuations in recent days, investment in cryptocurrencies remains strong with more than $200M in Venture funding in 2014 for the sector. In addition, [yesterday's annoucement by Overstock.com](http://hubble.disruption.vc/notes/1743) to establish a cryptocurrency enabled stock market indicates that the market and major companies are beginning to take the phenomena seriously through strategic investment.\r\n\r\n[WSJ - Blockchain lands biggest ever funding round for digital currencies](http://online.wsj.com/articles/blockchain-lands-biggest-ever-venture-funding-round-in-bitcoin-industry-1412687156)")
|
22
|
+
|
23
|
+
assert result.kind_of?(Array)
|
24
|
+
assert result.first.kind_of?(Brainspace::Article)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|