autocomplete_zipcode 0.1.1 → 2.0.0

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 +123 -0
  14. data/Rakefile +7 -1
  15. data/app/inputs/autocomplete_zipcode/city_input.rb +9 -0
  16. data/app/inputs/autocomplete_zipcode/ibge_input.rb +9 -0
  17. data/app/inputs/autocomplete_zipcode/neighborhood_input.rb +9 -0
  18. data/app/inputs/autocomplete_zipcode/state_input.rb +9 -0
  19. data/app/inputs/autocomplete_zipcode/state_select_input.rb +9 -0
  20. data/app/inputs/autocomplete_zipcode/street_input.rb +9 -0
  21. data/app/inputs/autocomplete_zipcode/zipcode_input.rb +9 -0
  22. data/autocomplete_zipcode.gemspec +21 -12
  23. data/bin/console +7 -7
  24. data/bin/rails +19 -0
  25. data/config/initializers/simple_form_autocomplete_zipcode.rb +13 -0
  26. data/lib/autocomplete_zipcode.rb +13 -6
  27. data/lib/autocomplete_zipcode/version.rb +3 -1
  28. data/vendor/assets/javascripts/autocomplete_zipcode.js +45 -22
  29. metadata +125 -114
  30. data/example/.gitignore +0 -21
  31. data/example/Gemfile +0 -55
  32. data/example/Gemfile.lock +0 -186
  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 -17
  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 -17
  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: dcba0f183cd507240edbdf8339df464e59f45b72
4
- data.tar.gz: 196b2ca58e9871903acfd9c66aac2df6caa4ca0f
2
+ SHA256:
3
+ metadata.gz: f8b7aefc93d38da2a23783246342051799bae1e0cee0beb842e80c85e10afde8
4
+ data.tar.gz: f0a528f4432d060b5c3518cc268a8278facf36bfae9ce8c8e1e701a8db282373
5
5
  SHA512:
