leftronic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bushido-leftronic.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,22 @@
1
+ A simple interface for the Leftronics dashboard
2
+ Leftronics is a dashboard-as-a-service. It supports five custom data update types:
3
+
4
+ leaderboard(name, entries)
5
+ list(name, entries)
6
+ map(name, latitude, longitude)
7
+ number(name, number)
8
+ text(name, title, text)
9
+
10
+ Example usage:
11
+
12
+ require 'leftronic'
13
+ dashboard = Leftronic.new("my-leftronic-api-key")
14
+ dashboard.leaderboard("top_deployed", [{"engine" => 200}, {"mockr" => 15}, {"fatfreecrm" => 59}])
15
+ dashboard.list("recently_deployed", ["locomotive-cms", "locomotive-cms", "redmine"])
16
+ dashboard.map("currently_signed_in", -81.98, 11.70)
17
+ dashboard.number("app_count", 5000)
18
+ dashboard.text("MongoDB Server up")
19
+
20
+ License:
21
+
22
+ MIT
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "leftronic/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "leftronic"
7
+ s.version = Leftronic::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Sean Grove"]
10
+ s.email = ["sean@bushi.do"]
11
+ s.homepage = "http://leftronic.com"
12
+ s.summary = %q{Idiomatic ruby gem to use Leftronic}
13
+ s.description = %q{Leftronic is an amazing dashboard-as-a-service company, but I wanted to work with them in ruby, so I wrote this.}
14
+
15
+ s.add_dependency "rest-client", ">=1.6.1"
16
+ s.add_dependency "json", ">=1.4.6"
17
+
18
+ s.rubyforge_project = "leftronic"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
@@ -0,0 +1,65 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ class Leftronic
5
+ attr_accessor :url, :api_key
6
+
7
+ def push(name, data_point)
8
+ payload =
9
+ {"accessKey" => @api_key,
10
+ "streamName" => name,
11
+ "point" => data_point
12
+ }
13
+
14
+ return RestClient.post(@url, payload.to_json)
15
+ end #:nodoc:
16
+
17
+
18
+ def initialize(api_key, url = "https://beta.leftronic.com/customSend/")
19
+ @api_key = api_key
20
+ @url = url
21
+ end
22
+
23
+ # Push a number datapoint
24
+ def number(name, number)
25
+ push(name, number)
26
+ end
27
+
28
+
29
+ # Push a map datapoint
30
+ def map(name, latitude, longitude)
31
+ push(name, {"latitude" => latitude, "longitude" => longitude})
32
+ end
33
+
34
+
35
+ # Push a text update
36
+ def text(name, title, text)
37
+ push(name, {"title" => title, "msg" => text})
38
+ end
39
+
40
+ # Push a new leaderboard
41
+ # Entries is a hash of the form {:key_name_1 => :value, :key_name_2 => :value}
42
+ def leaderboard(name, entries)
43
+ values = []
44
+
45
+ entries.each do |hash|
46
+ hash.each_pair do |key, value|
47
+ values << {"name" => key, "value" => value}
48
+ end
49
+ end
50
+
51
+ puts ({"leaderboard" => values}.inspect)
52
+ push(name, {"leaderboard" => values})
53
+ end
54
+
55
+
56
+ # Push a list
57
+ # Entries is simply an array
58
+ def list(name, entries)
59
+ values = entries.collect do |item|
60
+ {"listItem" => item}
61
+ end
62
+
63
+ push(name, {"list" => values})
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Leftronic
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: leftronic
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Sean Grove
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-08 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rest-client
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.6.1
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.4.6
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: Leftronic is an amazing dashboard-as-a-service company, but I wanted to work with them in ruby, so I wrote this.
39
+ email:
40
+ - sean@bushi.do
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - README
51
+ - Rakefile
52
+ - leftronic.gemspec
53
+ - lib/leftronic.rb
54
+ - lib/leftronic/version.rb
55
+ has_rdoc: true
56
+ homepage: http://leftronic.com
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project: leftronic
79
+ rubygems_version: 1.6.2
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Idiomatic ruby gem to use Leftronic
83
+ test_files: []
84
+