autocomplete_zipcode 0.1.2 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +10 -0
  3. data/.github/pull_request_template.md +19 -0
  4. data/.gitignore +5 -1
  5. data/.rspec +1 -2
  6. data/.rubocop.yml +7 -0
  7. data/.ruby-gemset +1 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +13 -1
  10. data/Gemfile +2 -0
  11. data/Gemfile.lock +209 -0
  12. data/Makefile +2 -0
  13. data/README.md +58 -10
  14. data/Rakefile +7 -1
  15. data/app/inputs/autocomplete_zipcode/city_input.rb +11 -0
  16. data/app/inputs/autocomplete_zipcode/ibge_input.rb +11 -0
  17. data/app/inputs/autocomplete_zipcode/neighborhood_input.rb +11 -0
  18. data/app/inputs/autocomplete_zipcode/state_input.rb +11 -0
  19. data/app/inputs/autocomplete_zipcode/state_select_input.rb +11 -0
  20. data/app/inputs/autocomplete_zipcode/street_input.rb +11 -0
  21. data/app/inputs/autocomplete_zipcode/zipcode_input.rb +11 -0
  22. data/autocomplete_zipcode.gemspec +25 -13
  23. data/bin/console +7 -7
  24. data/bin/rails +19 -0
  25. data/config/initializers/simple_form_autocomplete_zipcode.rb +9 -0
  26. data/lib/autocomplete_zipcode.rb +4 -5
  27. data/lib/autocomplete_zipcode/version.rb +3 -1
  28. data/vendor/assets/javascripts/autocomplete_zipcode.js +43 -28
  29. metadata +125 -114
  30. data/example/.gitignore +0 -21
  31. data/example/Gemfile +0 -55
  32. data/example/Gemfile.lock +0 -184
  33. data/example/README.md +0 -24
  34. data/example/Rakefile +0 -6
  35. data/example/app/assets/config/manifest.js +0 -3
  36. data/example/app/assets/images/.keep +0 -0
  37. data/example/app/assets/javascripts/addresses.coffee +0 -3
  38. data/example/app/assets/javascripts/application.js +0 -26
  39. data/example/app/assets/javascripts/cable.js +0 -13
  40. data/example/app/assets/javascripts/channels/.keep +0 -0
  41. data/example/app/assets/stylesheets/addresses.scss +0 -3
  42. data/example/app/assets/stylesheets/application.css +0 -15
  43. data/example/app/assets/stylesheets/scaffolds.scss +0 -89
  44. data/example/app/channels/application_cable/channel.rb +0 -4
  45. data/example/app/channels/application_cable/connection.rb +0 -4
  46. data/example/app/controllers/addresses_controller.rb +0 -74
  47. data/example/app/controllers/application_controller.rb +0 -3
  48. data/example/app/controllers/concerns/.keep +0 -0
  49. data/example/app/helpers/addresses_helper.rb +0 -2
  50. data/example/app/helpers/application_helper.rb +0 -2
  51. data/example/app/jobs/application_job.rb +0 -2
  52. data/example/app/mailers/application_mailer.rb +0 -4
  53. data/example/app/models/address.rb +0 -2
  54. data/example/app/models/application_record.rb +0 -3
  55. data/example/app/models/concerns/.keep +0 -0
  56. data/example/app/views/addresses/_address.json.jbuilder +0 -2
  57. data/example/app/views/addresses/_form.html.erb +0 -18
  58. data/example/app/views/addresses/edit.html.erb +0 -6
  59. data/example/app/views/addresses/index.html.erb +0 -33
  60. data/example/app/views/addresses/index.json.jbuilder +0 -1
  61. data/example/app/views/addresses/new.html.erb +0 -5
  62. data/example/app/views/addresses/show.html.erb +0 -24
  63. data/example/app/views/addresses/show.json.jbuilder +0 -1
  64. data/example/app/views/layouts/application.html.erb +0 -14
  65. data/example/app/views/layouts/mailer.html.erb +0 -13
  66. data/example/app/views/layouts/mailer.text.erb +0 -1
  67. data/example/bin/bundle +0 -3
  68. data/example/bin/rails +0 -9
  69. data/example/bin/rake +0 -9
  70. data/example/bin/setup +0 -34
  71. data/example/bin/spring +0 -17
  72. data/example/bin/update +0 -29
  73. data/example/config.ru +0 -5
  74. data/example/config/application.rb +0 -15
  75. data/example/config/boot.rb +0 -3
  76. data/example/config/cable.yml +0 -9
  77. data/example/config/database.yml +0 -25
  78. data/example/config/environment.rb +0 -5
  79. data/example/config/environments/development.rb +0 -54
  80. data/example/config/environments/production.rb +0 -86
  81. data/example/config/environments/test.rb +0 -42
  82. data/example/config/initializers/application_controller_renderer.rb +0 -6
  83. data/example/config/initializers/assets.rb +0 -11
  84. data/example/config/initializers/backtrace_silencers.rb +0 -7
  85. data/example/config/initializers/cookies_serializer.rb +0 -5
  86. data/example/config/initializers/filter_parameter_logging.rb +0 -4
  87. data/example/config/initializers/inflections.rb +0 -16
  88. data/example/config/initializers/mime_types.rb +0 -4
  89. data/example/config/initializers/new_framework_defaults.rb +0 -24
  90. data/example/config/initializers/session_store.rb +0 -3
  91. data/example/config/initializers/simple_form.rb +0 -169
  92. data/example/config/initializers/wrap_parameters.rb +0 -14
  93. data/example/config/locales/en.yml +0 -23
  94. data/example/config/locales/simple_form.en.yml +0 -31
  95. data/example/config/puma.rb +0 -47
  96. data/example/config/routes.rb +0 -4
  97. data/example/config/secrets.yml +0 -22
  98. data/example/config/spring.rb +0 -6
  99. data/example/db/migrate/20170425234824_create_addresses.rb +0 -13
  100. data/example/db/schema.rb +0 -25
  101. data/example/db/seeds.rb +0 -7
  102. data/example/lib/assets/.keep +0 -0
  103. data/example/lib/tasks/.keep +0 -0
  104. data/example/lib/templates/erb/scaffold/_form.html.erb +0 -13
  105. data/example/log/.keep +0 -0
  106. data/example/public/404.html +0 -67
  107. data/example/public/422.html +0 -67
  108. data/example/public/500.html +0 -66
  109. data/example/public/apple-touch-icon-precomposed.png +0 -0
  110. data/example/public/apple-touch-icon.png +0 -0
  111. data/example/public/favicon.ico +0 -0
  112. data/example/public/robots.txt +0 -5
  113. data/example/test/controllers/.keep +0 -0
  114. data/example/test/controllers/addresses_controller_test.rb +0 -48
  115. data/example/test/fixtures/.keep +0 -0
  116. data/example/test/fixtures/addresses.yml +0 -13
  117. data/example/test/fixtures/files/.keep +0 -0
  118. data/example/test/helpers/.keep +0 -0
  119. data/example/test/integration/.keep +0 -0
  120. data/example/test/mailers/.keep +0 -0
  121. data/example/test/models/.keep +0 -0
  122. data/example/test/models/address_test.rb +0 -7
  123. data/example/test/test_helper.rb +0 -10
  124. data/example/tmp/.keep +0 -0
  125. data/example/vendor/assets/javascripts/.keep +0 -0
  126. data/example/vendor/assets/stylesheets/.keep +0 -0
  127. data/lib/autocomplete_zipcode/simple_form/city_input.rb +0 -7
  128. data/lib/autocomplete_zipcode/simple_form/neighborhood_input.rb +0 -7
  129. data/lib/autocomplete_zipcode/simple_form/state_input.rb +0 -7
  130. data/lib/autocomplete_zipcode/simple_form/street_input.rb +0 -7
  131. data/lib/autocomplete_zipcode/simple_form/zipcode_input.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 80a0dae6b23729364949a833b8072dbfaa75a587
4
- data.tar.gz: 955c6d77c5efb151d998e2ec17f2b73f88d2bd29
2
+ SHA256:
3
+ metadata.gz: 0bfef5ece6adb70826e8aaf5cb4de07334fef2895b25c1f1e26f24da8cb900bd
4
+ data.tar.gz: 1a8d54f3e9243df143b578d160a397e1495cc6ed031a532d7fcc94252d2aa060
5
5
  SHA512:
6
- metadata.gz: c690142e7826bfdd683ff77833801ea46c6bfcab0360373bae7991809845f2039e5bb125173d20d03cecf98d417f1a696f8d8f523923c320b2f6034c1b1479b4
7
- data.tar.gz: 74b0616c607da31c3dc02f5c47b56808161de998ddf4314a6c1792556c339bd6b95f49f6744f52b690bfce14fa05523830e8b2345e89608f51955d86a39a28ba
6
+ metadata.gz: 7b21f6f15b7a15d200996f65be233065e6da0b5905fddf253026dfc2d356c0896137409dc0af6598f346905fe86f578d12af2553ffae4b073bd4ffe0f94995ee
7
+ data.tar.gz: f08065a0337b9befbe5bc24015faeff49c80a12f82e47535884ba7dddb8ed45b76c895412facade5c17f94be9b8166f130c664b7eb820a6ead9c7d0cca09f3ff
data/.codeclimate.yml ADDED
@@ -0,0 +1,10 @@
1
+ version: "2"
2
+ plugins:
3
+ rubocop:
4
+ enabled: true
5
+ channel: rubocop-0-60
6
+ config:
7
+ file: ".rubocop.yml"
8
+ exclude_patterns:
9
+ - "spec/"
10
+ - "spec/**/*"
@@ -0,0 +1,19 @@
1
+ # Overview
2
+
3
+ ## Implementation Details
4
+
5
+ ## Required Documentation Updates
6
+
7
+ None.
8
+
9
+ ## Testing Notes
10
+
11
+ None.
12
+
13
+ ## API Changes
14
+
15
+ None.
16
+
17
+ ## External Dependency Changes
18
+
19
+ None.
data/.gitignore CHANGED
@@ -1,9 +1,13 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+
10
+ spec/dummy/log/*.log
11
+ spec/dummy/tmp
12
+ spec/dummy/test
13
+ spec/dummy/db/*.sqlite3
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
- --color
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ SuggestExtensions: false
3
+ Exclude:
4
+ - 'spec/**/*.rb'
5
+ - 'spec/dummy/**/*'
6
+ Style/Documentation:
7
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ autocomplete_zipcode
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.travis.yml CHANGED
@@ -1,3 +1,15 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=$CODE_CLIMATE_TOKEN
1
4
  language: ruby
