daru-apiclient 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4243cfb5d7f06f20b0d44efe0afba6dffc59d16bc3fe916397f00c57d53b1bc9
4
+ data.tar.gz: 29d670ec373e52e519d94360fe28e6aa03031490dc9ec10c294979946a25d9d4
5
+ SHA512:
6
+ metadata.gz: f1dca620b3e1c7e3d94d9c58d52a4e27d57136c7b39eb7fc0b31335757f2bebedb79acf1f67d9904622d8ba7552c74ec470b967e1a5e007a97012dc2f6df5891
7
+ data.tar.gz: 23ce321d1ace5e48695e06ee960096f193b2ebe5df1a8666897820f4048cf75743dab9877508a775d35a956c1fc03f6b5282ce2cd0ad612cd6f8a79743678122
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.0
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in daru-client.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ daru-apiclient (0.0.1)
5
+ daru
6
+ httparty
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ backports (3.11.4)
12
+ daru (0.2.1)
13
+ backports
14
+ packable (~> 1.3.9)
15
+ diff-lcs (1.3)
16
+ httparty (0.16.3)
17
+ mime-types (~> 3.0)
18
+ multi_xml (>= 0.5.2)
19
+ mime-types (3.2.2)
20
+ mime-types-data (~> 3.2015)
21
+ mime-types-data (3.2018.0812)
22
+ multi_xml (0.6.0)
23
+ packable (1.3.10)
24
+ backports
25
+ rake (10.5.0)
26
+ rspec (3.8.0)
27
+ rspec-core (~> 3.8.0)
28
+ rspec-expectations (~> 3.8.0)
29
+ rspec-mocks (~> 3.8.0)
30
+ rspec-core (3.8.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-expectations (3.8.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-mocks (3.8.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-support (3.8.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 2.0)
45
+ daru-apiclient!
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+
49
+ BUNDLED WITH
50
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
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,70 @@
1
+ # 🔶 Daru::APIClient 🔶
2
+
3
+
4
+ ## 🔸Overview🔸
5
+ Get JSON data from Rest API with [httparty](https://github.com/jnunemaker/httparty) and create Daru::DataFrame.
6
+
7
+ ## 🔸Installation🔸
8
+
9
+ ```bash
10
+ gem install daru-apiclient
11
+ ```
12
+
13
+ ## 🔸Requirements🔸
14
+
15
+ * Ruby
16
+ * Daru
17
+ * httparty
18
+ * Jupyter notebook with IRuby (reccomended)
19
+
20
+ ## 🔸Examples🔸
21
+ Get [BestGems.org](http://bestgems.org/)'s data using API.
22
+ ![alt text](https://raw.githubusercontent.com/kojix2/daru-apiclient/master/notebook/daru-apiclient.png)
23
+ ```bash
24
+ juypter notebook
25
+ ```
26
+
27
+ ```ruby
28
+ require 'daru/apiclient'
29
+ require 'daru/view'
30
+ Daru::View.plotting_library = :googlecharts
31
+
32
+ C = Daru::APIClient.new "http://bestgems.org/api/v1/gems"
33
+
34
+ def bestgems(gem)
35
+ df = C.get("/#{gem}/daily_downloads.json")
36
+ df.rename_vectors "daily_downloads" => gem
37
+ df
38
+ end
39
+
40
+ rack = bestgems "rack"
41
+ rake = bestgems "rake"
42
+ json = bestgems "json"
43
+ thor = bestgems "thor"
44
+
45
+ df = rack.join(rake, how: :inner, on: ["date"])
46
+ .join(json, how: :inner, on: ["date"])
47
+ .join(thor, how: :inner, on: ["date"])
48
+
49
+ df.order = ["date", "rack", "rake", "json", "thor"]
50
+ df.sort!(["date"])
51
+ df = df.row[-300..-20]
52
+
53
+ chart = Daru::View::Plot.new(df,
54
+ type: :area,
55
+ isStacked: true,
56
+ height: 400
57
+ )
58
+ chart.show_in_iruby
59
+ ```
60
+
61
+ ## 🔸Development🔸
62
+ * This gem will keeps its simplicity.
63
+
64
+ ## 🔸Contributing🔸
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kojix2/daru-apiclient.
67
+
68
+ ## 🔸License🔸
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "daru/client"
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(__FILE__)
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,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "daru/apiclient/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "daru-apiclient"
8
+ spec.version = Daru::APIClient::VERSION
9
+ spec.authors = ["kojix2"]
10
+ spec.email = ["2xijok@gmail.com"]
11
+
12
+ spec.summary = "HTTParty => JSON => Daru::DataFrame"
13
+ spec.description = "Get JSON data from RestAPI with httparty and create Daru::DataFrame."
14
+ spec.homepage = "https://github.com/kojix2/daru-apiclient"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_runtime_dependency "daru"
27
+ spec.add_runtime_dependency "httparty"
28
+
29
+ spec.add_development_dependency "bundler", "~> 2.0"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ end
@@ -0,0 +1,23 @@
1
+ require 'httparty'
2
+ require 'daru'
3
+ require "daru/apiclient/version"
4
+
5
+ module Daru
6
+ class APIClient
7
+ include HTTParty
8
+
9
+ def initialize(uri)
10
+ self.class.base_uri uri
11
+ end
12
+
13
+ def get(*args)
14
+ response = self.class.get(*args)
15
+ Daru::DataFrame.new(response.to_a)
16
+ end
17
+
18
+ def post(*args)
19
+ response = self.class.post(*args)
20
+ Daru::DataFrame.new(response.to_a)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Daru
2
+ class APIClient
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
Binary file
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daru-apiclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kojix2
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: daru
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: Get JSON data from RestAPI with httparty and create Daru::DataFrame.
84
+ email:
85
+ - 2xijok@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - daru-client.gemspec
101
+ - lib/daru/apiclient.rb
102
+ - lib/daru/apiclient/version.rb
103
+ - notebook/daru-apiclient.png
104
+ homepage: https://github.com/kojix2/daru-apiclient
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubygems_version: 3.0.1
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: HTTParty => JSON => Daru::DataFrame
127
+ test_files: []