google_maps_by_pete 0.1.41 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcd645230320b52698c79c907d0b52d53007cb600354036d11ad3e48f881fd8a
4
- data.tar.gz: be0d20eea4a05b0b5bf035cac38638d7fdff110829dbf6be553dfce2f8551b14
3
+ metadata.gz: 494e0d522b467a5257086be196c726a5832de561c4d9c5b43f6c20fcb51f0135
4
+ data.tar.gz: 94a108f0fa5893f4c2c9b22287023f9f82017be0778cad6c49eb950e957258f5
5
5
  SHA512:
6
- metadata.gz: 7338d90ef05eb5a91ab0e4b93a1b83aeaa064bc46ca2691a6cd0b3119f0ebec1495dc2d0fe6551d0f349f34e3ce535643cb45a008eb62a8a7c6a1172c6057fd1
7
- data.tar.gz: e7785b72a2cb0acc7abeb292a7d5c5a91005624af6d4d1fa221b6c5c0456ac8ea8f14cbaaaa51dc0f09ad03f48c21fb14cb11ab97caaad0a89178f869818d33e
6
+ metadata.gz: ca9238b3c0bd0b8fc99ef3ab697471f7a2d98cca8de199e411fed20373b3ef5380fb6479afbbb6c6c6bb950382203703058e39ee55db89b5d8e4c4b34c94bb2b
7
+ data.tar.gz: bf05a8f6f2739802b749e27dd803d3303a4fc626fafaf86d02312d196122af340bf3d60a11a7bb74d7d0cedfb6e73ce791c5b6ef03b15249ac691f32127aa3e1
data/.DS_Store ADDED
Binary file
data/README.md CHANGED
@@ -1,38 +1,53 @@
1
- # GoogleMapsByPete
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/google_maps_by_pete`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
1
+ # Google Maps By Pete
6
2
 
3
+ An agile way to implement Google Maps localization on a scaffold in Ruby On Rails
7
4
  ## Installation
8
5
 
9
6
  Add this line to your application's Gemfile:
10
7
 
11
8
  ```ruby
12
9
  gem 'google_maps_by_pete'