2
5
  rvm:
3
- - 2.2.1
6
+ - 2.6.3
7
+ before_script:
8
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
9
+ - chmod +x ./cc-test-reporter
10
+ - ./cc-test-reporter before-build
11
+ - gem install bundler:2.1.4
12
+ script:
13
+ - bundle exec rspec
14
+ after_script:
15
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  # Specify your gem's dependencies in autocomplete_zipcode.gemspec
3
5
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,209 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ autocomplete_zipcode (2.1.1)
5
+ rails (>= 3.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.3.1)
11
+ actionpack (= 6.1.3.1)
12
+ activesupport (= 6.1.3.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.3.1)
16
+ actionpack (= 6.1.3.1)
17
+ activejob (= 6.1.3.1)
18
+ activerecord (= 6.1.3.1)
19
+ activestorage (= 6.1.3.1)
20
+ activesupport (= 6.1.3.1)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.3.1)
23
+ actionpack (= 6.1.3.1)
24
+ actionview (= 6.1.3.1)
25
+ activejob (= 6.1.3.1)
26
+ activesupport (= 6.1.3.1)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.3.1)
30
+ actionview (= 6.1.3.1)
31
+ activesupport (= 6.1.3.1)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.3.1)
37
+ actionpack (= 6.1.3.1)
38
+ activerecord (= 6.1.3.1)
39
+ activestorage (= 6.1.3.1)
40
+ activesupport (= 6.1.3.1)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.3.1)
43
+ activesupport (= 6.1.3.1)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.3.1)
49
+ activesupport (= 6.1.3.1)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.3.1)
52
+ activesupport (= 6.1.3.1)
53
+ activerecord (6.1.3.1)
54
+ activemodel (= 6.1.3.1)
55
+ activesupport (= 6.1.3.1)
56
+ activestorage (6.1.3.1)
57
+ actionpack (= 6.1.3.1)
58
+ activejob (= 6.1.3.1)
59
+ activerecord (= 6.1.3.1)
60
+ activesupport (= 6.1.3.1)
61
+ marcel (~> 1.0.0)
62
+ mini_mime (~> 1.0.2)
63
+ activesupport (6.1.3.1)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ ast (2.4.2)
70
+ builder (3.2.4)
71
+ coderay (1.1.3)
72
+ concurrent-ruby (1.1.8)
73
+ crass (1.0.6)
74
+ diff-lcs (1.4.4)
75
+ docile (1.3.5)
76
+ erubi (1.10.0)
77
+ globalid (0.4.2)
78
+ activesupport (>= 4.2.0)
79
+ i18n (1.8.10)
80
+ concurrent-ruby (~> 1.0)
81
+ jquery-rails (4.4.0)
82
+ rails-dom-testing (>= 1, < 3)
83
+ railties (>= 4.2.0)
84
+ thor (>= 0.14, < 2.0)
85
+ loofah (2.9.0)
86
+ crass (~> 1.0.2)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.7.1)
89
+ mini_mime (>= 0.1.1)
90
+ marcel (1.0.1)
91
+ method_source (1.0.0)
92
+ mini_mime (1.0.3)
93
+ mini_portile2 (2.5.0)
94
+ minitest (5.14.4)
95
+ nio4r (2.5.7)
96
+ nokogiri (1.11.2)
97
+ mini_portile2 (~> 2.5.0)
98
+ racc (~> 1.4)
99
+ parallel (1.20.1)
100
+ parser (3.0.0.0)
101
+ ast (~> 2.4.1)
102
+ pry (0.14.0)
103
+ coderay (~> 1.1)
104
+ method_source (~> 1.0)
105
+ racc (1.5.2)
106
+ rack (2.2.3)
107
+ rack-test (1.1.0)
108
+ rack (>= 1.0, < 3)
109
+ rails (6.1.3.1)
110
+ actioncable (= 6.1.3.1)
111
+ actionmailbox (= 6.1.3.1)
112
+ actionmailer (= 6.1.3.1)
113
+ actionpack (= 6.1.3.1)
114
+ actiontext (= 6.1.3.1)
115
+ actionview (= 6.1.3.1)
116
+ activejob (= 6.1.3.1)
117
+ activemodel (= 6.1.3.1)
118
+ activerecord (= 6.1.3.1)
119
+ activestorage (= 6.1.3.1)
120
+ activesupport (= 6.1.3.1)
121
+ bundler (>= 1.15.0)
122
+ railties (= 6.1.3.1)
123
+ sprockets-rails (>= 2.0.0)
124
+ rails-dom-testing (2.0.3)
125
+ activesupport (>= 4.2.0)
126
+ nokogiri (>= 1.6)
127
+ rails-html-sanitizer (1.3.0)
128
+ loofah (~> 2.3)
129
+ railties (6.1.3.1)
130
+ actionpack (= 6.1.3.1)
131
+ activesupport (= 6.1.3.1)
132
+ method_source
133
+ rake (>= 0.8.7)
134
+ thor (~> 1.0)
135
+ rainbow (3.0.0)
136
+ rake (13.0.3)
137
+ regexp_parser (2.1.1)
138
+ rexml (3.2.4)
139
+ rspec-core (3.10.1)
140
+ rspec-support (~> 3.10.0)
141
+ rspec-expectations (3.10.1)
142
+ diff-lcs (>= 1.2.0, < 2.0)
143
+ rspec-support (~> 3.10.0)
144
+ rspec-mocks (3.10.2)
145
+ diff-lcs (>= 1.2.0, < 2.0)
146
+ rspec-support (~> 3.10.0)
147
+ rspec-rails (5.0.1)
148
+ actionpack (>= 5.2)
149
+ activesupport (>= 5.2)
150
+ railties (>= 5.2)
151
+ rspec-core (~> 3.10)
152
+ rspec-expectations (~> 3.10)
153
+ rspec-mocks (~> 3.10)
154
+ rspec-support (~> 3.10)
155
+ rspec-support (3.10.2)
156
+ rubocop (1.12.0)
157
+ parallel (~> 1.10)
158
+ parser (>= 3.0.0.0)
159
+ rainbow (>= 2.2.2, < 4.0)
160
+ regexp_parser (>= 1.8, < 3.0)
161
+ rexml
162
+ rubocop-ast (>= 1.2.0, < 2.0)
163
+ ruby-progressbar (~> 1.7)
164
+ unicode-display_width (>= 1.4.0, < 3.0)
165
+ rubocop-ast (1.4.1)
166
+ parser (>= 2.7.1.5)
167
+ ruby-progressbar (1.11.0)
168
+ simple_form (5.1.0)
169
+ actionpack (>= 5.2)
170
+ activemodel (>= 5.2)
171
+ simplecov (0.20.0)
172
+ docile (~> 1.1)
173
+ simplecov-html (~> 0.11)
174
+ simplecov_json_formatter (~> 0.1)
175
+ simplecov-html (0.12.3)
176
+ simplecov_json_formatter (0.1.2)
177
+ sprockets (4.0.2)
178
+ concurrent-ruby (~> 1.0)
179
+ rack (> 1, < 3)
180
+ sprockets-rails (3.2.2)
181
+ actionpack (>= 4.0)
182
+ activesupport (>= 4.0)
183
+ sprockets (>= 3.0.0)
184
+ sqlite3 (1.4.2)
185
+ thor (1.1.0)
186
+ tzinfo (2.0.4)
187
+ concurrent-ruby (~> 1.0)
188
+ unicode-display_width (2.0.0)
189
+ websocket-driver (0.7.3)
190
+ websocket-extensions (>= 0.1.0)
191
+ websocket-extensions (0.1.5)
192
+ zeitwerk (2.4.2)
193
+
194
+ PLATFORMS
195
+ ruby
196
+
197
+ DEPENDENCIES
198
+ autocomplete_zipcode!
199
+ jquery-rails (~> 4.4.0)
200
+ pry (~> 0.14.0)
201
+ rake (~> 13.0.3)
202
+ rspec-rails (~> 5.0.0)
203
+ rubocop (~> 1.12.0)
204
+ simple_form (>= 5.1.0)
205
+ simplecov (~> 0.20.0)
206
+ sqlite3 (~> 1.4.2)
207
+
208
+ BUNDLED WITH
209
+ 2.1.4
data/Makefile ADDED
@@ -0,0 +1,2 @@
1
+ default:
2
+ ./bin/console
data/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  This gem was built to "automagically" fills an address form, for Rails version >= 3.1.
4
4
 
