fadss_lite 0.0.1

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: ea0ce6231d15f645aea90dc13e44983815a241c5
4
+ data.tar.gz: 44171e81b9226e16f557f9ee9b56f1843c01626d
5
+ SHA512:
6
+ metadata.gz: ea208ee70a2691c11b2764c3527620eb9febc44e800a2d75c55de148e5ccf7e3fcc1121d253b3ae7aafef3eaff981f770de8ac744326a5d70f76ef8834d5e70a
7
+ data.tar.gz: d90d2b5b802c5861581d78f783385d3acba18b96698d02206a530f95518a677dead52ea98f370cd0c8e7b6a83e6e3c8470ea1426a601c76ee7e46700d7f44268
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -c -f doc
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'Guardfile'
4
+ - 'fadss_lite.gemspec'
5
+ - 'Rakefile'
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/RegexpLiteral:
11
+ MaxSlashes: 0
12
+
13
+ Style/StringLiterals:
14
+ Enabled: false
15
+
16
+ Style/TrailingBlankLines:
17
+ Enabled: false
18
+
19
+ Style/LineLength:
20
+ Max: 1_00
21
+
22
+ Style/StringLiterals:
23
+ EnforcedStyle: single_quotes
24
+
25
+ Style/WordArray:
26
+ Exclude:
27
+ - 'spec/**/**'
28
+
29
+ Style/AsciiComments:
30
+ Enabled: false
31
+
32
+ CyclomaticComplexity:
33
+ Max: 10
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.1.1
5
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fadss_lite.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard :rspec, all_after_pass: false, all_on_start: false, cmd: 'rspec' do
2
+ watch(%r{spec/.+_spec\.rb$})
3
+ watch(%r{lib/(.+)\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
4
+ watch(%r{lib/(.+)/.+\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
5
+ end
6
+
7
+ guard :rubocop, all_on_start: false do
8
+ watch(%r{.+\.rb$})
9
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Rikiya Kawakami
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # FadssLite
2
+
3
+ A Ruby gem for communicating with the [FADSS](http://www.megakiku.jp/fadss/) REST API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fadss_lite'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fadss_lite
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'fadss_lite'
25
+ api = FadssLite::Api.new("apikey")
26
+ ```
27
+
28
+ ### Data Register
29
+ ```ruby
30
+ records = [
31
+ {
32
+ device: "AAA-BBB-0000000000",
33
+ data: [
34
+ at: "20140930013000000",
35
+ temp1: "23.4",
36
+ temp2: "24.1"
37
+ ]
38
+ }
39
+ ]
40
+ api.post_data(records) # => "{\"accept\":\"postPureData14093001000000000000000001\"}"
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/[my-github-username]/fadss_lite/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :travis
9
+ task travis: [:spec, :rubocop]
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fadss_lite/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fadss_lite"
8
+ spec.version = FadssLite::VERSION
9
+ spec.authors = ["Rikiya Kawakami"]
10
+ spec.email = ["ricky.k.yang@gmail.com"]
11
+ spec.summary = 'FADSS REST API client for Ruby.'
12
+ spec.description = 'FADSS REST API client for Ruby.'
13
+ spec.homepage = "https://github.com/jue58/fadss_lite"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "excon", ">=0.39.5"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency 'guard-rspec'
26
+ spec.add_development_dependency 'guard-rubocop'
27
+ spec.add_development_dependency 'webmock'
28
+ end
@@ -0,0 +1,21 @@
1
+ require 'excon'
2
+ require 'json'
3
+
4
+ module FadssLite
5
+ class Api
6
+ def initialize(key)
7
+ @connection =
8
+ Excon.new(
9
+ 'https://api.fadss.jp',
10
+ headers: {
11
+ 'X-Fadss-Key' => key,
12
+ 'Content-Type' => 'application/json'
13
+ }
14
+ )
15
+ end
16
+
17
+ def post_data(records)
18
+ @connection.post(path: '/v1/original_data.json', body: { records: records }.to_json).body
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module FadssLite
2
+ VERSION = '0.0.1'
3
+ end
data/lib/fadss_lite.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'fadss_lite/version'
2
+ require 'fadss_lite/api'
3
+
4
+ module FadssLite
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe FadssLite::Api do
4
+ let(:target) { FadssLite::Api.new(key) }
5
+ let(:key) { 'api_key' }
6
+
7
+ def headers
8
+ {
9
+ 'X-Fadss-Key' => 'api_key',
10
+ 'Content-Type' => 'application/json'
11
+ }
12
+ end
13
+
14
+ describe '#post' do
15
+ before(:each) do
16
+ stub_request(
17
+ :post,
18
+ 'https://api.fadss.jp/v1/original_data.json'
19
+ )
20
+ .with(body: { records: [] }.to_json, headers: headers)
21
+ .to_return(body: { a: :b }.to_json)
22
+ end
23
+
24
+ subject { target.post_data([]) }
25
+
26
+ it { is_expected.to eq({ a: :b }.to_json) }
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'fadss_lite'
3
+ require 'webmock/rspec'
4
+ require 'json'
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fadss_lite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rikiya Kawakami
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: excon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.39.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.39.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: FADSS REST API client for Ruby.
98
+ email:
99
+ - ricky.k.yang@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - fadss_lite.gemspec
114
+ - lib/fadss_lite.rb
115
+ - lib/fadss_lite/api.rb
116
+ - lib/fadss_lite/version.rb
117
+ - spec/fadss_lite/api_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: https://github.com/jue58/fadss_lite
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.2.2
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: FADSS REST API client for Ruby.
143
+ test_files:
144
+ - spec/fadss_lite/api_spec.rb
145
+ - spec/spec_helper.rb