gmaps4rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,6 @@
1
1
  module Gmaps4rails
2
2
  class GmapsController < ApplicationController
3
- #unloadable
4
- #layout 'gmaps4rails' # this allows you to have a gem-wide layout
5
-
3
+ #unloadable
6
4
  def index
7
5
  @model = params["model"]
8
6
  if @model.constantize.is_gmappable? == true
@@ -1,10 +1,10 @@
1
- Rails.application.routes.draw do |map|
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, :show ],
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
@@ -8,6 +8,6 @@ module ApplicationHelper
8
8
  end
9
9
  display += '</select></form>'
10
10
  end
11
- display
11
+ return display
12
12
  end
13
13
  end
@@ -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
 
@@ -31,7 +31,7 @@
31
31
  request += '&options=' + split_filter_value[1];
32
32
  }
33
33
  }
34
- alert(request);
34
+ alert(request); //TODO remove for real production
35
35
  gmaps4rails_ctaLayer = new google.maps.KmlLayer(request);
36
36
  gmaps4rails_ctaLayer.setMap(gmaps4rails_map);
37
37
  }
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
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: Enable easy display of items (taken from a model) on a Google Map. Uses Javascript API V3.
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: Enable easy display of items (taken from a model) on a Google Map. Uses Javascript API V3.
86
- test_files:
87
- - test/test_helper.rb
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,10 +0,0 @@
1
- module Gmaps4rails
2
- class Gmaps < ActiveRecord::Base
3
- set_table_name "gmaps4rails_widgets"
4
-
5
- def make
6
- puts "widget made"
7
- end
8
-
9
- end
10
- end
@@ -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
@@ -1,8 +0,0 @@
1
- module Gmaps4rails
2
- class Engine < Rails::Engine
3
-
4
- config.mount_at = '/gmaps4rails'
5
- config.widget_factory_name = 'Factory Name'
6
-
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- class CreateGmaps4railsTables < ActiveRecord::Migration
2
- def self.up
3
- SCHEMA_AUTO_INSERTED_HERE
4
- end
5
-
6
- def self.down
7
- drop_table :gmaps4rails_widgets
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 0) do
2
-
3
- create_table :gmaps4rails_widgets, :force => true do |t|
4
- t.string :title
5
- t.datetime :created_at
6
- t.datetime :updated_at
7
- end
8
-
9
- add_index :gmaps4rails_widgets, [:title]
10
-
11
- end
@@ -1,8 +0,0 @@
1
- namespace :gmaps4rails do
2
-
3
- desc "example gem rake task"
4
- task :report => :environment do
5
- puts "you just ran the example gem rake task"
6
- end
7
-
8
- end
@@ -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
@@ -1,11 +0,0 @@
1
- require 'test_helper'
2
-
3
- class WidgetTest < Test::Unit::TestCase
4
- load_schema
5
-
6
- def test_fixtures_are_working
7
- assert_equal gmaps4rails_widget(:first).title, "This is the title"
8
- end
9
-
10
-
11
- end