10
+
13
11
  ```
14
12
 
15
- And then execute:
13
+ Go to your application's directory in Terminal and run the command:
14
+ ```ruby
15
+ bundle install
16
+ ```
16
17
 
17
- $ bundle install
18
18
 
19
- Or install it yourself as:
19
+ ## Usage
20
+ Let's create a example for a Place scaffold:
20
21
 
21
- $ gem install google_maps_by_pete
22
+ 1. Go to your application's directory in Terminal and run the command:
22
23
 
23
- ## Usage
24
+ ```ruby
25
+ rails g scaffold Place name:string description:text
26
+ ```
27
+ 2. Go to your application's directory in Terminal and run the command:
28
+ ```ruby
29
+ bundle exec rake 'install_google_maps_by_pete[Place]'
30
+ ```
31
+ 3. Add jQuery to your layout file:
32
+ ```html
33
+ <script src='/google_maps_by_pete/jquery-3.6.0.min.js'></script>
34
+ ```
35
+ 4. Add maps.css to your layout file:
36
+ ```html
37
+ <link rel='stylesheet' href='/google_maps_by_pete/maps.css'>
38
+ ```
39
+ 5. Add this to your _form.html.erb file:
40
+ ```ruby
41
+ <%= render 'shared/google_maps_by_pete', api_key: 'your_google_api_key', height: '500px', center_map_on: {lat: 25.761681, lng: -80.191788}, model: place%>
42
+ ```
43
+
44
+ ## Video Tutorial
24
45
 
25
- 1. rails g scaffold Place name:string description:text
26
- 2. gem "google_maps_by_pete", path: "/Users/pedroconsuegra/Sites/ruby/google_maps_by_pete"
27
- 3. bundle exec rake 'install_google_maps_by_pete[place]
28
- 4. <%= render 'shared/google_maps_by_pete', api_key: 'your_google_api_key', height: '500px', center_map_on: {lat: 25.761681, lng: -80.191788}, model: @model%>
29
- 5. Go to places edit
46
+ Watch this video to see how it works
30
47
 
31
- ## Development
48
+ [![IMAGE ALT TEXT HERE](https://raw.githubusercontent.com/peterconsuegra/google_maps_by_pete/master/templates/MapsByPete.png)](https://www.youtube.com/watch?v=YCp1Yv2A4Dc)
32
49
 
33
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
50
 
35
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
51
 
37
52
  ## Contributing
38
53
 
Binary file
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/peterconsuegra/google_maps_by_pete"
20
20
  spec.metadata["changelog_uri"] = "https://github.com/peterconsuegra/google_maps_by_pete/blob/master/CHANGELOG.md"
21
+ spec.license = 'MIT'
21
22
 
22
23
  # Specify which files should be added to the gem when it is released.
23
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -34,6 +35,6 @@ Gem::Specification.new do |spec|
34
35
  # For more information and examples about making a new gem, checkout our
35
36
  # guide at: https://bundler.io/guides/creating_gem.html
36
37
  spec.add_dependency("colorize","~> 0.8.0")
37
- spec.add_dependency("tty-file")
38
+ spec.add_dependency("tty-file","~> 0.10.0")
38
39
 
39
40
  end
data/lib/.DS_Store ADDED
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoogleMapsByPete
4
- VERSION = "0.1.41"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -29,23 +29,16 @@ module PeterConsuegraRecipes
29
29
  end
30
30
  end
31
31
 
32
- def self.append_after_first_appearance_of(string,code,file)
33
- File.open(file, 'r+') do |file|
34
- lines = file.each_line.to_a
35
- length = lines.length()
36
-
37
- lines.each_with_index do |val, index|
38
- if val.include?(string)
39
- puts "entro "
40
- aux = lines[length-(index+1)]
41
- lines[length-(index+1)] = "#{code} \n"
42
- lines.append(aux)
43
- file.rewind
44
- file.write(lines.join)
45
- break
46
- end
47
- end
48
- end
32
+ def self.get_scaffold_vars(model)
33
+ hash = Hash.new
34
+ hash["model"] = model
35
+ hash["model_class"] = model.titleize.gsub(' ','')
36
+ hash["table_name"] = eval(hash["model_class"]).table_name
37
+ hash["controller_file"] = hash["table_name"]+"_controller.rb"
38
+ hash["controller_class"] = hash["table_name"].titleize.gsub(' ','')+"Controller"
39
+ hash["base_route"] = hash["table_name"]
40
+ puts hash
41
+ return hash
49
42
  end
50
43
 
51
44
  end
@@ -7,19 +7,15 @@ require "tty-file"
7
7
  desc 'install_google_maps_by_pete required files'
8
8
  task :install_google_maps_by_pete, [:model] do |t, args|
9
9
 
10
+ #require all models
11
+ Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file }
12
+
10
13
  #route files
11
14
  rails_app_folder = Dir.pwd
12
15
  gem_folder = File.expand_path('../../../.', __FILE__)
13
-
14
- #model vars
15
- model_name = args[:model].capitalize
16
- model_plural = model_name+"s"
17
- model_plural = model_plural.capitalize
18
- model_plural_downcase = model_plural.downcase
19
-
20
- # puts "model: #{model_name}"
21
- # puts "model_plural: #{model_plural}"
22
- # puts "model_plural_downcase: #{model_plural_downcase}"
16
+
17
+ #Get scaffold vars
18
+ hash = PeterConsuegraRecipes::get_scaffold_vars(args[:model])
23
19
 
24
20
  #Templates folder
25
21
  src_folder="#{gem_folder}/templates/"
@@ -54,18 +50,18 @@ task :install_google_maps_by_pete, [:model] do |t, args|
54
50
 
55
51
  #Adding route to routes.rb
56
52
  file="#{rails_app_folder}/config/routes.rb"
57
- code = "post '/#{model_plural_downcase}/set_location', to: '#{model_plural_downcase}#set_location'"
53
+ code = "post '/#{hash['base_route']}/set_location', to: '#{hash['base_route']}#set_location'"
58
54
  PeterConsuegraRecipes::append_before_last_appearance_of("end",code,file)
59
55
  puts "Adding route: #{code}".blue
60
56
 
61
57
  #Adding include GoogleMapsByPete in Controller
62
- file="#{rails_app_folder}/app/controllers/#{model_plural_downcase}_controller.rb"
58
+ file="#{rails_app_folder}/app/controllers/#{hash['controller_file']}"
63
59
  code="include MapsByPete\n"
64
- TTY::File.inject_into_file file, code, after: "class #{model_plural}Controller < ApplicationController\n"
60
+ TTY::File.inject_into_file file, code, after: "class #{hash['controller_class']} < ApplicationController\n"
65
61
  puts "Adding concern to controller #{file}: include MapsByPete".blue
66
62
 
67
63
  #Add required migration
68
- `rails generate migration AddFieldsTo#{model_name} lat:decimal{10-6} lng:decimal{10-6}`
64
+ `rails generate migration AddFieldsTo#{hash['model_class']} lat:decimal{10-6} lng:decimal{10-6}`
69
65
  sleep 2
