adafruit-io 2.0.0.beta.6 → 2.0.0.beta.7

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: 1eaa78ed8fc5921d2af4d16d7fa1defb321eecb2
4
- data.tar.gz: 7ee9adca6975f86882faea7f6c40bcba3c91b74f
3
+ metadata.gz: d4e361c9a85392c933fe7c35fda6bfd98f6f80cd
4
+ data.tar.gz: 9a68f813bfff5fedee4511bb6fcd7b940ebfb1e4
5
5
  SHA512:
6
- metadata.gz: c58dedbafaae234314a9e0dcddcb67fad758479fed2ad141a2956d247ff83ef037bc5f25805adbbd6110026611521c08fa326236183b9ea45d4eacd6f22a3a6f
7
- data.tar.gz: 0fe5158a4d1a5523b4e4638ad29f3c194918171f1ae814285221f2328a4f9a1270678c86b181d19797e6e300666d5d2bfc663a2a8670f9bab0352fe5f520a725
6
+ metadata.gz: 730d7000307a9569797d6904f7fa5fba72e7cf6ec507b753fdad266584b1fed8bfdfbe29ae569f2d8b00fe129cf42f93687d1d202816a2944f457121a94f65a2
7
+ data.tar.gz: a61eb95bc77ff2aaab6d5893f9d16779e4d60acf1ab9612ba186e395bb73ab93c2e98af86f2f4fcbe518a44fa5f44c863ca12ac2fa3ed8a64ffd99a81ff2d75b
data/README.md CHANGED
@@ -33,6 +33,19 @@ It is our goal to eventually support all API V2 methods, but that will happen in
33
33
  - [x] Permissions `2.0.0.beta.5`
34
34
  - [x] Triggers `2.0.0.beta.6`
35
35
 
36
+ Still needing complete tests:
37
+
38
+ - [x] Feeds
39
+ - [x] Data
40
+ - [x] Tokens
41
+ - [x] Blocks
42
+ - [ ] Dashboards *has pending*
43
+ - [ ] Groups *has pending*
44
+ - [ ] Activities
45
+ - [ ] Permissions
46
+ - [ ] Triggers
47
+ - [ ] MQTT
48
+
36
49
  ## Installation
37
50
 
38
51
  Add this line to your application's Gemfile:
@@ -15,37 +15,69 @@ module Adafruit
15
15
  def block(*args)
16
16
  username, arguments = extract_username(args)
17
17
  dashboard_key = require_argument(arguments, :dashboard_key)
18
- block_id = get_id_from_arguments(arguments)
18
+ block_id = get_key_from_arguments(arguments)
19
19
 
20
20
  get api_url(username, 'dashboards', dashboard_key, 'blocks', block_id)
21
21
  end
22
22
 
23
+ # Create a block
23
24
  def create_block(*args)
24
25
  username, arguments = extract_username(args)
25
26
  dashboard_key = require_argument(arguments, :dashboard_key)
26
- block_attrs = arguments.shift
27
+ block_attrs = valid_block_attrs(arguments)
27
28
 
28
- post api_url(username, 'groups'), group_attrs
29
+ post api_url(username, 'dashboards', dashboard_key, 'blocks'), block_attrs
29
30
  end
30
31
 
32
+ # Delete a block
31
33
  def delete_block(*args)
32
34
  username, arguments = extract_username(args)
33
35
  dashboard_key = require_argument(arguments, :dashboard_key)
34
- block_id = get_id_from_arguments(arguments)
36
+ block_id = get_key_from_arguments(arguments)
35
37
 
36
38
  delete api_url(username, 'dashboards', dashboard_key, 'blocks', block_id)
37
39
  end
38
40
 
41
+ # Update a block
39
42
  def update_block(*args)
40
43
  username, arguments = extract_username(args)
41
44
  dashboard_key = require_argument(arguments, :dashboard_key)
42
- block_id = get_id_from_arguments(arguments)
45
+ block_id = get_key_from_arguments(arguments)
46
+ block_attrs = valid_block_attrs(arguments)
43
47
 
44
- query = get_query_from_arguments(arguments, %w(name properties visual_type column row size_x size_y block_feeds))
48
+ put api_url(username, 'dashboards', dashboard_key, 'blocks', block_id), block_attrs
49
+ end
50
+
51
+ # The list of every valid property name that can be stored by Adafruit IO.
52
+ #
53
+ # Not every property applies to every block. Boolean values should be
54
+ # stored as the string "yes" or "no".
55
+ def valid_block_properties
56
+ %w(
57
+ text value release fontSize onText offText backgroundColor onColor
58
+ offColor min max step label orientation handle minValue maxValue
59
+ ringWidth label xAxisLabel yAxisLabel yAxisMin yAxisMax tile
60
+ fontColor showName showTimestamp errors historyHours showNumbers
61
+ showLocation
62
+ )
63
+ end
45
64
 
46
- put api_url(username, 'dashboards', dashboard_key, 'blocks', block_id), query
65
+ # The list of every valid block type that can be presented by Adafruit IO.
66
+ def valid_block_visual_types
67
+ %w(
68
+ toggle_button slider momentary_button gauge line_chart text
69
+ color_picker map stream image remote_control
70
+ )
47
71
  end
48
72
 
73
+ private
74
+
75
+ def valid_block_attrs(arguments)
76
+ get_query_from_arguments(
77
+ arguments,
78
+ %w(name properties visual_type column row size_x size_y block_feeds)
79
+ )
80
+ end
49
81
  end
50
82
  end
51
83
  end
@@ -1,5 +1,5 @@
1
1
  module Adafruit
2
2
  module IO
3
- VERSION = "2.0.0.beta.6"
3
+ VERSION = "2.0.0.beta.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adafruit-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta.6
4
+ version: 2.0.0.beta.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Cooper
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-19 00:00:00.000000000 Z
12
+ date: 2018-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday