dasher-ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa5e96cc84dc470f8f048514db42cf977c0576a1
4
+ data.tar.gz: 4665e9ec8ca11bec51e21a66c8e01725c2183ee9
5
+ SHA512:
6
+ metadata.gz: b1f2465224a7c14313a8bf3139945614847c48233e5c9cd29bff7d5ed8a7168d15ff0c17aff8db107c2ec8607bf767e75ae7c69c70c5b3427d36fad69f0bef69
7
+ data.tar.gz: 2245dc6e9e5d53bd3ee5f5932601217b27897aa52c64d8df6912ec14b90676b468297fec13c5ee6b533c6dad1b87143cad9edd4445e35538b09db35942bc666f
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Dasher Ruby Client
2
+
3
+ This client allows you to easily update screen data for [Dasher](http://dasherapp.com).
4
+ You can use this gem to easily push new data to any of your Dasher screens with
5
+ ease.
6
+
7
+ ## Installation
8
+
9
+ Just install the gem into your `Gemfile` to get started.
10
+
11
+ ```ruby
12
+ gem "dasher-ruby", "~> 1.0", :require => "dasher"
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ # Getting screen and square information
19
+ Dasher.client.screens #=> Returns an array of screens
20
+ Dasher.client.screen(1) #=> Return information about a given screen by ID
21
+
22
+ # You can update a specific property quickly by providing the path to the property
23
+ # you want to change. You should provide the ID (or path) to the square, the
24
+ # key of the property you want to change and the new value.
25
+ Dasher.client.update_property(2, "number", 4001)
26
+ Dasher.client.update_property("screen1.signups", "number", 4001)
27
+
28
+ # Updating lists is also easy. You provide the square ID (or path), an optional
29
+ # identifier allowing you to remove/edit this item again in the future and the
30
+ # properties for the list item.
31
+ Dasher.client.add_list_item(2, nil, {"text" => "Some properties", "color" => "red"})
32
+
33
+ # You can also provide a full new list of updates. Screens will automatically
34
+ # remove, add or edit items as appropriate. Any items without identifiers will
35
+ # be removed.
36
+ Dasher.client.replace_list(2, [
37
+ {"identifier" => "A", {"text" => "Some example text on row A"}},
38
+ {"identifier" => "B", {"text" => "Some example text on row B"}}
39
+ ])
40
+ ```
41
+
42
+ The `Dasher.client` instance is automatically configured to use the production
43
+ Dasher endpoints and the key in the `Dasher_TOKEN` environment variable.
44
+ You can create your own clients if you would like.
45
+
46
+ ```ruby
47
+ client = Dasher::Client.new(host, token, :port => 443, :ssl => true)
48
+ client.screens
49
+ # etc...
50
+ ```
@@ -0,0 +1,48 @@
1
+ require 'moonrope_client'
2
+
3
+ module Dasher
4
+ class Client
5
+
6
+ attr_reader :host, :token, :port, :ssl
7
+
8
+ def initialize(host, token, options = {})
9
+ @host = host
10
+ @token = token
11
+ @port = options[:port]
12
+ @ssl = options[:ssl]
13
+ end
14
+
15
+ def screens
16
+ api.screens.list!.data
17
+ end
18
+
19
+ def screen(id)
20
+ api.screens.details!(:id => id).data
21
+ end
22
+
23
+ def update_property(square, key, value)
24
+ api.squares.update_property!(:square => square, :key => key, :value => value).data
25
+ rescue MoonropeClient::RequestError => e
26
+ e.result.data["code"] == "ValidationError" ? false : raise
27
+ end
28
+
29
+ def add_list_item(square, identifier, properties = {})
30
+ api.lists.add!(:square => square, :identifier => identifier, :properties => properties)
31
+ end
32
+
33
+ def replace_list(square, items = [])
34
+ api.lists.replace!(:square => square, :items => items)
35
+ rescue MoonropeClient::RequestError => e
36
+ puts e.result.data
37
+ end
38
+
39
+ private
40
+
41
+ def api
42
+ @client ||= begin
43
+ MoonropeClient::Connection.new(host, :headers => {'X-Auth-Token' => token}, :ssl => port == 443, :port => port)
44
+ end
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module Dasher
2
+ VERSION = '1.0.0'
3
+ end
data/lib/dasher.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'dasher/client'
2
+
3
+ module Dasher
4
+
5
+ class << self
6
+ def client
7
+ @client ||= Dasher::Client.new("dasherapp.com", ENV["DASHER_TOKEN"], :port => 443, :ssl => true)
8
+ end
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dasher-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Cooke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: moonrope-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.2
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.2
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ description: A full client library allows requests to made to the Dasher API.
34
+ email:
35
+ - adam@atechmedia.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - README.md
41
+ - lib/dasher.rb
42
+ - lib/dasher/client.rb
43
+ - lib/dasher/version.rb
44
+ homepage: https://dasherapp.com
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.4.5
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: A Ruby client library for the Dasher API.
68
+ test_files: []