70
66
  `rake db:migrate`
71
67
 
@@ -78,8 +74,9 @@ task :install_google_maps_by_pete, [:model] do |t, args|
78
74
  puts "Add maps.css to your layout file:".red
79
75
  puts "<link rel='stylesheet' href='/google_maps_by_pete/maps.css'>".red
80
76
  puts "Add this to your _form.html.erb file:".red
81
- puts "<%= render 'shared/google_maps_by_pete', api_key: 'your_google_api_key', height: '500px', center_map_on: {lat: 25.761681, lng: -80.191788}, model: #{model_name.downcase}%>".red
82
-
77
+ puts "<%= render 'shared/google_maps_by_pete', api_key: 'your_google_api_key', height: '500px', center_map_on: {lat: 25.761681, lng: -80.191788}, model: #{hash['model'].downcase}%>".red
78
+ puts "Allow lat and lng params in your controller #{hash['controller_file']}:".red
79
+ puts "params.require(:#{hash['model'].downcase}).permit(:lat, :lng)".red
83
80
 
84
81
 
85
82
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_by_pete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.41
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Consuegra
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: tty-file
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.10.0
41
41
  description: An agile way to implement Google Maps. in a model
42
42
  email:
43
43
  - pedroconsuegrat@gmail.com
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".DS_Store"
48
49
  - ".gitignore"
49
50
  - ".rubocop.yml"
50
51
  - CHANGELOG.md
@@ -54,18 +55,22 @@ files:
54
55
  - Rakefile
55
56
  - bin/console
56
57
  - bin/setup
58
+ - google_maps_by_pete-0.1.41.gem
57
59
  - google_maps_by_pete.gemspec
60
+ - lib/.DS_Store
58
61
  - lib/google_maps_by_pete.rb
59
62
  - lib/google_maps_by_pete/version.rb
60
63
  - lib/peterconsuegra_recipes.rb
61
64
  - lib/railtie.rb
62
65
  - lib/tasks/install_google_maps_by_pete.rake
66
+ - templates/MapsByPete.png
63
67
  - templates/_google_maps_by_pete.html.erb
64
68
  - templates/jquery-3.6.0.min.js
65
69
  - templates/maps.css
66
70
  - templates/maps_by_pete.rb
67
71
  homepage: https://rubygems.org/gems/google_maps_by_pete
68
- licenses: []
72
+ licenses:
73
+ - MIT
69
74
  metadata:
70
75
  allowed_push_host: https://rubygems.org/
71
76
  homepage_uri: https://rubygems.org/gems/google_maps_by_pete