carsensor-api 0.0.1.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +16 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +32 -0
- data/.rubocop/gemspec.yml +2 -0
- data/.rubocop/layout.yml +57 -0
- data/.rubocop/lint.yml +8 -0
- data/.rubocop/metrics.yml +13 -0
- data/.rubocop/rails.yml +2 -0
- data/.rubocop/rspec.yml +34 -0
- data/.rubocop/security.yml +2 -0
- data/.rubocop/style.yml +91 -0
- data/.rubocop_todo.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/bundle +105 -0
- data/bin/console +14 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +8 -0
- data/bin/yard +29 -0
- data/bin/yardoc +29 -0
- data/bin/yri +29 -0
- data/carsensor-api.gemspec +37 -0
- data/lib/carsensor/api.rb +142 -0
- data/lib/carsensor/api/version.rb +7 -0
- data/vendor/.gitignore +2 -0
- metadata +199 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: df4d8bdfa2ef6e4210bfae98f7801b1571cac2d794c5f618c1833c5f590d48f8
|
4
|
+
data.tar.gz: 7159a8f0944360ea6f935c710c043d569d4d841fde069e17b8ac2751d1be7649
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d1f1111efd31f7548472191fb5cb179e02855fa12434cf73f07b00426382bd64ac19cb75e38cb74a854ab351e3b5401b9ff1a76176fc90ac158846acba4f558
|
7
|
+
data.tar.gz: cf7aef493c202fa72e5bb8c25d13f4ffe7b0946a960e8602094093948e01a236cf40fde58446111eee3d4c7a7c63909e9637a8d11c060690c0212c4d465a7e88
|
@@ -0,0 +1,16 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.6.0
|
6
|
+
steps:
|
7
|
+
- run: gem update bundler
|
8
|
+
- checkout
|
9
|
+
- restore_cache:
|
10
|
+
key: gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "carsensor-api.gemspec" }}
|
11
|
+
- run: bin/setup
|
12
|
+
- save_cache:
|
13
|
+
key: gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "carsensor-api.gemspec" }}
|
14
|
+
paths: vendor/bundle
|
15
|
+
- run: bin/rubocop
|
16
|
+
- run: bin/rake spec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
|
4
|
+
inherit_from:
|
5
|
+
- .rubocop/gemspec.yml
|
6
|
+
- .rubocop/layout.yml
|
7
|
+
- .rubocop/lint.yml
|
8
|
+
- .rubocop/metrics.yml
|
9
|
+
- .rubocop/rspec.yml
|
10
|
+
- .rubocop/security.yml
|
11
|
+
- .rubocop/style.yml
|
12
|
+
- .rubocop_todo.yml
|
13
|
+
|
14
|
+
AllCops:
|
15
|
+
DisplayCopNames: true
|
16
|
+
DisplayStyleGuide: true
|
17
|
+
EnabledByDefault: true
|
18
|
+
Exclude:
|
19
|
+
- '*.gemspec'
|
20
|
+
- 'bin/*'
|
21
|
+
- 'vendor/bundle/**/*'
|
22
|
+
- 'spec/spec_helper.rb'
|
23
|
+
ExtraDetails: true
|
24
|
+
TargetRubyVersion: 2.6
|
25
|
+
UseCache: true
|
26
|
+
|
27
|
+
# temporarily disabled stuff
|
28
|
+
Metrics/LineLength:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
RSpec/ExampleLength:
|
32
|
+
Enabled: false
|
data/.rubocop/layout.yml
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Layout/ClassStructure:
|
2
|
+
Enabled: true
|
3
|
+
Categories:
|
4
|
+
module_inclusion:
|
5
|
+
- include
|
6
|
+
- prepend
|
7
|
+
- extend
|
8
|
+
ExpectedOrder:
|
9
|
+
- module_inclusion
|
10
|
+
- constants
|
11
|
+
- public_class_methods
|
12
|
+
- initializer
|
13
|
+
- public_methods
|
14
|
+
- protected_methods
|
15
|
+
- private_methods
|
16
|
+
|
17
|
+
Layout/CommentIndentation:
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
Layout/EmptyLineAfterGuardClause:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
Layout/EmptyLineAfterMagicComment:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Layout/EmptyLineBetweenDefs:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Layout/EmptyLines:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
Layout/EmptyLinesAroundAccessModifier:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Layout/ExtraSpacing:
|
36
|
+
Enabled: true
|
37
|
+
AllowForAlignment: false
|
38
|
+
|
39
|
+
Layout/IndentHeredoc:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Layout/LeadingCommentSpace:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Layout/SpaceAfterColon:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Layout/SpaceInsideBlockBraces:
|
49
|
+
Enabled: true
|
50
|
+
EnforcedStyle: space
|
51
|
+
EnforcedStyleForEmptyBraces: space
|
52
|
+
SpaceBeforeBlockParameters: false
|
53
|
+
|
54
|
+
Layout/SpaceInsideHashLiteralBraces:
|
55
|
+
Enabled: true
|
56
|
+
EnforcedStyle: no_space
|
57
|
+
EnforcedStyleForEmptyBraces: no_space
|
data/.rubocop/lint.yml
ADDED
data/.rubocop/rails.yml
ADDED
data/.rubocop/rspec.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
RSpec/AlignLeftLetBrace:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
RSpec/AlignRightLetBrace:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
RSpec/AnyInstance:
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
RSpec/ContextWording:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
RSpec/DescribedClass:
|
14
|
+
Enabled: true
|
15
|
+
EnforcedStyle: explicit
|
16
|
+
|
17
|
+
RSpec/EmptyLineAfterFinalLet:
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
RSpec/ExampleLength:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
RSpec/LeadingSubject:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
RSpec/LetBeforeExamples:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
RSpec/NotToNot:
|
30
|
+
Enabled: true
|
31
|
+
EnforcedStyle: not_to
|
32
|
+
|
33
|
+
RSpec/ScatteredLet:
|
34
|
+
Enabled: true
|
data/.rubocop/style.yml
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
Style/AccessModifierDeclarations:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/BlockDelimiters:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: braces_for_chaining
|
7
|
+
|
8
|
+
Style/CharacterLiteral:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/CollectionMethods:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Style/Copyright:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: true
|
19
|
+
Exclude:
|
20
|
+
- spec/**/*
|
21
|
+
|
22
|
+
Style/ExpandPathArguments:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Style/FormatString:
|
26
|
+
Enabled: true
|
27
|
+
EnforcedStyle: percent
|
28
|
+
|
29
|
+
Style/FormatStringToken:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/FrozenStringLiteralComment:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Style/GlobalVars:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
Style/HashSyntax:
|
39
|
+
Enabled: true
|
40
|
+
EnforcedStyle: ruby19
|
41
|
+
|
42
|
+
Style/LambdaCall:
|
43
|
+
EnforcedStyle: braces
|
44
|
+
|
45
|
+
Style/MethodCalledOnDoEndBlock:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Style/MethodCallWithArgsParentheses:
|
49
|
+
Enabled: true
|
50
|
+
IgnoreMacros: true
|
51
|
+
IgnoredMethods:
|
52
|
+
# Language core
|
53
|
+
- raise
|
54
|
+
- require
|
55
|
+
# Rspec
|
56
|
+
- be
|
57
|
+
- describe
|
58
|
+
- expect
|
59
|
+
- include_context
|
60
|
+
- not_to
|
61
|
+
- shared_context
|
62
|
+
- to
|
63
|
+
# Rake
|
64
|
+
- task
|
65
|
+
# gem/bundler
|
66
|
+
- add_dependency
|
67
|
+
- add_development_dependency
|
68
|
+
- source
|
69
|
+
|
70
|
+
Style/MutableConstant:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
Style/PercentLiteralDelimiters:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/Semicolon:
|
77
|
+
Enabled: true
|
78
|
+
AllowAsExpressionSeparator: true
|
79
|
+
|
80
|
+
Style/Send:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
Style/StringHashKeys:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
Style/StringLiterals:
|
87
|
+
Enabled: true
|
88
|
+
EnforcedStyle: single_quotes
|
89
|
+
|
90
|
+
Style/UnneededPercentQ:
|
91
|
+
Enabled: true
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
|
3
|
+
# using RuboCop version 0.62.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 OZAWA Sakuro
|
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,39 @@
|
|
1
|
+
# Carsensor::API
|
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/carsensor/api`. 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 'carsensor-api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install carsensor-api
|
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. Then, run `rake spec` to run the tests. 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]/carsensor-api.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "carsensor/api"
|
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/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/setup
ADDED
data/bin/yard
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'yard' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("yard", "yard")
|
data/bin/yardoc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'yardoc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("yard", "yardoc")
|
data/bin/yri
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'yri' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("yard", "yri")
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'carsensor/api/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'carsensor-api'
|
9
|
+
spec.version = Carsensor::API::VERSION
|
10
|
+
spec.authors = ['OZAWA Sakuro']
|
11
|
+
spec.email = ['sakuro@2238.club']
|
12
|
+
|
13
|
+
spec.summary = %q{Ruby binding to Carsensor API}
|
14
|
+
spec.description = %q{Ruby binding to Carsensor API(https://webservice.recruit.co.jp/carsensor/reference.html)}
|
15
|
+
spec.homepage = 'https://github.com/sakuro/carsensor-api'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_dependency 'rack'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
30
|
+
spec.add_development_dependency 'pry-byebug'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
spec.add_development_dependency 'rubocop'
|
34
|
+
spec.add_development_dependency 'rubocop-rspec'
|
35
|
+
spec.add_development_dependency 'yard'
|
36
|
+
spec.add_development_dependency 'webmock'
|
37
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'carsensor/api/version'
|
6
|
+
require 'rack/utils'
|
7
|
+
|
8
|
+
module Carsensor
|
9
|
+
# A thin wrapper for Carsensor Web API at (https://webservice.recruit.co.jp/carsensor/reference.html
|
10
|
+
class API
|
11
|
+
# Exception class for errors which would occur during invocation of Carsensor API
|
12
|
+
class Error < StandardError
|
13
|
+
# @param message [String] Message for the exception
|
14
|
+
# @param code [Integer,String] Error code of API itself or error status of HTTP
|
15
|
+
def initialize(message:, code:)
|
16
|
+
super('%s(code: %s)' % [message, code])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ENDPOINT_BASE_URI = URI('http://webservice.recruit.co.jp')
|
21
|
+
|
22
|
+
# A class for metadata of responses from Carsensor API
|
23
|
+
module Metadata
|
24
|
+
attr_accessor :metadata
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param key [String] The API key
|
28
|
+
def initialize(key:)
|
29
|
+
raise ArgumentError, 'key: must be a String' unless key.is_a?(String)
|
30
|
+
|
31
|
+
@key = key
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns bodies for given criterion
|
35
|
+
#
|
36
|
+
# @param query [Hash] options to specify criterion
|
37
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] bodies and metadata
|
38
|
+
def bodies(**query)
|
39
|
+
call_api(:body, '/carsensor/body/v1', query)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns brands for given criterion
|
43
|
+
#
|
44
|
+
# @param query [Hash] options to specify criterion
|
45
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] brands and metadata
|
46
|
+
def brands(**query)
|
47
|
+
call_api(:brand, '/carsensor/brand/v1', query)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns colors for given criterion
|
51
|
+
#
|
52
|
+
# @param query [Hash] options to specify criterion
|
53
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] colors and metadata
|
54
|
+
def colors(**query)
|
55
|
+
call_api(:color, '/carsensor/color/v1', query)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns countries for given criterion
|
59
|
+
#
|
60
|
+
# @param query [Hash] options to specify criterion
|
61
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] countries and metadata
|
62
|
+
def countries(**query)
|
63
|
+
call_api(:country, '/carsensor/country/v1', query)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns large areas for given criterion
|
67
|
+
#
|
68
|
+
# @param query [Hash] options to specify criterion
|
69
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] large areas and metadata
|
70
|
+
def large_areas(**query)
|
71
|
+
call_api(:large_area, '/carsensor/large_area/v1', query)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns prefectures for given criterion
|
75
|
+
#
|
76
|
+
# @param query [Hash] options to specify criterion
|
77
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] prefectures and metadata
|
78
|
+
def prefectures(**query)
|
79
|
+
call_api(:pref, '/carsensor/pref/v1', query)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns used cars for given criterion
|
83
|
+
#
|
84
|
+
# @param query [Hash] options to specify criterion
|
85
|
+
# @return [Array<Hash>,Carsensor::API::Metadata] used cars and metadata
|
86
|
+
def used_cars(**query)
|
87
|
+
call_api(:usedcar, '/carsensor/usedcar/v1', query)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns number of total available used cars.
|
91
|
+
#
|
92
|
+
# @return [Integer] number of total available used cars
|
93
|
+
def total_available
|
94
|
+
large_areas.map {|area| used_cars(large_area: area[:code]).metadata[:results_available] }.sum
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def call_api(root, path, **query)
|
100
|
+
(method(:build_uri) >> method(:read_uri) >> method(:parse_body) >> method(:extract_result).curry[root]).(path, query)
|
101
|
+
end
|
102
|
+
|
103
|
+
def build_uri(path, **query)
|
104
|
+
ENDPOINT_BASE_URI.dup.tap do |u|
|
105
|
+
u.path = path
|
106
|
+
u.query = Rack::Utils.build_query(key: @key, format: 'json', **query.transform_values {|v| v.is_a?(Array) ? v.join(',') : v })
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def read_uri(uri)
|
111
|
+
uri.read
|
112
|
+
rescue OpenURI::HTTPError => e
|
113
|
+
status = e.io.status
|
114
|
+
raise Error.new(message: status[1], code: status[0])
|
115
|
+
end
|
116
|
+
|
117
|
+
def parse_body(body)
|
118
|
+
JSON.parse(body, symbolize_names: true).tap do |data|
|
119
|
+
api_error = data.dig(:results, :error, 0)
|
120
|
+
raise Error.new(**api_error) if api_error
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def extract_result(root, data)
|
125
|
+
(data.dig(:results, root) || []).tap do |result|
|
126
|
+
result.extend(Metadata)
|
127
|
+
result.metadata = extract_metadata(data).freeze
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def extract_metadata(data)
|
132
|
+
%i[api_version results_available results_returned results_start].each_with_object({}) do |field, metadata|
|
133
|
+
metadata[field] = extract_metadata_field(data, field)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def extract_metadata_field(data, field)
|
138
|
+
value = data.dig(:results, field)
|
139
|
+
field.match?(/\Aresults_/) && !value.is_a?(Integer) ? Integer(value, 10) : value # rubocop:disable Performance/StartWith
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
data/vendor/.gitignore
ADDED
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carsensor-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- OZAWA Sakuro
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
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
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Ruby binding to Carsensor API(https://webservice.recruit.co.jp/carsensor/reference.html)
|
140
|
+
email:
|
141
|
+
- sakuro@2238.club
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".circleci/config.yml"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".rubocop.yml"
|
150
|
+
- ".rubocop/gemspec.yml"
|
151
|
+
- ".rubocop/layout.yml"
|
152
|
+
- ".rubocop/lint.yml"
|
153
|
+
- ".rubocop/metrics.yml"
|
154
|
+
- ".rubocop/rails.yml"
|
155
|
+
- ".rubocop/rspec.yml"
|
156
|
+
- ".rubocop/security.yml"
|
157
|
+
- ".rubocop/style.yml"
|
158
|
+
- ".rubocop_todo.yml"
|
159
|
+
- Gemfile
|
160
|
+
- LICENSE.txt
|
161
|
+
- README.md
|
162
|
+
- Rakefile
|
163
|
+
- bin/bundle
|
164
|
+
- bin/console
|
165
|
+
- bin/rake
|
166
|
+
- bin/rspec
|
167
|
+
- bin/rubocop
|
168
|
+
- bin/setup
|
169
|
+
- bin/yard
|
170
|
+
- bin/yardoc
|
171
|
+
- bin/yri
|
172
|
+
- carsensor-api.gemspec
|
173
|
+
- lib/carsensor/api.rb
|
174
|
+
- lib/carsensor/api/version.rb
|
175
|
+
- vendor/.gitignore
|
176
|
+
homepage: https://github.com/sakuro/carsensor-api
|
177
|
+
licenses:
|
178
|
+
- MIT
|
179
|
+
metadata: {}
|
180
|
+
post_install_message:
|
181
|
+
rdoc_options: []
|
182
|
+
require_paths:
|
183
|
+
- lib
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 1.3.1
|
194
|
+
requirements: []
|
195
|
+
rubygems_version: 3.0.1
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: Ruby binding to Carsensor API
|
199
|
+
test_files: []
|