leftronicapi 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ ### Required Gems
6
+ # gem "rubygems", ">= 0"
7
+ gem "curb", ">= 0"
8
+ gem "json", ">= 0"
9
+ gem "rake", ">= 0"
10
+
11
+ # Add dependencies to develop your gem here.
12
+ # Include everything needed to run rake, tests, features, etc.
13
+ group :development do
14
+ gem "shoulda", ">= 0"
15
+ gem "bundler", "~> 1.0.0"
16
+ gem "jeweler", "~> 1.6.4"
17
+ gem "rcov", ">= 0"
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ curb (0.7.15)
5
+ git (1.2.5)
6
+ jeweler (1.6.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ json (1.6.1)
11
+ rake (0.9.2)
12
+ rcov (0.9.10)
13
+ shoulda (2.11.3)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.0.0)
20
+ curb
21
+ jeweler (~> 1.6.4)
22
+ json
23
+ rake
24
+ rcov
25
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ Leftronic Ruby Gem Documentation
2
+ ================================
3
+
4
+ What is Leftronic?
5
+ ------------------
6
+
7
+ [Leftronic](https://beta.leftronic.com) makes powerful dashboards for business intelligence.
8
+
9
+ * Colorful and interactive data visualizations
10
+ * Templates to get you started right away
11
+ * Drag-and-drop editor makes it easy for anyone to create a powerful dashboard, customized to their needs
12
+ * Integration with Google Analytics, Twitter, Chartbeat, Zendesk, Basecamp, Pivotal Tracker, Facebook, and more to come!
13
+ * Dashboards can be protected or shared with a shortened URL
14
+ * Powerful API's for Javascript, PHP, Python, Ruby, and Java
15
+ * Python Package and Ruby Gem
16
+
17
+ Technical Notes
18
+ ---------------
19
+
20
+ We also suggest checking out our [API](https://beta.leftronic.com/api) page. While the most detailed documentation is here, it has JSON and CURL examples in addition to a test form to send data to your custom widgets.
21
+
22
+ Authentication is handled by your API access key. We strongly encourage you to keep this key private. If you're logged in, your key can be found on our [API](https://beta.leftronic.com/api) page. If you plan on using one of our API libraries, you will find instructions below on how to set your access key.
23
+
24
+ All API requests are made by sending a POST request to https://beta.leftronic.com/customSend with a properly formatted JSON packet. We do not support XML.
25
+
26
+ Current API version is 1.0.
27
+ Current Ruby Gem version is 1.0.0.
28
+
29
+ Getting Started
30
+ ---------------
31
+
32
+ If you haven't already, create an account at https://beta.leftronic.com/accounts/login.
33
+
34
+ Get your API access key from the API overview page at https://beta.leftronic.com/api.
35
+
36
+ We recommend checking out our [Tutorials](https://beta.leftronic.com/tutorials) to familiarize yourself with your dashboard.
37
+
38
+ Ruby Gem
39
+ --------
40
+
41
+ Start by downloading the most recent version of our Ruby Gem on [Github](https://github.com/sonofabell/leftronic-ruby) or on [RubyGems](http://rubygems.org/gems/leftronic).
42
+
43
+ ### Installing Dependencies
44
+
45
+ [RubyGems](http://rubygems.org/pages/download), [Curb](http://rubygems.org/gems/curb), and [JSON](http://rubygems.org/gems/json). We recommend installing them with the [RubyGems](http://rubygems.org/pages/download) installer.
46
+
47
+ **_Note_**: Versions prior to Ruby 1.9 may need to import [rubygems](http://rubygems.org).
48
+
49
+ ```ruby
50
+ require 'rubygems'
51
+ ```
52
+
53
+ Import the file. Your location may vary.
54
+
55
+ ```ruby
56
+ require 'leftronic'
57
+ ```
58
+
59
+ Create a class instance with your API key. Feel free to name it whatever you'd like.
60
+
61
+ ```ruby
62
+ update = Leftronic.new("YOUR_ACCESS_KEY")
63
+ ```
64
+
65
+ Here are some example functions to push to your dashboard. Be sure you have configured the correct widgets to accept custom data points. Also, be sure that you have entered your API access key correctly.
66
+
67
+ Let's start with pushing a number to a widget.
68
+
69
+ ```ruby
70
+ update = Leftronic.pushNumber("yourNumberStream", 14600)
71
+ ```
72
+
73
+ Now we'll push some geographic coordinates to a map widget. You can use either the U.S. or world map widgets. The first coordinate (37.8) is the latitude and the second coordinate (-122.6) is the longitude. If your request is successful, you should see a data point appear on San Francisco, California.
74
+
75
+ ```ruby
76
+ update = Leftronic.pushLocation("yourGeoStream", 37.8, -122.6)
77
+ ```
78
+
79
+ Here's how you push a title and message to a text feed widget.
80
+
81
+ ```ruby
82
+ update = Leftronic.pushText("yourTextStream", "This is my title.", "Hello World!")
83
+ ```
84
+
85
+ Let's push an array of names and values to a leaderboard widget. Be sure to create the array first (you may call it whatever you'd like). Be careful to use the proper syntax. Next, push the array to your widget.
86
+
87
+ ```ruby
88
+ leaderArray = Array[{"name" => "Johnny", "value" => 84}, {"name" => "Jamie", "value" => 75}, {"name" => "Lance", "value" => 62}]
89
+
90
+ update = Leftronic.pushBoard("yourBoardStream", leaderArray)
91
+ ```
92
+
93
+ Similar to the last example, let's push a list of items to a list widget. Same rules as last time.
94
+
95
+ ```ruby
96
+ listArray = Array[{"listItem" => "Elizabeth"}, {"listItem" => "Marshall"}, {"listItem" => "Claire"}, {"listItem" => "Nolan"}]
97
+
98
+ update = Leftronic.pushList("yourListStream", listArray)
99
+ ```
100
+
101
+ Feedback and Issues
102
+ -------------------
103
+
104
+ If you notice any bugs or other issues, submit a patch or send us a pull request. You can also send us an email at <support@leftronic.com>.
data/README.rdoc ADDED
@@ -0,0 +1,47 @@
1
+ = Leftronic Ruby Gem
2
+
3
+ == What is Leftronic?
4
+
5
+ Leftronic[https://beta.leftronic.com] makes powerful dashboards for business intelligence.
6
+
7
+ * Colorful and interactive data visualizations
8
+ * Templates to get you started right away
9
+ * Drag-and-drop editor makes it easy for anyone to create a powerful dashboard, customized to their needs
10
+ * Integration with Google Analytics, Twitter, Chartbeat, Zendesk, Basecamp, Pivotal Tracker, Facebook, and more to come!
11
+ * Dashboards can be protected or shared with a shortened URL
12
+ * Powerful API's for Javascript, PHP, Python, Ruby, and Java
13
+ * Python Package and Ruby Gem
14
+
15
+ == Technical Notes
16
+
17
+ We also suggest checking out our API[https://beta.leftronic.com/api] page. While the most detailed documentation is here, it has JSON and CURL examples in addition to a test form to send data to your custom widgets.
18
+
19
+ Authentication is handled by your API access key. We strongly encourage you to keep this key private. If you're logged in, your key can be found on our API[https://beta.leftronic.com/api] page. If you plan on using one of our API libraries, you will find instructions below on how to set your access key.
20
+
21
+ All API requests are made by sending a POST request to https://beta.leftronic.com/customSend with a properly formatted JSON packet. We do not support XML.
22
+
23
+ Current API version is 1.0.
24
+
25
+ == Getting Started
26
+
27
+ If you haven't already, create an account at https://beta.leftronic.com/accounts/login.
28
+
29
+ Get your API access key from the API overview page at https://beta.leftronic.com/api.
30
+
31
+ We recommend checking out our Tutorials[https://beta.leftronic.com/tutorials] to familiarize yourself with your dashboard.
32
+
33
+ For examples and further documentation, the source for this Gem is on Github[https://github.com/sonofabell/leftronic-ruby].
34
+
35
+ == Contributing to Leftronic Gem
36
+
37
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
38
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
39
+ * Fork the project
40
+ * Start a feature/bugfix branch
41
+ * Commit and push until you are happy with your contribution
42
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
43
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
44
+
45
+ == Copyright
46
+
47
+ Copyright (c) 2011 Leftronic[https://beta.leftronic.com]. License is GNU Library or Lesser General Public License (LGPL). A copy of the license is available at http://www.gnu.org/copyleft/lesser.html. See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "leftronicapi"
18
+ gem.homepage = "http://github.com/sonofabell/leftronic-ruby"
19
+ gem.license = "GNU - LGPL"
20
+ gem.summary = %Q{The official Ruby Gem to interface with the Leftronic API.}
21
+ gem.description = %Q{Provides a set of functions to update Leftronic dashboard widgets with custom data. Data is submitted by an HTTP POST request with data encoded in the JSON format.}
22
+ gem.email = "support@leftronic.com"
23
+ gem.authors = ["Peter Schaadt"]
24
+ ### dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "leftronic #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/leftronic.gemspec ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "leftronic"
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Peter Schaadt"]
12
+ s.date = "2011-09-27"
13
+ s.description = "Provides a set of functions to update Leftronic dashboard widgets with custom data. Data is submitted by an HTTP POST request with data encoded in the JSON format."
14
+ s.email = "support@leftronic.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "leftronic.gemspec",
30
+ "lib/leftronic.rb",
31
+ "test/helper.rb",
32
+ "test/test_leftronic.rb"
33
+ ]
34
+ s.homepage = "http://github.com/sonofabell/leftronic-ruby"
35
+ s.licenses = ["GNU - LGPL"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "1.8.10"
38
+ s.summary = "A Ruby Gem to interface with the Leftronic API."
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<curb>, [">= 0"])
45
+ s.add_runtime_dependency(%q<json>, [">= 0"])
46
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
47
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<curb>, [">= 0"])
53
+ s.add_dependency(%q<json>, [">= 0"])
54
+ s.add_dependency(%q<rake>, [">= 0"])
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
58
+ s.add_dependency(%q<rcov>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<curb>, [">= 0"])
62
+ s.add_dependency(%q<json>, [">= 0"])
63
+ s.add_dependency(%q<rake>, [">= 0"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ end
69
+ end
70
+
data/lib/leftronic.rb ADDED
@@ -0,0 +1,88 @@
1
+ require 'rubygems'
2
+ require 'curb'
3
+ require 'json'
4
+
5
+ class Leftronic
6
+
7
+ attr_accessor :accessKey
8
+
9
+ # Class variable
10
+ def initialize(accessKey)
11
+ @@accessKey = accessKey
12
+ end
13
+
14
+ def self.pushNumber(streamName, point)
15
+ ### Pushing a number to a Number, Horizontal/Vertical Bar, or Dial widget
16
+ parameters = {"accessKey" => @@accessKey, "streamName" => streamName, "point" => point}
17
+ # Convert to JSON
18
+ jsonData = parameters.to_json()
19
+ # Form request
20
+ urlRequest = Curl::Easy.http_post("https://beta.leftronic.com/customSend/", jsonData
21
+ # Make request
22
+ ) do |curl|
23
+ curl.headers['Accept'] = 'application/json'
24
+ curl.headers['Content-Type'] = 'application/json'
25
+ end
26
+ end
27
+
28
+ def self.pushLocation(streamName, lati, longi)
29
+ ### Pushing a geographic location (latitude and longitude) to a Map widget
30
+ parameters = {"accessKey" => @@accessKey, "streamName" => streamName, "point" => {
31
+ "latitude" => lati, "longitude" => longi}}
32
+ # Convert to JSON
33
+ jsonData = parameters.to_json()
34
+ # Form request
35
+ urlRequest = Curl::Easy.http_post("https://beta.leftronic.com/customSend/", jsonData
36
+ # Make request
37
+ ) do |curl|
38
+ curl.headers['Accept'] = 'application/json'
39
+ curl.headers['Content-Type'] = 'application/json'
40
+ end
41
+ end
42
+
43
+ def self.pushText(streamName, myTitle, myMsg)
44
+ ### Pushing a title and message to a Text Feed widget
45
+ parameters = {"accessKey" => @@accessKey, "streamName" => streamName, "point" => {
46
+ "title" => myTitle, "msg" => myMsg}}
47
+ # Convert to JSON
48
+ jsonData = parameters.to_json()
49
+ # Form request
50
+ urlRequest = Curl::Easy.http_post("https://beta.leftronic.com/customSend/", jsonData
51
+ # Make request
52
+ ) do |curl|
53
+ curl.headers['Accept'] = 'application/json'
54
+ curl.headers['Content-Type'] = 'application/json'
55
+ end
56
+ end
57
+
58
+ def self.pushBoard(streamName, leaderArray)
59
+ ### Pushing an array to the Leaderboard widget
60
+ parameters = {"accessKey" => @@accessKey, "streamName" => streamName, "point" => {
61
+ "leaderboard" => leaderArray}}
62
+ # Convert to JSON
63
+ jsonData = parameters.to_json()
64
+ # Form request
65
+ urlRequest = Curl::Easy.http_post("https://beta.leftronic.com/customSend/", jsonData
66
+ # Make request
67
+ ) do |curl|
68
+ curl.headers['Accept'] = 'application/json'
69
+ curl.headers['Content-Type'] = 'application/json'
70
+ end
71
+ end
72
+
73
+ def self.pushList(streamName, listArray)
74
+ ### Pushing an array to the List widget
75
+ parameters = {"accessKey" => @@accessKey, "streamName" => streamName, "point" => {
76
+ "list" => listArray}}
77
+ # Convert to JSON
78
+ jsonData = parameters.to_json()
79
+ # Form request
80
+ urlRequest = Curl::Easy.http_post("https://beta.leftronic.com/customSend/", jsonData
81
+ # Make CURL request
82
+ ) do |curl|
83
+ curl.headers['Accept'] = 'application/json'
84
+ curl.headers['Content-Type'] = 'application/json'
85
+ end
86
+ end
87
+
88
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'leftronic'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestLeftronic < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: leftronicapi
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Peter Schaadt
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-27 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: curb
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: json
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: shoulda
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: bundler
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ hash: 23
85
+ segments:
86
+ - 1
87
+ - 0
88
+ - 0
89
+ version: 1.0.0
90
+ type: :development
91
+ version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: jeweler
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ hash: 7
101
+ segments:
102
+ - 1
103
+ - 6
104
+ - 4
105
+ version: 1.6.4
106
+ type: :development
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: rcov
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ type: :development
121
+ version_requirements: *id007
122
+ description: Provides a set of functions to update Leftronic dashboard widgets with custom data. Data is submitted by an HTTP POST request with data encoded in the JSON format.
123
+ email: support@leftronic.com
124
+ executables: []
125
+
126
+ extensions: []
127
+
128
+ extra_rdoc_files:
129
+ - LICENSE.txt
130
+ - README.md
131
+ - README.rdoc
132
+ files:
133
+ - .document
134
+ - Gemfile
135
+ - Gemfile.lock
136
+ - LICENSE.txt
137
+ - README.md
138
+ - README.rdoc
139
+ - Rakefile
140
+ - VERSION
141
+ - leftronic.gemspec
142
+ - lib/leftronic.rb
143
+ - test/helper.rb
144
+ - test/test_leftronic.rb
145
+ homepage: http://github.com/sonofabell/leftronic-ruby
146
+ licenses:
147
+ - GNU - LGPL
148
+ post_install_message:
149
+ rdoc_options: []
150
+
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ hash: 3
159
+ segments:
160
+ - 0
161
+ version: "0"
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ hash: 3
168
+ segments:
169
+ - 0
170
+ version: "0"
171
+ requirements: []
172
+
173
+ rubyforge_project:
174
+ rubygems_version: 1.8.10
175
+ signing_key:
176
+ specification_version: 3
177
+ summary: The official Ruby Gem to interface with the Leftronic API.
178
+ test_files: []
179
+