5
+ ## Status
6
+
7
+ [![Build Status](https://api.travis-ci.com/marcelobarreto/autocomplete_zipcode.svg?branch=master)](https://travis-ci.com/marcelobarreto/autocomplete_zipcode)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/37008f3eeaaf2ea47122/maintainability)](https://codeclimate.com/github/marcelobarreto/autocomplete_zipcode/maintainability)
9
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/37008f3eeaaf2ea47122/test_coverage)](https://codeclimate.com/github/marcelobarreto/autocomplete_zipcode/test_coverage)
10
+ [![RubyGems](http://img.shields.io/gem/dt/autocomplete_zipcode.svg?style=flat)](http://rubygems.org/gems/autocomplete_zipcode)
11
+
12
+ ## Try it
13
+
14
+ [Online](http://autocompletezipcode.herokuapp.com)
5
15
 
6
16
  ## Installation
7
17
 
@@ -14,23 +24,29 @@ gem 'autocomplete_zipcode'
14
24
  And then execute:
15
25
 
16
26
  ```bash
17
- $ bundle install
27
+ bundle install
18
28
  ```
19
29
 
20
- ## Usage
30
+ ## Simple Usage
21
31
 
22
32
  In app/assets/javascripts/application.js, you should add as follows:
23
33
 
24
34
  ```js
35
+ // app/assets/javascripts/application.js
25
36
  //= require ...
37
+ //= require turbolinks
38
+ //= require jquery
26
39
  //= require autocomplete_zipcode
27
- //= require ...
40
+
41
+ $(document).on('ready', () => {
42
+ AutocompleteZipcode.mount();
43
+ });
28
44
  ```
29
45
 
30
- Basic Example:
46
+ ## Basic Example
31
47
 
32
48
  ```erb
33
- <%= simple_form_for :example do | f | %>
49
+ <%= simple_form_for :example do |f| %>
34
50
  ...
35
51
  <%= f.input :zipcode, as: :zipcode %>
36
52
  <%= f.input :street, as: :street %>
@@ -44,10 +60,10 @@ Basic Example:
44
60
  If you are not using simple_form, then simply add the `data-provider="zipcode"` and the other fields name to the input field yourself.
45
61
 
46
62
  ```erb
47
- <%= form_for :example do | f | %>
63
+ <%= form_for :example do |f| %>
48
64
  ...
49
- <%= f.text_field :zipcode, data: {provider: :zipcode} %>
50
- <%= f.text_field :street, data: {provider: :street} %>
65
+ <%= f.text_field :zipcode, data: { autocomplete_zipcode_provider: :zipcode } %>
66
+ <%= f.text_field :street, data: { autocomplete_zipcode_provider: :street } %>
51
67
  ...
52
68
  <% end %>
53
69
  ```
@@ -57,14 +73,46 @@ If you are not using simple_form, then simply add the `data-provider="zipcode"`
57
73
  Simply add an event listener callback to `zipcode.error`, for example:
58
74
 
59
75
  ```js
60
- document.addEventListener('zipcode.error', function(e) {
76
+ // app/assets/javascripts/application.js
77
+
78
+ document.addEventListener('zipcode.error', () => {
61
79
  alert('Invalid zipcode!!!')
62
80
  });
63
81
  ```
64
82
 
83
+ ## Advanced Usage
84
+
85
+ ```js
86
+ // app/assets/javascripts/application.js
87
+ //= require ...
88
+ //= require turbolinks
89
+ //= require jquery
90
+ //= require autocomplete_zipcode
91
+
92
+ $(document).on('ready', () => {
93
+ AutocompleteZipcode.mount({
94
+ onSuccess: (containerEl, zipcodeEl) => {
95
+ console.log(containerEl, zipcodeEl);
96
+ },
97
+ onFail: (containerEl, zipcodeEl) => {
98
+ console.log(containerEl, zipcodeEl);
99
+ },
100
+ });
101
+
102
+ document.addEventListener('zipcode.success', () => {
103
+ console.log('zipcode fetched successfully');
104
+ });
105
+
106
+ document.addEventListener('zipcode.error', () => {
107
+ console.log('zipcode fetch failed');
108
+ });
109
+ });
110
+ ```
111
+
65
112
  ## Sample projects
66
113
 
67
- For an example, take a look at the `example` folder in this repository.
114
+ For an online example, take a look at [this repository](https://github.com/marcelobarreto/autocomplete_zipcode_example).
115
+ You can also see it working on the dummy application (`spec/dummy`)
68
116
 
69
117
  ## Contributing
70
118
 
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec