mtgapi 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 753011792140d122c30e3690bfb1628a09a6bd05
4
- data.tar.gz: 2fd14dd23b434159f772993de789cd1ccf43f959
3
+ metadata.gz: bd2ea31b46cc910aa00d4509a26672ff1633c641
4
+ data.tar.gz: e7a489830ec40128cd3947ca04b08c45c6bc2871
5
5
  SHA512:
6
- metadata.gz: 88466729b048518dc7555f6f8395552f6e9958843351c7abe7249015457b0030907fb92b55470f75dc9d8cd55fc18c7e551e33918edcb7fdcf56db76932ae37c
7
- data.tar.gz: 7b3472ee7e5f4ccd91a58fe181cf9d58a0b7366a7a5ff1ab4a271ceb56cabd2bc2cc1c9d0336425dc44d3e917102e63d2885fb2762c1ac39de2dd7d44f15cfed
6
+ metadata.gz: 727ab8ac21b4ce331e8c81e14d4949cb4918065017d6c9db09aa0e1702cabba9f36252bc4a7d1b6819151dbc7c3665c76882eb526686edcc96ea3ed99c061a94
7
+ data.tar.gz: fd098d58df3b98ce5d53a60b9d0243026a05aa28182f5d3323c9009633aa8cb049d14d416264ee2c202b85f5baf5ca7ba444a2be4e3aa1053899701eb56b4761
data/README.md CHANGED
@@ -31,7 +31,7 @@ export MTG_TOKEN=token_goes_here
31
31
  @client = Mtgapi::Client.new
32
32
  ```
33
33
 
34
- ### Search Cards by Name
34
+ ### Fetch Cards by Name
35
35
 
36
36
  ```ruby
37
37
  @client.find_by(:name, "Shock")
@@ -43,6 +43,18 @@ export MTG_TOKEN=token_goes_here
43
43
  @client.find_by(:id, 1)
44
44
  ```
45
45
 
46
+ ### Fetch Cards by Set
47
+
48
+ ```ruby
49
+ @client.find_by(:set, "Alara Reborn")
50
+ ```
51
+
52
+ ### Fetch list of sets
53
+
54
+ ```ruby
55
+ @client.sets
56
+ ```
57
+
46
58
  ## Contributing
47
59
 
48
60
  1. Fork it
@@ -12,9 +12,13 @@ module Mtgapi
12
12
  @token = token
13
13
  end
14
14
 
15
+ def sets
16
+ self.class.get("/list/sets").parsed_response
17
+ end
18
+
15
19
  def find_by(attr, value)
16
20
  url = self.send("#{attr.to_s}_url", value)
17
- self.class.get(url)
21
+ self.class.get(url).parsed_response
18
22
  end
19
23
 
20
24
  def id_url(id)
@@ -25,6 +29,10 @@ module Mtgapi
25
29
  "/card/name/#{name}"
26
30
  end
27
31
 
32
+ def set_url(set)
33
+ "/card/set/#{set}"
34
+ end
35
+
28
36
  def token_append
29
37
  "?token=#{token}"
30
38
  end
@@ -1,3 +1,3 @@
1
1
  module Mtgapi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,14 +1,15 @@
1
1
  require "test_helper"
2
2
 
3
3
  class ClientTest < Minitest::Test
4
- attr_reader :client
5
4
 
6
- def setup
7
- @client = Mtgapi::Client.new("testtoken")
5
+ def client
6
+ Mtgapi::Client.new("testtoken")
8
7
  end
9
8
 
10
- def do_return
11
- ->(arg) { return arg }
9
+ def do_mock
10
+ mock = Minitest::Mock.new
11
+ mock.expect(:parsed_response, true)
12
+ ->(arg) { return mock }
12
13
  end
13
14
 
14
15
  def test_id_url
@@ -19,13 +20,23 @@ class ClientTest < Minitest::Test
19
20
  assert_equal "/card/name/test", client.name_url("test")
20
21
  end
21
22
 
23
+ def test_set_url
24
+ assert_equal "/card/set/test", client.set_url("test")
25
+ end
26
+
22
27
  def test_token_append
23
28
  assert_equal "?token=#{client.token}", client.token_append
24
29
  end
25
30
 
31
+ def test_sets
32
+ Mtgapi::Client.stub(:get, do_mock) do
33
+ assert client.sets
34
+ end
35
+ end
36
+
26
37
  def test_find_by
27
- Mtgapi::Client.stub(:get, do_return) do
28
- assert_equal "/card/id/1", client.find_by(:id, 1)
38
+ Mtgapi::Client.stub(:get, do_mock) do
39
+ assert client.find_by(:id, 1)
29
40
  end
30
41
  end
31
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtgapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate West