plotlyrb 0.1.2

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
+ SHA512:
3
+ data.tar.gz: f8ba8954c500971712f3231d3f2d43bac2fed278cfa9de6da45389c25c6c459792ce4ce6260306aff049c0084ee68ab3477559aae97f2c1812930315fc999d03
4
+ metadata.gz: ebc67494b4c92d19c0df370d67702ad7d58d30a1627da2b811294393a584bdd19a53b9ae277a08ab1c603de759e0d7e24197326c96430f1c4b0975df0d46a0df
5
+ SHA1:
6
+ data.tar.gz: beda0dece41c51bc40bd5561e8b91068b382e2a8
7
+ metadata.gz: ae8b4c55d6b40d7d43e207c0e43f67f1d0c3e8e3
data/.gitignore ADDED
@@ -0,0 +1,36 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.8.7
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at andrewfnewman@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in plotlyrb.gemspec
4
+ gemspec
5
+
6
+ gem 'backports', '~> 3.6', :require => false
7
+
8
+ group :development, :test do
9
+ gem 'test-unit'
10
+ gem 'mocha'
11
+ gem 'colored'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ plotlyrb (0.1.2)
5
+ backports (~> 3.6, >= 3.6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ backports (3.6.6)
11
+ colored (1.2)
12
+ metaclass (0.0.4)
13
+ mocha (1.1.0)
14
+ metaclass (~> 0.0.1)
15
+ power_assert (0.2.7)
16
+ rake (10.5.0)
17
+ test-unit (3.1.5)
18
+ power_assert
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ backports (~> 3.6)
25
+ bundler (~> 1.11)
26
+ colored
27
+ mocha
28
+ plotlyrb!
29
+ rake (~> 10.0)
30
+ test-unit
31
+
32
+ BUNDLED WITH
33
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Andrew Newman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Plotlyrb
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/plotlyrb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'plotlyrb'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install plotlyrb
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/plotlyrb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "plotlyrb"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ require 'net/https'
2
+ require 'base64'
3
+
4
+ module Plotlyrb
5
+ class ApiV2
6
+
7
+ PROTOCOL = 'https'
8
+ HOSTNAME = 'api.plot.ly'
9
+ BASE_PATH = 'v2'
10
+ BASE_URI = "#{PROTOCOL}://#{HOSTNAME}/#{BASE_PATH}"
11
+
12
+ IMAGES = URI.parse("#{BASE_URI}/images")
13
+
14
+ def self.headers(username, api_key)
15
+ encoded_auth = Base64.encode64("#{username}:#{api_key}")
16
+ {
17
+ 'plotly-client-platform' => "Ruby #{Plotlyrb::VERSION}",
18
+ 'authorization' => "Basic #{encoded_auth}",
19
+ 'content-type' => 'application/json'
20
+ }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require 'net/https'
2
+ require 'json'
3
+
4
+ module Plotlyrb
5
+ class PlotImage
6
+
7
+ VALID_IMAGE_FORMATS = [:png, :svg, :pdf, :eps]
8
+
9
+ def initialize(username, api_key, url=ApiV2::IMAGES)
10
+ @url = url
11
+ @headers = ApiV2::headers(username, api_key)
12
+ @https = Net::HTTP.new(url.host, url.port)
13
+ @https.use_ssl = true
14
+ end
15
+
16
+ def plot_image(data, image_path, image_type, layout = {})
17
+ raise "image_type #{image_type} not supported" unless VALID_IMAGE_FORMATS.include?(image_type)
18
+ payload = { :figure => { :data => data, :layout => layout }, :format => image_type.to_s }.to_json
19
+ request = Net::HTTP::Post.new(@url.path, @headers)
20
+ request.body = payload
21
+ response = @https.request(request)
22
+ image_path_with_ext = "#{image_path}"
23
+ IO.binwrite(image_path_with_ext, response.body)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Plotlyrb
2
+ VERSION = '0.1.2'
3
+ end
data/lib/plotlyrb.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'backports'
2
+
3
+ require_relative 'plotlyrb/version'
4
+ require_relative 'plotlyrb/api_v2'
5
+ require_relative 'plotlyrb/plot_image'
data/plotlyrb.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'plotlyrb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "plotlyrb"
8
+ spec.version = Plotlyrb::VERSION
9
+ spec.authors = ["Veitchlister Consulting"]
10
+ spec.email = ["developers@veitchlister.com.au"]
11
+
12
+ spec.summary = %q{A Ruby wrapper around the Plotly RESTful API.}
13
+ spec.description = %q{Trying to complete a complete API based on the Python Library https://github.com/plotly/plotly.py/tree/master/plotly/plotly}
14
+ spec.homepage = "https://github.com/vlc/plotlyrb"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+ spec.required_ruby_version = '>= 1.8.7'
30
+
31
+ spec.add_runtime_dependency 'backports', '~> 3.6', '>= 3.6.0'
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.11"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: plotlyrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Veitchlister Consulting
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+
12
+ date: 2016-01-21 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: backports
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: "3.6"
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 3.6.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: "1.11"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: "10.0"
45
+ type: :development
46
+ version_requirements: *id003
47
+ description: Trying to complete a complete API based on the Python Library https://github.com/plotly/plotly.py/tree/master/plotly/plotly
48
+ email:
49
+ - developers@veitchlister.com.au
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - .gitignore
58
+ - .ruby-version
59
+ - CODE_OF_CONDUCT.md
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - LICENSE.txt
63
+ - README.md
64
+ - Rakefile
65
+ - bin/console
66
+ - bin/setup
67
+ - lib/plotlyrb.rb
68
+ - lib/plotlyrb/api_v2.rb
69
+ - lib/plotlyrb/plot_image.rb
70
+ - lib/plotlyrb/version.rb
71
+ - plotlyrb.gemspec
72
+ homepage: https://github.com/vlc/plotlyrb
73
+ licenses:
74
+ - MIT
75
+ metadata:
76
+ allowed_push_host: "TODO: Set to 'http://mygemserver.com'"
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 1.8.7
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 2.0.16
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: A Ruby wrapper around the Plotly RESTful API.
99
+ test_files: []
100
+
101
+ has_rdoc: