starline 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/starline.rb +5 -0
- data/lib/starline/builders.rb +7 -0
- data/lib/starline/builders/geo_points.rb +22 -0
- data/lib/starline/builders/tracks.rb +36 -0
- data/lib/starline/entities/geo_point.rb +13 -0
- data/lib/starline/entities/track.rb +13 -0
- data/lib/starline/entities/tracks_collection.rb +23 -0
- data/lib/starline/telematics.rb +30 -0
- data/lib/starline/version.rb +3 -0
- data/starline.gemspec +30 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 479179b8a62f12f04476cd6ba6f653b9f4d86406
|
4
|
+
data.tar.gz: 925f4f70aa604a3e3ee7250f215a7ccbe83334a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fddb071ac90be7118bbd5f4dbcb0d52e8fe6263f89bbe308fa356de00a37a392f1cb245eb304cd25e2f7251a5fa42e87532067736f587c920c4429b94bf3b5c8
|
7
|
+
data.tar.gz: c8774aca9f5724b4b5611d4ecdd28c4dd10639b7efc4921e079ece28e45f273c92a29ca613e550434d3ed9b927b313b18eaf50f90e7ebd4b7031b3021cb96eae
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 sharipov.ru@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
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Sharipov Ruslan
|
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
|
+
# Starline Telematics
|
2
|
+
|
3
|
+
StarlineTelematics is a ruby library-wrapper over telematics JSON data from
|
4
|
+
satellite security and monitoring service which is used in StarLine car alarm
|
5
|
+
systems (https://starline-online.ru)
|
6
|
+
|
7
|
+
The purpose of the library is to provide easy way for getting your car tracks
|
8
|
+
data and present them in usable format for further analyzing / building
|
9
|
+
applications around it.
|
10
|
+
|
11
|
+
The library is for personal use only and, of course, it doesn't send your data
|
12
|
+
anywhere so you can be confident using it.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'starline'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install starline
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
Read JSON files:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
telematics = StarLine::Telematics.new(track_file_path)
|
36
|
+
```
|
37
|
+
|
38
|
+
Get GeoPoint objects:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
telematics.geo_points
|
42
|
+
```
|
43
|
+
|
44
|
+
Get all tracks - connections between geo points:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
telematics.tracks
|
48
|
+
```
|
49
|
+
|
50
|
+
Filter out tracks when with zero distance:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
telematics.tracks.without_parking_tracks
|
54
|
+
```
|
55
|
+
|
56
|
+
## Development
|
57
|
+
|
58
|
+
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.
|
59
|
+
|
60
|
+
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).
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sharipov-ru/starline. 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.
|
65
|
+
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
70
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "starline"
|
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
data/lib/starline.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'starline/entities/geo_point'
|
2
|
+
|
3
|
+
module Starline
|
4
|
+
module Builders
|
5
|
+
class GeoPoints
|
6
|
+
def self.build(tracks_json)
|
7
|
+
points = tracks_json.fetch("desc")
|
8
|
+
points.map { |point_hash| build_geo_point(point_hash) }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def self.build_geo_point(hash)
|
13
|
+
Entities::GeoPoint.new(
|
14
|
+
lat: hash["y"],
|
15
|
+
lon: hash["x"],
|
16
|
+
timestamp: hash["ts"]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fast_haversine'
|
2
|
+
require 'starline/entities/track'
|
3
|
+
require 'starline/entities/tracks_collection'
|
4
|
+
|
5
|
+
module Starline
|
6
|
+
module Builders
|
7
|
+
class Tracks
|
8
|
+
def self.build(geo_points)
|
9
|
+
tracks = []
|
10
|
+
|
11
|
+
geo_points.each_cons(2) do |start_point, end_point|
|
12
|
+
tracks << build_track(start_point, end_point)
|
13
|
+
end
|
14
|
+
|
15
|
+
Entities::TracksCollection.new(tracks)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def self.build_track(start_point, end_point)
|
20
|
+
Entities::Track.new(
|
21
|
+
start_point: start_point,
|
22
|
+
end_point: end_point,
|
23
|
+
distance: calculate_distance(start_point, end_point)
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.calculate_distance(start_point, end_point)
|
28
|
+
FastHaversine.distance_between(
|
29
|
+
[start_point.lat, start_point.lon],
|
30
|
+
[end_point.lat, end_point.lon],
|
31
|
+
:km
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Starline
|
2
|
+
module Entities
|
3
|
+
class Track
|
4
|
+
attr_reader :start_point, :end_point, :distance
|
5
|
+
|
6
|
+
def initialize(start_point:, end_point:, distance:)
|
7
|
+
@start_point = start_point
|
8
|
+
@end_point = end_point
|
9
|
+
@distance = distance
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Starline
|
2
|
+
module Entities
|
3
|
+
class TracksCollection
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(tracks)
|
7
|
+
@tracks = tracks
|
8
|
+
end
|
9
|
+
|
10
|
+
def each(&block)
|
11
|
+
@tracks.each(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def size
|
15
|
+
@tracks.size
|
16
|
+
end
|
17
|
+
|
18
|
+
def without_parking_tracks
|
19
|
+
@tracks.reject { |track| track.distance == 0 }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'starline/builders'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Starline
|
5
|
+
class Telematics
|
6
|
+
attr_reader :tracks_path
|
7
|
+
|
8
|
+
def initialize(tracks_path)
|
9
|
+
@tracks_path = File.expand_path(tracks_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def tracks_file
|
13
|
+
File.open(tracks_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def geo_points
|
17
|
+
Starline::Builders::GeoPoints.build(parsed_tracks_file)
|
18
|
+
end
|
19
|
+
|
20
|
+
def tracks
|
21
|
+
Starline::Builders::Tracks.build(geo_points)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def parsed_tracks_file
|
27
|
+
JSON.parse(File.read(tracks_file))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/starline.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'starline/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "starline"
|
8
|
+
spec.version = Starline::VERSION
|
9
|
+
spec.authors = ["Sharipov Ruslan"]
|
10
|
+
spec.email = ["sharipov.ru@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby wrapper for JSON data from StarLine website.}
|
13
|
+
spec.description = %q{StarlineTelematics is a ruby library-wrapper over telematics JSON data from
|
14
|
+
satellite security and monitoring service which is used in StarLine car alarm
|
15
|
+
systems (https://starline-online.ru)}
|
16
|
+
spec.homepage = "https://github.com/sharipov-ru/starline_telematics"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "fast_haversine", "0.0.1"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: starline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sharipov Ruslan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fast_haversine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
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.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
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: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
description: |-
|
84
|
+
StarlineTelematics is a ruby library-wrapper over telematics JSON data from
|
85
|
+
satellite security and monitoring service which is used in StarLine car alarm
|
86
|
+
systems (https://starline-online.ru)
|
87
|
+
email:
|
88
|
+
- sharipov.ru@gmail.com
|
89
|
+
executables: []
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rspec"
|
95
|
+
- ".ruby-version"
|
96
|
+
- ".travis.yml"
|
97
|
+
- CODE_OF_CONDUCT.md
|
98
|
+
- Gemfile
|
99
|
+
- LICENSE.txt
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- bin/console
|
103
|
+
- bin/setup
|
104
|
+
- lib/starline.rb
|
105
|
+
- lib/starline/builders.rb
|
106
|
+
- lib/starline/builders/geo_points.rb
|
107
|
+
- lib/starline/builders/tracks.rb
|
108
|
+
- lib/starline/entities/geo_point.rb
|
109
|
+
- lib/starline/entities/track.rb
|
110
|
+
- lib/starline/entities/tracks_collection.rb
|
111
|
+
- lib/starline/telematics.rb
|
112
|
+
- lib/starline/version.rb
|
113
|
+
- starline.gemspec
|
114
|
+
homepage: https://github.com/sharipov-ru/starline_telematics
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.5.1
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Ruby wrapper for JSON data from StarLine website.
|
138
|
+
test_files: []
|