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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0886920eea0a52ecd66691a48c644c1cf5aa803e
4
- data.tar.gz: 8e26aa548e91922fa034da99b81d79894f9b15ea
3
+ metadata.gz: afef5a7196cca2f35c7ce8fec7eccc7732adb172
4
+ data.tar.gz: 920b3dc387da1780b8ed263712f584f771bad6c5
5
5
  SHA512:
6
- metadata.gz: db15db43b7241e265a89722b0e31d07a4cd54fc4c2710574f42bd91fe70cff72545b87f1acc6f14c4ffda845df2c426c47be163d2d3e1a84b5327820f735eb02
7
- data.tar.gz: 33df2bba3dd9c8f2b4dd99e8426b5d12c986c210d4b4e5a1fce054e8dd38fb52320f4c47a16f5c6b1df17dc03ce67962364fcee0bae49fdc0fc583e63c2c6940
6
+ metadata.gz: 496b2849e314b1f3c645651967c0871a2fc5727789cf67685e7b4b0d54b20bfabcf17d83d90381ed912f5b05b3f168be513077ac8ac979bf2be152167700e1fc
7
+ data.tar.gz: 396aa54eec4e172a90c8dc6eaa9eb1491b55bbce983c4b0229a6e13b2022a4881ae8d5d2f810efca2021105d2ea7d9873a157185b76453fa6324058c0d03b9cf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brainspace (0.1.0)
4
+ brainspace (0.1.1)
5
5
  faraday
6
6
  hashie
7
7
  json
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Brainspace
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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