6
- metadata.gz: bb922c16004b3de26cde88f3bd3de274cb07a1eaf31debc5a8abb82728e963977effc7fa0eee7e4c6449927fcfb2c5708d6f87fd97e8a511957903b23c5f30ae
7
- data.tar.gz: d7de550a5b1ea2982e873fe6e7dfd2f0816f2e7e87fd30b364b7dd483e51cdb21d98a6e2e9d4654e2121689aff655f24d4577ce485acd5e93622eb8232ffec8d
6
+ metadata.gz: 5aaa4ea4c71395e3b013f101f69590f9c94f453ff220169957627f6f894039bc571fe9a11e436114d1fde4873fed8f9ef69c7fea7f277b19a171b06862e2a3a7
7
+ data.tar.gz: '0893608e98e986999b174ded384a14f881be7e2113074691293d3d5f8021fb920748ddc68e96df20e0a62f8c75f0ef57e188eb57d9402b39181133cb87c1d2bd'
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/support/helpers"
@@ -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.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (6.1.3.1)
10
+ actionpack (= 6.1.3.1)
11
+ activesupport (= 6.1.3.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.1.3.1)
15
+ actionpack (= 6.1.3.1)
16
+ activejob (= 6.1.3.1)
17
+ activerecord (= 6.1.3.1)
18
+ activestorage (= 6.1.3.1)
19
+ activesupport (= 6.1.3.1)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.1.3.1)
22
+ actionpack (= 6.1.3.1)
23
+ actionview (= 6.1.3.1)
24
+ activejob (= 6.1.3.1)
25
+ activesupport (= 6.1.3.1)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.1.3.1)
29
+ actionview (= 6.1.3.1)
30
+ activesupport (= 6.1.3.1)
31
+ rack (~> 2.0, >= 2.0.9)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.1.3.1)
36
+ actionpack (= 6.1.3.1)
37
+ activerecord (= 6.1.3.1)
38
+ activestorage (= 6.1.3.1)
39
+ activesupport (= 6.1.3.1)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.1.3.1)
42
+ activesupport (= 6.1.3.1)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.1.3.1)
48
+ activesupport (= 6.1.3.1)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.1.3.1)
51
+ activesupport (= 6.1.3.1)
52
+ activerecord (6.1.3.1)
53
+ activemodel (= 6.1.3.1)
54
+ activesupport (= 6.1.3.1)
55
+ activestorage (6.1.3.1)
56
+ actionpack (= 6.1.3.1)
57
+ activejob (= 6.1.3.1)
58
+ activerecord (= 6.1.3.1)
59
+ activesupport (= 6.1.3.1)
60
+ marcel (~> 1.0.0)
61
+ mini_mime (~> 1.0.2)
62
+ activesupport (6.1.3.1)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 1.6, < 2)
65
+ minitest (>= 5.1)
66
+ tzinfo (~> 2.0)
67
+ zeitwerk (~> 2.3)
68
+ ast (2.4.2)
69
+ builder (3.2.4)
70
+ coderay (1.1.3)
71
+ concurrent-ruby (1.1.8)
72
+ crass (1.0.6)
73
+ diff-lcs (1.4.4)
74
+ docile (1.3.5)
75
+ erubi (1.10.0)
76
+ globalid (0.4.2)
77
+ activesupport (>= 4.2.0)
78
+ i18n (1.8.10)
79
+ concurrent-ruby (~> 1.0)
80
+ jquery-rails (4.4.0)
81
+ rails-dom-testing (>= 1, < 3)
82
+ railties (>= 4.2.0)
83
+ thor (>= 0.14, < 2.0)
84
+ loofah (2.9.0)
85
+ crass (~> 1.0.2)
86
+ nokogiri (>= 1.5.9)
87
+ mail (2.7.1)
88
+ mini_mime (>= 0.1.1)
89
+ marcel (1.0.1)
90
+ method_source (1.0.0)
91
+ mini_mime (1.0.3)
92
+ mini_portile2 (2.5.0)
93
+ minitest (5.14.4)
94
+ nio4r (2.5.7)
95
+ nokogiri (1.11.2)
96
+ mini_portile2 (~> 2.5.0)
97
+ racc (~> 1.4)
98
+ parallel (1.20.1)
99
+ parser (3.0.0.0)
100
+ ast (~> 2.4.1)
101
+ pry (0.14.0)
102
+ coderay (~> 1.1)
103
+ method_source (~> 1.0)
104
+ racc (1.5.2)
105
+ rack (2.2.3)
106
+ rack-test (1.1.0)
107
+ rack (>= 1.0, < 3)
108
+ rails (6.1.3.1)
109
+ actioncable (= 6.1.3.1)
110
+ actionmailbox (= 6.1.3.1)
111
+ actionmailer (= 6.1.3.1)
112
+ actionpack (= 6.1.3.1)
113
+ actiontext (= 6.1.3.1)
114
+ actionview (= 6.1.3.1)
115
+ activejob (= 6.1.3.1)
116
+ activemodel (= 6.1.3.1)
117
+ activerecord (= 6.1.3.1)
118
+ activestorage (= 6.1.3.1)
119
+ activesupport (= 6.1.3.1)
120
+ bundler (>= 1.15.0)
121
+ railties (= 6.1.3.1)
122
+ sprockets-rails (>= 2.0.0)
123
+ rails-dom-testing (2.0.3)
124
+ activesupport (>= 4.2.0)
125
+ nokogiri (>= 1.6)
126
+ rails-html-sanitizer (1.3.0)
127
+ loofah (~> 2.3)
128
+ railties (6.1.3.1)
129
+ actionpack (= 6.1.3.1)
130
+ activesupport (= 6.1.3.1)
131
+ method_source
132
+ rake (>= 0.8.7)
133
+ thor (~> 1.0)
134
+ rainbow (3.0.0)
135
+ rake (13.0.3)
136
+ regexp_parser (2.1.1)
137
+ rexml (3.2.4)
138
+ rspec-core (3.10.1)
139
+ rspec-support (~> 3.10.0)
140
+ rspec-expectations (3.10.1)
141
+ diff-lcs (>= 1.2.0, < 2.0)
142
+ rspec-support (~> 3.10.0)
143
+ rspec-mocks (3.10.2)
144
+ diff-lcs (>= 1.2.0, < 2.0)
145
+ rspec-support (~> 3.10.0)
146
+ rspec-rails (5.0.1)
147
+ actionpack (>= 5.2)
148
+ activesupport (>= 5.2)
149
+ railties (>= 5.2)
150
+ rspec-core (~> 3.10)
151
+ rspec-expectations (~> 3.10)
152
+ rspec-mocks (~> 3.10)
153
+ rspec-support (~> 3.10)
154
+ rspec-support (3.10.2)
155
+ rubocop (1.12.0)
156
+ parallel (~> 1.10)
157
+ parser (>= 3.0.0.0)
158
+ rainbow (>= 2.2.2, < 4.0)
159
+ regexp_parser (>= 1.8, < 3.0)
160
+ rexml
161
+ rubocop-ast (>= 1.2.0, < 2.0)
162
+ ruby-progressbar (~> 1.7)
163
+ unicode-display_width (>= 1.4.0, < 3.0)
164
+ rubocop-ast (1.4.1)
165
+ parser (>= 2.7.1.5)
166
+ ruby-progressbar (1.11.0)
167
+ simple_form (5.1.0)
168
+ actionpack (>= 5.2)
169
+ activemodel (>= 5.2)
170
+ simplecov (0.20.0)
171
+ docile (~> 1.1)
172
+ simplecov-html (~> 0.11)
173
+ simplecov_json_formatter (~> 0.1)
174
+ simplecov-html (0.12.3)
175
+ simplecov_json_formatter (0.1.2)
176
+ sprockets (4.0.2)
177
+ concurrent-ruby (~> 1.0)
178
+ rack (> 1, < 3)
179
+ sprockets-rails (3.2.2)
180
+ actionpack (>= 4.0)
181
+ activesupport (>= 4.0)
182
+ sprockets (>= 3.0.0)
183
+ sqlite3 (1.4.2)
184
+ thor (1.1.0)
185
+ tzinfo (2.0.4)
186
+ concurrent-ruby (~> 1.0)
187
+ unicode-display_width (2.0.0)
188
+ websocket-driver (0.7.3)
189
+ websocket-extensions (>= 0.1.0)
190
+ websocket-extensions (0.1.5)
191
+ zeitwerk (2.4.2)
192
+
193
+ PLATFORMS
194
+ ruby
195
+
196
+ DEPENDENCIES
197
+ autocomplete_zipcode!
198
+ jquery-rails (~> 4.4.0)
199
+ pry (~> 0.14.0)
200
+ rails (>= 4.2.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
@@ -0,0 +1,123 @@
1
+ # AutocompleteZipcode
2
+
3
+ This gem was built to "automagically" fills an address form, for Rails version >= 3.1.
4
+
5
+ ## Status
6
+
7
+ [![Build Status](https://api.travis-ci.com/marcelobarreto/autocomplete_zipcode.svg?branch=master)](https://travis-ci.org/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)
15
+
16
+ ## Installation
17
+
18
+ Add the following gems to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'autocomplete_zipcode'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ ```bash
27
+ bundle install
28
+ ```
29
+
30
+ ## Simple Usage
31
+
32
+ In app/assets/javascripts/application.js, you should add as follows:
33
+
34
+ ```js
35
+ // app/assets/javascripts/application.js
36
+ //= require ...
37
+ //= require turbolinks
38
+ //= require jquery
39
+ //= require autocomplete_zipcode
40
+
41
+ $(document).on('ready', () => {
42
+ AutocompleteZipcode.mount();
43
+ });
44
+ ```
45
+
46
+ ## Basic Example
47
+
48
+ ```erb
49
+ <%= simple_form_for :example do |f| %>
50
+ ...
51
+ <%= f.input :zipcode, as: :zipcode %>
52
+ <%= f.input :street, as: :street %>
53
+ <%= f.input :neighborhood, as: :neighborhood %>
54
+ <%= f.input :city, as: :city %>
55
+ <%= f.input :state, as: :state %>
56
+ ...
57
+ <% end %>
58
+ ```
59
+
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.
61
+
62
+ ```erb
63
+ <%= form_for :example do |f| %>
64
+ ...
65
+ <%= f.text_field :zipcode, data: { autocomplete_zipcode_provider: :zipcode } %>
66
+ <%= f.text_field :street, data: { autocomplete_zipcode_provider: :street } %>
67
+ ...
68
+ <% end %>
69
+ ```
70
+
71
+ ## Handle invalid zipcodes
72
+
73
+ Simply add an event listener callback to `zipcode.error`, for example:
74
+
75
+ ```js
76
+ // app/assets/javascripts/application.js
77
+
78
+ document.addEventListener('zipcode.error', () => {
79
+ alert('Invalid zipcode!!!')
80
+ });
81
+ ```
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
+
112
+ ## Sample projects
113
+
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`)
116
+
117
+ ## Contributing
118
+
119
+ 1. Fork it
120
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
121
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
122
+ 4. Push to the branch (`git push origin my-new-feature`)
123
+ 5. Create new Pull Request
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