geomock-rails 1.0.0
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.
- data/.gitignore +5 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/geomock-rails.gemspec +23 -0
- data/lib/generators/geomock/install/install_generator.rb +37 -0
- data/lib/geomock/rails/engine.rb +7 -0
- data/lib/geomock/rails/version.rb +5 -0
- data/lib/geomock/rails.rb +6 -0
- data/lib/geomock-rails.rb +1 -0
- data/vendor/assets/javascripts/geomock.js +113 -0
- data/vendor/assets/javascripts/geomock.min.js +2 -0
- metadata +83 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012 Nikita Fedyashev
|
|
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.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# geomock-rails
|
|
2
|
+
|
|
3
|
+
GeoMock! For Rails! So great.
|
|
4
|
+
|
|
5
|
+
This gem provides:
|
|
6
|
+
|
|
7
|
+
* GeoMock v 1.0
|
|
8
|
+
|
|
9
|
+
## Rails 3.1
|
|
10
|
+
|
|
11
|
+
For Rails 3.1 and greater, the files will be added to the asset pipeline and available for you to use. These two lines will be added to the file `app/assets/javascripts/application.js` by default:
|
|
12
|
+
|
|
13
|
+
//= require jquery
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
New Rails 3.1 apps include geomock-rails in the Gemfile by default.
|
|
18
|
+
|
|
19
|
+
### Installation
|
|
20
|
+
|
|
21
|
+
In your Gemfile, add this line:
|
|
22
|
+
|
|
23
|
+
gem "geomock-rails"
|
|
24
|
+
|
|
25
|
+
Then, run `bundle install`. To invoke the generator, run:
|
|
26
|
+
|
|
27
|
+
rails generate geomock:install
|
|
28
|
+
|
|
29
|
+
You're done!
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/geomock/rails/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "geomock-rails"
|
|
6
|
+
s.version = GeoMock::Rails::VERSION
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.authors = ["Nikita Fedyashev"]
|
|
9
|
+
s.email = ["loci.master@gmail.com"]
|
|
10
|
+
s.homepage = "http://rubygems.org/gems/geomock-rails"
|
|
11
|
+
s.summary = "Use GeoMock with Rails 3"
|
|
12
|
+
s.description = "This gem provides geomock for your Rails 3 application."
|
|
13
|
+
|
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
|
15
|
+
s.rubyforge_project = "geomock-rails"
|
|
16
|
+
|
|
17
|
+
s.add_dependency "railties", ">= 3.2.0.beta", "< 5.0"
|
|
18
|
+
s.add_dependency "thor", "~> 0.14"
|
|
19
|
+
|
|
20
|
+
s.files = `git ls-files`.split("\n")
|
|
21
|
+
s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
|
|
22
|
+
s.require_path = 'lib'
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
|
|
3
|
+
# Supply generator for Rails 3.0.x or if asset pipeline is not enabled
|
|
4
|
+
if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled
|
|
5
|
+
module GeoMock
|
|
6
|
+
module Generators
|
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
8
|
+
|
|
9
|
+
desc "This generator installs GeoMock"
|
|
10
|
+
source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
|
|
11
|
+
|
|
12
|
+
def copy_geomock
|
|
13
|
+
say_status("copying", "GeoMock", :green)
|
|
14
|
+
copy_file "geomock.js", "public/javascripts/geomock.js"
|
|
15
|
+
copy_file "geomock.min.js", "public/javascripts/geomock.min.js"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
module GeoMock
|
|
22
|
+
module Generators
|
|
23
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
24
|
+
desc "Just show instructions so people will know what to do when mistakenly using generator for Rails 3.1 apps"
|
|
25
|
+
|
|
26
|
+
def do_nothing
|
|
27
|
+
say_status("deprecated", "You are using Rails 3.1 with the asset pipeline enabled, so this generator is not needed.")
|
|
28
|
+
say_status("", "The necessary files are already in your asset pipeline.")
|
|
29
|
+
say_status("", "Just add `//= require geomock` to your app/assets/javascripts/application.js")
|
|
30
|
+
say_status("", "If you do not want the asset pipeline enabled, you may turn it off in application.rb and re-run this generator.")
|
|
31
|
+
# ok, nothing
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'geomock/rails'
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
/*
|
|
3
|
+
(c) 2011 Jan Monschke
|
|
4
|
+
v1.0
|
|
5
|
+
GeoMock is licensed under the MIT license.
|
|
6
|
+
*/ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
|
7
|
+
(function() {
|
|
8
|
+
if (typeof navigator === "undefined" || navigator === null) {
|
|
9
|
+
window.navigator = {};
|
|
10
|
+
}
|
|
11
|
+
delete navigator.geolocation;
|
|
12
|
+
return navigator.geolocation = {
|
|
13
|
+
delay: 1000,
|
|
14
|
+
shouldFail: false,
|
|
15
|
+
failsAt: -1,
|
|
16
|
+
errorMessage: "There was an error retrieving the position!",
|
|
17
|
+
currentTimeout: -1,
|
|
18
|
+
lastPosReturned: 0,
|
|
19
|
+
_sanitizeLastReturned: function() {
|
|
20
|
+
if (this.lastPosReturned > this.waypoints.length - 1) {
|
|
21
|
+
return this.lastPosReturned = 0;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
_geoCall: function(method, success, error) {
|
|
25
|
+
if (this.shouldFail && (error != null)) {
|
|
26
|
+
return this.currentTimeout = window[method].call(null, __bind(function() {
|
|
27
|
+
return error(this.errorMessage);
|
|
28
|
+
}, this), this.delay);
|
|
29
|
+
} else {
|
|
30
|
+
if (success != null) {
|
|
31
|
+
return this.currentTimeout = window[method].call(null, __bind(function() {
|
|
32
|
+
success(this.waypoints[this.lastPosReturned++]);
|
|
33
|
+
return this._sanitizeLastReturned();
|
|
34
|
+
}, this), this.delay);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
getCurrentPosition: function(success, error) {
|
|
39
|
+
return this._geoCall("setTimeout", success, error);
|
|
40
|
+
},
|
|
41
|
+
watchPosition: function(success, error) {
|
|
42
|
+
this._geoCall("setInterval", success, error);
|
|
43
|
+
return this.currentTimeout;
|
|
44
|
+
},
|
|
45
|
+
clearWatch: function(id) {
|
|
46
|
+
return clearInterval(id);
|
|
47
|
+
},
|
|
48
|
+
waypoints: [
|
|
49
|
+
{
|
|
50
|
+
coords: {
|
|
51
|
+
latitude: 52.5168,
|
|
52
|
+
longitude: 13.3889,
|
|
53
|
+
accuracy: 1500
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
coords: {
|
|
57
|
+
latitude: 52.5162,
|
|
58
|
+
longitude: 13.3890,
|
|
59
|
+
accuracy: 1334
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
coords: {
|
|
63
|
+
latitude: 52.5154,
|
|
64
|
+
longitude: 13.3890,
|
|
65
|
+
accuracy: 631
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
coords: {
|
|
69
|
+
latitude: 52.5150,
|
|
70
|
+
longitude: 13.3890,
|
|
71
|
+
accuracy: 361
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
coords: {
|
|
75
|
+
latitude: 52.5144,
|
|
76
|
+
longitude: 13.3890,
|
|
77
|
+
accuracy: 150
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
coords: {
|
|
81
|
+
latitude: 52.5138,
|
|
82
|
+
longitude: 13.3890,
|
|
83
|
+
accuracy: 65
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
coords: {
|
|
87
|
+
latitude: 52.5138,
|
|
88
|
+
longitude: 13.3895,
|
|
89
|
+
accuracy: 65
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
coords: {
|
|
93
|
+
latitude: 52.5139,
|
|
94
|
+
longitude: 13.3899,
|
|
95
|
+
accuracy: 65
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
coords: {
|
|
99
|
+
latitude: 52.5140,
|
|
100
|
+
longitude: 13.3906,
|
|
101
|
+
accuracy: 65
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
coords: {
|
|
105
|
+
latitude: 52.5140,
|
|
106
|
+
longitude: 13.3910,
|
|
107
|
+
accuracy: 65
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
})();
|
|
113
|
+
}).call(this);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// (c) 2011 Jan Monschke v1.0 GeoMock is licensed under the MIT license.
|
|
2
|
+
(function(){var __bind=function(fn,me){return function(){return fn.apply(me,arguments);};};(function(){if(typeof navigator==="undefined"||navigator===null){window.navigator={};}delete navigator.geolocation;return navigator.geolocation={delay:1000,shouldFail:false,failsAt:-1,errorMessage:"There was an error retrieving the position!",currentTimeout:-1,lastPosReturned:0,_sanitizeLastReturned:function(){if(this.lastPosReturned>this.waypoints.length-1){return this.lastPosReturned=0;}},_geoCall:function(method,success,error){if(this.shouldFail&&(error!=null)){return this.currentTimeout=window[method].call(null,__bind(function(){return error(this.errorMessage);},this),this.delay);}else{if(success!=null){return this.currentTimeout=window[method].call(null,__bind(function(){success(this.waypoints[this.lastPosReturned++]);return this._sanitizeLastReturned();},this),this.delay);}}},getCurrentPosition:function(success,error){return this._geoCall("setTimeout",success,error);},watchPosition:function(success,error){this._geoCall("setInterval",success,error);return this.currentTimeout;},clearWatch:function(id){return clearInterval(id);},waypoints:[{coords:{latitude:52.5168,longitude:13.3889,accuracy:1500}},{coords:{latitude:52.5162,longitude:13.3890,accuracy:1334}},{coords:{latitude:52.5154,longitude:13.3890,accuracy:631}},{coords:{latitude:52.5150,longitude:13.3890,accuracy:361}},{coords:{latitude:52.5144,longitude:13.3890,accuracy:150}},{coords:{latitude:52.5138,longitude:13.3890,accuracy:65}},{coords:{latitude:52.5138,longitude:13.3895,accuracy:65}},{coords:{latitude:52.5139,longitude:13.3899,accuracy:65}},{coords:{latitude:52.5140,longitude:13.3906,accuracy:65}},{coords:{latitude:52.5140,longitude:13.3910,accuracy:65}}]};})();}).call(this);
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: geomock-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Nikita Fedyashev
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-02-24 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: railties
|
|
16
|
+
requirement: &2153551520 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 3.2.0.beta
|
|
22
|
+
- - <
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: '5.0'
|
|
25
|
+
type: :runtime
|
|
26
|
+
prerelease: false
|
|
27
|
+
version_requirements: *2153551520
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: thor
|
|
30
|
+
requirement: &2153550780 !ruby/object:Gem::Requirement
|
|
31
|
+
none: false
|
|
32
|
+
requirements:
|
|
33
|
+
- - ~>
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0.14'
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: *2153550780
|
|
39
|
+
description: This gem provides geomock for your Rails 3 application.
|
|
40
|
+
email:
|
|
41
|
+
- loci.master@gmail.com
|
|
42
|
+
executables: []
|
|
43
|
+
extensions: []
|
|
44
|
+
extra_rdoc_files: []
|
|
45
|
+
files:
|
|
46
|
+
- .gitignore
|
|
47
|
+
- LICENSE
|
|
48
|
+
- README.md
|
|
49
|
+
- Rakefile
|
|
50
|
+
- geomock-rails.gemspec
|
|
51
|
+
- lib/generators/geomock/install/install_generator.rb
|
|
52
|
+
- lib/geomock-rails.rb
|
|
53
|
+
- lib/geomock/rails.rb
|
|
54
|
+
- lib/geomock/rails/engine.rb
|
|
55
|
+
- lib/geomock/rails/version.rb
|
|
56
|
+
- vendor/assets/javascripts/geomock.js
|
|
57
|
+
- vendor/assets/javascripts/geomock.min.js
|
|
58
|
+
homepage: http://rubygems.org/gems/geomock-rails
|
|
59
|
+
licenses: []
|
|
60
|
+
post_install_message:
|
|
61
|
+
rdoc_options: []
|
|
62
|
+
require_paths:
|
|
63
|
+
- lib
|
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
+
none: false
|
|
72
|
+
requirements:
|
|
73
|
+
- - ! '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 1.3.6
|
|
76
|
+
requirements: []
|
|
77
|
+
rubyforge_project: geomock-rails
|
|
78
|
+
rubygems_version: 1.8.15
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 3
|
|
81
|
+
summary: Use GeoMock with Rails 3
|
|
82
|
+
test_files: []
|
|
83
|
+
has_rdoc:
|