gmap_coordinates_picker 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,7 +11,7 @@ Usage
11
11
  add the following to your `Gemfile`:
12
12
 
13
13
  ```ruby
14
- gem " gmap_coordinates_picker"
14
+ gem "gmap_coordinates_picker"
15
15
  ```
16
16
 
17
17
  Then, add in your form:
@@ -42,12 +42,19 @@ beside the option depicted on the example above it can be configured with the fo
42
42
  - `map_height` - default "400px"
43
43
  - `api_key` - Google Map api key (optional)
44
44
  - 'static' - to display only static map, by default it set to false and the map will be editable
45
- - 'map_handler' - javascript map object to operate custom event on rendered map by default gMapObj is assigned as map object. You can implement any google map API methods like setCenter, zoom with that onject
45
+ - 'map_handler' - javascript map object to operate custom event on rendered map by default gMapObj is assigned as map object. You can implement any google map API methods like setCenter, zoom with that object
46
46
 
47
47
 
48
48
  VERSION
49
49
  =======
50
50
 
51
+ -0.0.5
52
+ - formtastic support added
53
+ - generator for settings override added
54
+ - passing option is simple and gmap_conf option depricated
55
+
56
+ -0.0.4
57
+ - yanked
51
58
  -0.0.3
52
59
  - `static map` feature added
53
60
  - `javascript map handler` support added
data/Rakefile CHANGED
@@ -4,6 +4,24 @@ begin
4
4
  rescue LoadError
5
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
6
  end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'GmapCoordinatesPicker'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
7
25
 
8
26
  Bundler::GemHelper.install_tasks
9
27
 
@@ -0,0 +1,16 @@
1
+ module GmapCoordinatesPicker
2
+ module Generators
3
+ class ConfigGenerator < Rails::Generators::Base
4
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
5
+
6
+ desc <<DESC
7
+ Description:
8
+ Copies GmapCoordinatesPicker configuration file to your application's initializer directory.
9
+ DESC
10
+
11
+ def copy_config_file
12
+ template 'gmap_coordinates_picker_config.rb', 'config/initializers/gmap_coordinates_picker_config.rb'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ GmapCoordinatesPicker.configure do |config|
2
+ #config.lat_column = :latitude
3
+ #config.lng_column = :longitude
4
+ #config.default_coordinates = [23.727666666, 90.410550] #Dhaka (my home town) center point :)
5
+ #config.map_handler = 'gMapObj' #javascript map object
6
+ #config.zoom_level = 10
7
+ #config.map_container_class = 'gmap_coordinate_picker_container'
8
+ #config.map_width = '600px'
9
+ #config.map_height = '400px'
10
+ end
@@ -0,0 +1,37 @@
1
+ require 'active_support/configurable'
2
+
3
+ module GmapCoordinatesPicker
4
+
5
+ def self.configure(&block)
6
+ yield @config ||= GmapCoordinatesPicker::Configuration.new
7
+ end
8
+
9
+ # Global settings for GmapCoordinatesPicker
10
+ def self.config
11
+ @config
12
+ end
13
+
14
+ # need a Class for 3.0
15
+ class Configuration #:nodoc:
16
+ include ActiveSupport::Configurable
17
+ config_accessor :lat_column
18
+ config_accessor :lng_column
19
+ config_accessor :default_coordinates
20
+ config_accessor :map_handler
21
+ config_accessor :zoom_level
22
+ config_accessor :map_container_class
23
+ config_accessor :map_width
24
+ config_accessor :map_height
25
+ end
26
+
27
+ configure do |config|
28
+ config.lat_column = :latitude
29
+ config.lng_column = :longitude
30
+ config.default_coordinates = [23.727666666, 90.410550] #Dhaka (my home town) center point :)
31
+ config.map_handler = 'gMapObj'
32
+ config.zoom_level = 10
33
+ config.map_container_class = 'gmap_coordinate_picker_container'
34
+ config.map_width = '600px'
35
+ config.map_height = '400px'
36
+ end
37
+ end
@@ -3,33 +3,18 @@ require 'rails'
3
3
  require 'gmap_coordinates_picker'
4
4
 
5
5
  module GmapCoordinatesPicker
6
- #class Engine < ::Rails::Engine
7
- # config.before_initialize do
8
- # ActiveSupport.on_load :active_record do
9
- # ActiveRecord::Base.send(:include, SimpleCaptcha::ModelHelpers)
10
- # end
11
- # end
12
- #
13
- # config.after_initialize do
14
- # ActionView::Base.send(:include, SimpleCaptcha::ViewHelper)
15
- # ActionView::Helpers::FormBuilder.send(:include, SimpleCaptcha::FormBuilder)
16
- #
17
- # if Object.const_defined?("Formtastic")
18
- # if Formtastic.const_defined?("Helpers")
19
- # Formtastic::Helpers::FormHelper.builder = SimpleCaptcha::CustomFormBuilder
20
- # else
21
- # Formtastic::SemanticFormHelper.builder = SimpleCaptcha::CustomFormBuilder
22
- # end
23
- # end
24
- # end
25
- #
26
- # config.app_middleware.use SimpleCaptcha::Middleware
27
- #end
28
-
29
6
  class Engine < ::Rails::Engine
30
7
  config.after_initialize do
31
8
  ActionView::Base.send(:include, GmapCoordinatesPicker::ViewHelper)
32
9
  ActionView::Helpers::FormBuilder.send(:include, GmapCoordinatesPicker::FormBuilder)
10
+
11
+ if Object.const_defined?("Formtastic")
12
+ if Formtastic.const_defined?("Helpers")
13
+ Formtastic::Helpers::FormHelper.builder = GmapCoordinatesPicker::FormtasticMapBuilder
14
+ else
15
+ Formtastic::SemanticFormHelper.builder = GmapCoordinatesPicker::FormtasticMapBuilder
16
+ end
17
+ end
33
18
  end
34
19
  end
35
20
  end
@@ -0,0 +1,9 @@
1
+ module GmapCoordinatesPicker
2
+ class FormtasticMapBuilder < Formtastic::FormBuilder
3
+
4
+ def gmap_coordinate_picker(options = {})
5
+ options.update :object => @object_name
6
+ render_gmap_coordinate_picker(objectify_options(options))
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module GmapCoordinatesPicker
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -3,8 +3,13 @@ module GmapCoordinatesPicker #:nodoc
3
3
  def render_gmap_coordinate_picker(options={})
4
4
 
5
5
  unless options[:static].to_s == 'true'
6
- lat_column = options[:gmap_conf][:lat_column]
7
- lng_column = options[:gmap_conf][:lng_column]
6
+ options[:gmap_conf] ||= {}
7
+ if options[:gmap_conf].present?
8
+ ActiveSupport::Deprecation.warn "passing :gmap_conf => {:lat_column => 'latitude', :lng_column => 'longitude'} as options is deprecated and may be removed from future releases, use :lat_column, :lng_column directly in the option instead or see the document.", caller
9
+ end
10
+ lat_column = options[:lat_column] || options[:gmap_conf][:lat_column] || GmapCoordinatesPicker.config.lat_column
11
+ lng_column = options[:lng_column] || options[:gmap_conf][:lng_column] || GmapCoordinatesPicker.config.lng_column
12
+ default_coordinates = options[:default_coordinates] || GmapCoordinatesPicker.config.default_coordinates
8
13
  lat_column_value = options[:object].present? ? options[:object].send(lat_column) : default_coordinates[0]
9
14
  lng_column_value = options[:object].present? ? options[:object].send(lng_column) : default_coordinates[1]
10
15
  prefix = options[:object].present? ? options[:object].class.name.downcase : "gmap_coordinate_picker"
@@ -14,13 +19,13 @@ module GmapCoordinatesPicker #:nodoc
14
19
 
15
20
  default_locals = {
16
21
  :api_key => options[:api_key],
17
- :map_handler => options[:map_handler] || 'gMapObj',
18
- :zoom_level => options[:zoom_level] || 10,
22
+ :map_handler => options[:map_handler] || GmapCoordinatesPicker.config.map_handler,
23
+ :zoom_level => options[:zoom_level] || GmapCoordinatesPicker.config.zoom_level,
19
24
  :map_container => "gmap_coordinate_picker_container_#{Time.now.to_i}",
20
- :map_container_class => options[:map_container_class],
21
- :map_width => options[:map_width] || "600px",
22
- :map_height => options[:map_height] ||"400px",
23
- :default_coordinates => options[:default_coordinates] || [0, 0],
25
+ :map_container_class => options[:map_container_class] || GmapCoordinatesPicker.config.map_container_class,
26
+ :map_width => options[:map_width] || GmapCoordinatesPicker.config.map_width,
27
+ :map_height => options[:map_height] || GmapCoordinatesPicker.config.map_height,
28
+ :default_coordinates => options[:default_coordinates] || GmapCoordinatesPicker.config.default_coordinates,
24
29
  }
25
30
 
26
31
  editable_map_locals = {
@@ -35,10 +40,12 @@ module GmapCoordinatesPicker #:nodoc
35
40
  :lat_field => lat_lng_field(lat_column, lat_column_value, lat_dom_id, options),
36
41
  :lng_field => lat_lng_field(lng_column, lng_column_value, lng_dom_id, options)
37
42
  }
43
+
38
44
  unless options[:static].to_s == 'true'
39
- render :partial => 'gmap_coordinate_picker/gmap_coordinate_picker', :locals => default_locals.merge(editable_map_locals)
45
+ @template ||= self
46
+ @template.render :partial => '/gmap_coordinate_picker/gmap_coordinate_picker', :locals => default_locals.merge(editable_map_locals)
40
47
  else
41
- render :partial => 'gmap_coordinate_picker/render_map', :locals => default_locals
48
+ render :partial => '/gmap_coordinate_picker/render_map', :locals => default_locals
42
49
  end
43
50
  end
44
51
 
@@ -53,4 +60,4 @@ module GmapCoordinatesPicker #:nodoc
53
60
 
54
61
 
55
62
  end
56
- end
63
+ end
@@ -1,8 +1,8 @@
1
+ require 'gmap_coordinates_picker/config'
2
+ require 'gmap_coordinates_picker/engine' if defined?(Rails)
3
+
1
4
  module GmapCoordinatesPicker
2
5
  autoload :ViewHelper, 'gmap_coordinates_picker/view_helper'
3
6
  autoload :FormBuilder, 'gmap_coordinates_picker/form_builder'
4
-
5
-
6
- end
7
-
8
- require 'gmap_coordinates_picker/engine' if defined?(Rails)
7
+ autoload :FormtasticMapBuilder, 'gmap_coordinates_picker/formtastic'
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmap_coordinates_picker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
12
+ date: 2013-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.1.0
22
22
  type: :runtime
@@ -24,9 +24,57 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ - !ruby/object:Gem::Dependency
63
+ name: mocha
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
30
78
  description: It works without any dependency to any third party library
31
79
  email:
32
80
  - ahmed2tul@gmail.com
@@ -36,8 +84,12 @@ extra_rdoc_files: []
36
84
  files:
37
85
  - app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb
38
86
  - app/views/gmap_coordinate_picker/_render_map.html.erb
87
+ - lib/generators/gmap_coordinates_picker/config_generator.rb
88
+ - lib/generators/gmap_coordinates_picker/templates/gmap_coordinates_picker_config.rb
89
+ - lib/gmap_coordinates_picker/config.rb
39
90
  - lib/gmap_coordinates_picker/engine.rb
40
91
  - lib/gmap_coordinates_picker/form_builder.rb
92
+ - lib/gmap_coordinates_picker/formtastic.rb
41
93
  - lib/gmap_coordinates_picker/version.rb
42
94
  - lib/gmap_coordinates_picker/view_helper.rb
43
95
  - lib/gmap_coordinates_picker.rb