muve 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/Rakefile +9 -0
- data/lib/muve.rb +5 -0
- data/lib/muve/location.rb +26 -0
- data/lib/muve/version.rb +3 -0
- data/muve.gemspec +25 -0
- data/spec/location_spec.rb +51 -0
- data/spec/spec_helper.rb +85 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e0a98cfd3af0c5386fdb04db259e42575703b7f
|
4
|
+
data.tar.gz: 3ec568b3d16b5e165c12689ec26184997a2eb8d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98a38f7cb5a064d6791a28bfaf45a7eaca2d102eaa7facb12facbdc9791d61fe6fccdbeba0bcabe31dc44e365951e00972e185e644cbf1d53c4c764fde478aaf
|
7
|
+
data.tar.gz: 9853c8c1018636279f2dbcee0c4edceb3cbc943d1f68a0b62732adab0f45aaffad50d17324d066eb07d9f42525db03ac9b647f39157b11547408d64f80462605
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
.ruby-*
|
2
|
+
*.swp
|
3
|
+
~*
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
.bundle
|
7
|
+
.config
|
8
|
+
.yardoc
|
9
|
+
Gemfile.lock
|
10
|
+
InstalledFiles
|
11
|
+
_yardoc
|
12
|
+
coverage
|
13
|
+
doc/
|
14
|
+
lib/bundler/man
|
15
|
+
pkg
|
16
|
+
rdoc
|
17
|
+
spec/reports
|
18
|
+
test/tmp
|
19
|
+
test/version_tmp
|
20
|
+
tmp
|
21
|
+
*.bundle
|
22
|
+
*.so
|
23
|
+
*.o
|
24
|
+
*.a
|
25
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 David Asabina
|
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/Rakefile
ADDED
data/lib/muve.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Location
|
2
|
+
attr_accessor :latitude, :longitude
|
3
|
+
|
4
|
+
alias_method :lat, :latitude
|
5
|
+
alias_method :lat=, :latitude=
|
6
|
+
|
7
|
+
alias_method :lng, :longitude
|
8
|
+
alias_method :lng=, :longitude=
|
9
|
+
alias_method :long, :longitude
|
10
|
+
alias_method :long=, :longitude=
|
11
|
+
|
12
|
+
def initialize(latitude, longitude, type=:wgs84)
|
13
|
+
@latitude, @longitude = latitude, longitude
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?
|
17
|
+
return false unless latitude.abs <= 90 && longitude.abs <= 180
|
18
|
+
end
|
19
|
+
|
20
|
+
def invalid?
|
21
|
+
!valid?
|
22
|
+
end
|
23
|
+
|
24
|
+
def random(center, range)
|
25
|
+
end
|
26
|
+
end
|
data/lib/muve/version.rb
ADDED
data/muve.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'muve/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'muve'
|
7
|
+
s.version = Muve::VERSION
|
8
|
+
s.summary = 'muve gem'
|
9
|
+
s.description = 'Basic helpers to be used with Muvement'
|
10
|
+
s.authors = ["David Asabina"]
|
11
|
+
s.email = ["david@supr.nu"]
|
12
|
+
s.files = ['lib/muve.rb']
|
13
|
+
s.homepage = ''
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_development_dependency "rspec", "~> 3.0.0"
|
24
|
+
s.add_development_dependency "ffaker"
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Location' do
|
4
|
+
before do
|
5
|
+
@lat, @lng = Faker::Geolocation.lat, Faker::Geolocation.lng
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'knows its latitude and longitude' do
|
9
|
+
expect(Location.new(@lat, @lng).latitude).to eq(@lat)
|
10
|
+
expect(Location.new(@lat, @lng).longitude).to eq(@lng)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'gets the longitude through its aliases' do
|
14
|
+
location = Location.new(@lat, @lng)
|
15
|
+
expect(location.lng).to eq(@lng)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'gets the latitude through aliases' do
|
19
|
+
location = Location.new(@lat, @lng)
|
20
|
+
expect(location.lat).to eq(@lat)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets the longitude through its aliases' do
|
24
|
+
location = Location.new(@lat, @lng)
|
25
|
+
|
26
|
+
longitude = Faker::Geolocation.lng
|
27
|
+
location.lng = longitude
|
28
|
+
expect(location.longitude).to eq(longitude)
|
29
|
+
|
30
|
+
longitude = Faker::Geolocation.lng
|
31
|
+
location.long = longitude
|
32
|
+
expect(location.longitude).to eq(longitude)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'sets the latitude through its aliases' do
|
36
|
+
location = Location.new(@lat, @lng)
|
37
|
+
latitude = Faker::Geolocation.lat
|
38
|
+
location.lat = latitude
|
39
|
+
expect(location.latitude).to eq(latitude)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'is invalid when latitude exceeds bounds' do
|
43
|
+
expect(Location.new(-181, @lng)).to be_invalid
|
44
|
+
expect(Location.new( 181, @lng)).to be_invalid
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'is invalid when longitude exceeds bounds' do
|
48
|
+
expect(Location.new(@lat, -91)).to be_invalid
|
49
|
+
expect(Location.new(@lat, 90)).to be_invalid
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'muve'
|
5
|
+
|
6
|
+
require 'ffaker'
|
7
|
+
|
8
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
10
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
11
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
12
|
+
#
|
13
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
14
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
15
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
16
|
+
# individual file that may not need all of that loaded. Instead, make a
|
17
|
+
# separate helper file that requires this one and then use it only in the specs
|
18
|
+
# that actually need it.
|
19
|
+
#
|
20
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
21
|
+
# users commonly want.
|
22
|
+
#
|
23
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
24
|
+
RSpec.configure do |config|
|
25
|
+
# The settings below are suggested to provide a good initial experience
|
26
|
+
# with RSpec, but feel free to customize to your heart's content.
|
27
|
+
=begin
|
28
|
+
# These two settings work together to allow you to limit a spec run
|
29
|
+
# to individual examples or groups you care about by tagging them with
|
30
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
31
|
+
# get run.
|
32
|
+
config.filter_run :focus
|
33
|
+
config.run_all_when_everything_filtered = true
|
34
|
+
|
35
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
36
|
+
# file, and it's useful to allow more verbose output when running an
|
37
|
+
# individual spec file.
|
38
|
+
if config.files_to_run.one?
|
39
|
+
# Use the documentation formatter for detailed output,
|
40
|
+
# unless a formatter has already been configured
|
41
|
+
# (e.g. via a command-line flag).
|
42
|
+
config.default_formatter = 'doc'
|
43
|
+
end
|
44
|
+
|
45
|
+
# Print the 10 slowest examples and example groups at the
|
46
|
+
# end of the spec run, to help surface which specs are running
|
47
|
+
# particularly slow.
|
48
|
+
config.profile_examples = 10
|
49
|
+
|
50
|
+
# Run specs in random order to surface order dependencies. If you find an
|
51
|
+
# order dependency and want to debug it, you can fix the order by providing
|
52
|
+
# the seed, which is printed after each run.
|
53
|
+
# --seed 1234
|
54
|
+
config.order = :random
|
55
|
+
|
56
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
57
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
58
|
+
# test failures related to randomization by passing the same `--seed` value
|
59
|
+
# as the one that triggered the failure.
|
60
|
+
Kernel.srand config.seed
|
61
|
+
|
62
|
+
# rspec-expectations config goes here. You can use an alternate
|
63
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
64
|
+
# assertions if you prefer.
|
65
|
+
config.expect_with :rspec do |expectations|
|
66
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
67
|
+
# For more details, see:
|
68
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
69
|
+
expectations.syntax = :expect
|
70
|
+
end
|
71
|
+
|
72
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
73
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
74
|
+
config.mock_with :rspec do |mocks|
|
75
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
76
|
+
# For more details, see:
|
77
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
78
|
+
mocks.syntax = :expect
|
79
|
+
|
80
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
81
|
+
# a real object. This is generally recommended.
|
82
|
+
mocks.verify_partial_doubles = true
|
83
|
+
end
|
84
|
+
=end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: muve
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Asabina
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ffaker
|
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
|
+
description: Basic helpers to be used with Muvement
|
70
|
+
email:
|
71
|
+
- david@supr.nu
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- Rakefile
|
80
|
+
- lib/muve.rb
|
81
|
+
- lib/muve/location.rb
|
82
|
+
- lib/muve/version.rb
|
83
|
+
- muve.gemspec
|
84
|
+
- spec/location_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: muve gem
|
110
|
+
test_files:
|
111
|
+
- spec/location_spec.rb
|
112
|
+
- spec/spec_helper.rb
|