gmaps4rails 0.0.2 → 0.0.3
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/app/controllers/gmaps4rails/gmaps_controller.rb +1 -3
- data/config/routes.rb +2 -2
- data/lib/acts_as_gmappable/base.rb +0 -12
- data/lib/application_helper.rb +1 -1
- data/lib/engine.rb +0 -5
- data/public/javascripts/gmaps4rails.js +1 -1
- metadata +7 -17
- data/app/models/gmaps4rails/gmaps.rb +0 -10
- data/app/views/gmaps4rails/gmaps/index.html.erb +0 -1
- data/lib/rails/generators/gmaps4rails/gmaps4rails_generator.rb +0 -75
- data/lib/rails/generators/gmaps4rails/templates/initializer.rb +0 -8
- data/lib/rails/generators/gmaps4rails/templates/migration.rb +0 -9
- data/lib/rails/generators/gmaps4rails/templates/schema.rb +0 -11
- data/lib/rails/railties/tasks.rake +0 -8
- data/test/test_helper.rb +0 -56
- data/test/unit/gmaps4rails_widget_test.rb +0 -11
data/config/routes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
Rails.application.routes.draw do
|
1
|
+
Rails.application.routes.draw do
|
2
2
|
|
3
3
|
mount_at = Gmaps4rails::Engine.config.mount_at
|
4
4
|
|
5
5
|
match mount_at => 'gmaps4rails/gmaps#index'
|
6
6
|
|
7
|
-
map.resources :gmaps, :only => [ :index
|
7
|
+
map.resources :gmaps, :only => [ :index ],
|
8
8
|
:controller => "gmaps4rails/gmaps",
|
9
9
|
:path_prefix => mount_at#,
|
10
10
|
#:name_prefix => "gmaps4rails_"
|
@@ -14,19 +14,7 @@ module Gmaps4rails
|
|
14
14
|
module Config
|
15
15
|
def acts_as_gmappable options = {}
|
16
16
|
before_save :get_coordinates
|
17
|
-
|
18
|
-
#attr_accessor :goptions
|
19
17
|
|
20
|
-
#write_inheritable_attribute(:goptions, {}) if goptions.nil?
|
21
|
-
#
|
22
|
-
# def goptions
|
23
|
-
# read_inheritable_attribute(:goptions)
|
24
|
-
# end
|
25
|
-
# This is where arbitrary code goes that you want to
|
26
|
-
# add to the class that declared "acts_as_widget"
|
27
|
-
|
28
|
-
#has_many :widgets, :class_name => 'Gmaps4rails::Widget'
|
29
|
-
|
30
18
|
def self.is_gmappable?
|
31
19
|
true
|
32
20
|
end
|
data/lib/application_helper.rb
CHANGED
data/lib/engine.rb
CHANGED
@@ -10,11 +10,6 @@ module Gmaps4rails
|
|
10
10
|
config.widget_factory_name = "gmaps4rails"
|
11
11
|
config.mount_at = '/'
|
12
12
|
|
13
|
-
# Load rake tasks
|
14
|
-
rake_tasks do
|
15
|
-
load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')
|
16
|
-
end
|
17
|
-
|
18
13
|
# Check the gem config
|
19
14
|
initializer "check config" do |app|
|
20
15
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmaps4rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Roth
|
@@ -19,7 +19,7 @@ date: 2010-10-10 00:00:00 +02:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description:
|
22
|
+
description: IN HEAVY DEV. Will enable easy display of items (taken from a model) on a Google Map. Uses Javascript API V3.
|
23
23
|
email: apnea.diving.deep@gmail.com
|
24
24
|
executables: []
|
25
25
|
|
@@ -31,24 +31,15 @@ files:
|
|
31
31
|
- app/controllers/gmaps4rails/gmaps_controller.rb
|
32
32
|
- app/helpers/application_helper.rb
|
33
33
|
- app/helpers/gmaps4rails/Gmaps_helper.rb
|
34
|
-
- app/models/gmaps4rails/gmaps.rb
|
35
34
|
- app/views/gmaps4rails/_map.html.erb
|
36
|
-
- app/views/gmaps4rails/gmaps/index.html.erb
|
37
35
|
- app/views/gmaps4rails/gmaps/index.xml.builder
|
38
36
|
- config/routes.rb
|
39
37
|
- lib/acts_as_gmappable/base.rb
|
40
38
|
- lib/application_helper.rb
|
41
39
|
- lib/engine.rb
|
42
40
|
- lib/gmaps4rails.rb
|
43
|
-
- lib/rails/generators/gmaps4rails/gmaps4rails_generator.rb
|
44
|
-
- lib/rails/generators/gmaps4rails/templates/initializer.rb
|
45
|
-
- lib/rails/generators/gmaps4rails/templates/migration.rb
|
46
|
-
- lib/rails/generators/gmaps4rails/templates/schema.rb
|
47
|
-
- lib/rails/railties/tasks.rake
|
48
41
|
- public/javascripts/gmaps4rails.js
|
49
42
|
- README.rdoc
|
50
|
-
- test/test_helper.rb
|
51
|
-
- test/unit/gmaps4rails_widget_test.rb
|
52
43
|
has_rdoc: true
|
53
44
|
homepage: http://github.com/apneadiving/test-for-maps
|
54
45
|
licenses: []
|
@@ -82,7 +73,6 @@ rubyforge_project:
|
|
82
73
|
rubygems_version: 1.3.7
|
83
74
|
signing_key:
|
84
75
|
specification_version: 3
|
85
|
-
summary:
|
86
|
-
test_files:
|
87
|
-
|
88
|
-
- test/unit/gmaps4rails_widget_test.rb
|
76
|
+
summary: IN HEAVY DEV. Will enable easy display of items (taken from a model) on a Google Map. Uses Javascript API V3.
|
77
|
+
test_files: []
|
78
|
+
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= debug @objects%>
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
class Gmaps4railsGenerator < Rails::Generators::Base
|
5
|
-
include Rails::Generators::Migration
|
6
|
-
|
7
|
-
def self.source_root
|
8
|
-
File.join(File.dirname(__FILE__), 'templates')
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.next_migration_number(dirname) #:nodoc:
|
12
|
-
if ActiveRecord::Base.timestamped_migrations
|
13
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
-
else
|
15
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
# Every method that is declared below will be automatically executed when the generator is run
|
21
|
-
|
22
|
-
def create_migration_file
|
23
|
-
f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')
|
24
|
-
schema = f.read; f.close
|
25
|
-
|
26
|
-
schema.gsub!(/ActiveRecord::Schema.*\n/, '')
|
27
|
-
schema.gsub!(/^end\n*$/, '')
|
28
|
-
|
29
|
-
f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')
|
30
|
-
migration = f.read; f.close
|
31
|
-
migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)
|
32
|
-
|
33
|
-
tmp = File.open "tmp/~migration_ready.rb", "w"
|
34
|
-
tmp.write migration
|
35
|
-
tmp.close
|
36
|
-
|
37
|
-
migration_template '../../../tmp/~migration_ready.rb',
|
38
|
-
'db/migrate/create_gmaps4rails_tables.rb'
|
39
|
-
remove_file 'tmp/~migration_ready.rb'
|
40
|
-
end
|
41
|
-
|
42
|
-
def copy_initializer_file
|
43
|
-
copy_file 'initializer.rb', 'config/initializers/gmaps4rails.rb'
|
44
|
-
end
|
45
|
-
|
46
|
-
def update_application_template
|
47
|
-
f = File.open "app/views/layouts/application.html.erb"
|
48
|
-
layout = f.read; f.close
|
49
|
-
|
50
|
-
if layout =~ /<%=[ ]+yield[ ]+%>/
|
51
|
-
print " \e[1m\e[34mquestion\e[0m Your layouts/application.html.erb layout currently has the line <%= yield %>. This gem needs to change this line to <%= content_for?(:content) ? yield(:content) : yield %> to support its nested layouts. This change should not affect any of your existing layouts or views. Is this okay? [y/n] "
|
52
|
-
begin
|
53
|
-
answer = gets.chomp
|
54
|
-
end while not answer =~ /[yn]/i
|
55
|
-
|
56
|
-
if answer =~ /y/i
|
57
|
-
|
58
|
-
layout.gsub!(/<%=[ ]+yield[ ]+%>/, '<%= content_for?(:content) ? yield(:content) : yield %>')
|
59
|
-
|
60
|
-
tmp = File.open "tmp/~application.html.erb", "w"
|
61
|
-
tmp.write layout; tmp.close
|
62
|
-
|
63
|
-
remove_file 'app/views/layouts/application.html.erb'
|
64
|
-
copy_file '../../../tmp/~application.html.erb',
|
65
|
-
'app/views/layouts/application.html.erb'
|
66
|
-
remove_file 'tmp/~application.html.erb'
|
67
|
-
end
|
68
|
-
elsif layout =~ /<%=[ ]+content_for\?\(:content\) \? yield\(:content\) : yield[ ]+%>/
|
69
|
-
puts " \e[1m\e[33mskipping\e[0m layouts/application.html.erb modification is already done."
|
70
|
-
else
|
71
|
-
puts " \e[1m\e[31mconflict\e[0m The gem is confused by your layouts/application.html.erb. It does not contain the default line <%= yield %>, you may need to make manual changes to get this gem's nested layouts working. Visit ###### for details."
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'yaml'
|
6
|
-
require 'active_record'
|
7
|
-
require 'mysql'
|
8
|
-
|
9
|
-
require 'app/models/gmaps4rails/widget.rb'
|
10
|
-
|
11
|
-
def gmaps4rails_widget( fixture_name )
|
12
|
-
id = @@fixtures['gmaps4rails_widget'][ fixture_name.to_s ][ 'id' ]
|
13
|
-
gmaps4rails::Widget.find( id )
|
14
|
-
end
|
15
|
-
|
16
|
-
def load_schema
|
17
|
-
config = YAML::load( IO.read( File.dirname(__FILE__) + '/database.yml') )
|
18
|
-
|
19
|
-
# Manually initialize the database
|
20
|
-
conn = Mysql.real_connect( config['mysql']['host'], config['mysql']['username'], config['mysql']['password'] )
|
21
|
-
conn.query( "CREATE DATABASE IF NOT EXISTS #{config['mysql']['database']}" )
|
22
|
-
|
23
|
-
ActiveRecord::Base.establish_connection( config['mysql'] )
|
24
|
-
ActiveRecord::Base.connection()
|
25
|
-
|
26
|
-
load(File.dirname(__FILE__) + "/../" +
|
27
|
-
"lib/rails/generators/gmaps4rails/templates/schema.rb")
|
28
|
-
|
29
|
-
@@fixtures = {}
|
30
|
-
|
31
|
-
load_fixture( 'gmaps4rails_widget' )
|
32
|
-
end
|
33
|
-
|
34
|
-
def load_fixture( table )
|
35
|
-
@@fixtures[ table ] = {}
|
36
|
-
fixture = YAML::load( IO.read( File.dirname(__FILE__) + "/fixtures/#{table}.yml") )
|
37
|
-
@@fixtures[ table ] = fixture
|
38
|
-
|
39
|
-
klass = class_eval table.titleize.gsub(/ /, '::')
|
40
|
-
|
41
|
-
fixture.each do |record_name, record|
|
42
|
-
record.each do |column, value|
|
43
|
-
if ( match = column.match(/(.*)_id/) )
|
44
|
-
fixture_reference = "gmaps4rails_" + match[1].pluralize
|
45
|
-
if value.is_a? Symbol
|
46
|
-
r = class_eval "#{fixture_reference}( '#{value}' )"
|
47
|
-
record[ column ] = r.id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
r = klass.create( record )
|
53
|
-
@@fixtures[ table ][ record_name ][ 'id' ] = r.id
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|