constructorio 1.0.3 → 1.0.4
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 +4 -4
- data/README.md +2 -2
- data/lib/constructorio.rb +1 -1
- data/lib/constructorio/helper.rb +1 -1
- data/lib/constructorio/version.rb +1 -1
- data/test/test_helper.rb +3 -3
- data/test/view_helper_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a44d85b592d503fee64cbf411daf318ab52fcfc9
|
4
|
+
data.tar.gz: 29aefce25803f2b066488c1550a047ee04ed0071
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 736e434f3feae53f9c501764871c7a96529efc39fdd124f557dd8fc55db98fe44cb25f6e03d31222497cb47d78739ce0173d6b861dd74683731c4b9e285f2898
|
7
|
+
data.tar.gz: 84df4cf7349f73b33f54cd0aa60f14a4f15b72d45630f442f1be4777550abb7b49a40fee1075abc5e41e2c84a6c1c821753b4ca9e801139bf06885045299abd0
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ To add autocomplete to a model:
|
|
32
32
|
```
|
33
33
|
class MyModel < ActiveRecord::Base
|
34
34
|
include ConstructorIO
|
35
|
-
|
35
|
+
constructorio_autocomplete(['attribute1', 'attribute2'])
|
36
36
|
end
|
37
37
|
|
38
38
|
```
|
@@ -40,7 +40,7 @@ end
|
|
40
40
|
To attach an autocomplete dropdown to an input field, just insert this in your view:
|
41
41
|
|
42
42
|
```
|
43
|
-
<%=
|
43
|
+
<%= constructorio_autocomplete(dom_id: 'id_of_input_field') %>
|
44
44
|
```
|
45
45
|
|
46
46
|
To import an existing data set into Constructor.io, you can use the rake task:
|
data/lib/constructorio.rb
CHANGED
@@ -40,7 +40,7 @@ module ConstructorIO
|
|
40
40
|
# "product_name", "description"
|
41
41
|
# - or -
|
42
42
|
# { 'attribute' => 'product_name', 'metadata' => { metadata_one => ->{ something_dynamic }} }
|
43
|
-
def
|
43
|
+
def constructorio_autocomplete(fields, autocomplete_key = ConstructorIO.configuration.autocomplete_key)
|
44
44
|
# All fields require an attribute
|
45
45
|
field_names = fields.map { |f| f.is_a?(String) ? f : f['attribute'] }
|
46
46
|
raise MissingItemName if field_names.include? nil
|
data/lib/constructorio/helper.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ConstructorIO
|
4
4
|
module Helper
|
5
|
-
def
|
5
|
+
def constructorio_autocomplete(options = {})
|
6
6
|
result = %Q|<script type="text/javascript" src="//cnstrc.com/js/ac.js"></script>\n|
|
7
7
|
result += %Q|<script>$(document).ready(function(){ $('##{options[:dom_id]}').constructorAutocomplete({ key: '#{ConstructorIO.configuration.autocomplete_key}' }); })</script>|
|
8
8
|
return result.html_safe
|
data/test/test_helper.rb
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
|
26
26
|
class Person < ActiveRecord::Base
|
27
27
|
include ConstructorIO
|
28
|
-
|
28
|
+
constructorio_autocomplete [{
|
29
29
|
'attribute' => 'first_name',
|
30
30
|
'metadata' => {
|
31
31
|
'test_metadata' => 'test_values',
|
@@ -37,13 +37,13 @@ end
|
|
37
37
|
class PersonSimple < ActiveRecord::Base
|
38
38
|
self.table_name = 'people'
|
39
39
|
include ConstructorIO
|
40
|
-
|
40
|
+
constructorio_autocomplete [ 'first_name' ]
|
41
41
|
end
|
42
42
|
|
43
43
|
class PersonNoKey < ActiveRecord::Base
|
44
44
|
self.table_name = 'people'
|
45
45
|
include ConstructorIO
|
46
|
-
|
46
|
+
constructorio_autocomplete [{'attribute' => 'last_name'}]
|
47
47
|
end
|
48
48
|
|
49
49
|
class FakeView
|
data/test/view_helper_test.rb
CHANGED
@@ -6,6 +6,6 @@ class ViewHelperTest < MiniTest::Test
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_autocomplete_html
|
9
|
-
assert_equal @fakeview.
|
9
|
+
assert_equal @fakeview.constructorio_autocomplete(dom_id: 'a'), "<script type=\"text/javascript\" src=\"//cnstrc.com/js/ac.js\"></script>\n<script>$(document).ready(function(){ $('#a').constructorAutocomplete({ key: 'example_autocomplete_key' }); })</script>"
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructorio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Lai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|