propinsi 0.0.2 → 0.0.3
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 +23 -11
- data/Rakefile +1 -2
- data/lib/propinsi.rb +2 -2
- data/lib/propinsi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cbbeef5bbb21bbda7a7445e734d7114a74e538f
|
|
4
|
+
data.tar.gz: f5f3f28d07d38dfbf90e93c7875948450eb8bf81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48f2f47de952b358b68df34efa16630fcabe23c6b3db095beee9f3550b828d156d966c746b6398396332986fd2e0d42c2809d21a9aa7085310c28d4e9ae7b5d1
|
|
7
|
+
data.tar.gz: f09764f059d42b7fb9c4944165b577d4e5b762055be87befcb232934d72365ce247243b990139aa187ee4b327442447a62175d6603212c922121ec183161f004
|
data/README.md
CHANGED
|
@@ -19,11 +19,17 @@ Or install it yourself as:
|
|
|
19
19
|
|
|
20
20
|
$ gem install propinsi
|
|
21
21
|
|
|
22
|
+
run
|
|
23
|
+
|
|
24
|
+
$ rails g propinsi:install
|
|
25
|
+
|
|
22
26
|
after instalation there will be some new files
|
|
23
27
|
|
|
24
|
-
lib/tasks/propinsi.rake
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
- lib/tasks/propinsi.rake
|
|
29
|
+
- db/migrate/yyyymmdd_create_cities.rb
|
|
30
|
+
- db/migrate/yyyymmdd_create_provinces.rb
|
|
31
|
+
- model/province.rb
|
|
32
|
+
- model/city.rb
|
|
27
33
|
|
|
28
34
|
run:
|
|
29
35
|
|
|
@@ -40,27 +46,33 @@ to import all provinces and cities into your created table.
|
|
|
40
46
|
### Usage with database
|
|
41
47
|
Since the province and city is already in your database, you can use it normaly as you call a table.
|
|
42
48
|
To implement in a select box, you can use [collection select](http://guides.rubyonrails.org/form_helpers.html).
|
|
43
|
-
|
|
49
|
+
|
|
50
|
+
`<%= collection_select(:user, :province_id, Province.all, :id, :name) %>`
|
|
44
51
|
|
|
45
52
|
### Usage without database
|
|
46
53
|
If you do not want to use database, you can use our array based list.
|
|
47
54
|
|
|
48
55
|
Display all data
|
|
49
|
-
|
|
56
|
+
|
|
57
|
+
`Propinsi.all`
|
|
50
58
|
|
|
51
59
|
Display all province
|
|
52
|
-
|
|
60
|
+
|
|
61
|
+
`Propinsi.propinsi`
|
|
53
62
|
|
|
54
63
|
Find province based on ID or name
|
|
55
|
-
|
|
56
|
-
`Propinsi.findpropinsi(
|
|
64
|
+
|
|
65
|
+
`Propinsi.findpropinsi(1)`
|
|
66
|
+
`Propinsi.findpropinsi("Aceh")`
|
|
57
67
|
|
|
58
68
|
Diplay all City
|
|
59
|
-
|
|
69
|
+
|
|
70
|
+
`Propinsi.kota`
|
|
60
71
|
|
|
61
72
|
find city based on ID or name
|
|
62
|
-
|
|
63
|
-
`
|
|
73
|
+
|
|
74
|
+
`Propinsi.findkota(2)` #Kabupaten Aceh Tenggara
|
|
75
|
+
`Propoinsi.findkota("bekasi")`
|
|
64
76
|
|
|
65
77
|
## Contributing
|
|
66
78
|
|
data/Rakefile
CHANGED
data/lib/propinsi.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Propinsi
|
|
|
23
23
|
def Propinsi.findkota(input)
|
|
24
24
|
kota=self.kota;
|
|
25
25
|
index=kota.each_with_index do |row,idx|
|
|
26
|
-
break idx if(input.to_s == row["id"].to_s ||
|
|
26
|
+
break idx if(input.to_s == row["id"].to_s || row["name"].to_s.downcase.include? input.to_s.downcase)
|
|
27
27
|
end
|
|
28
28
|
if index.kind_of?(Array)
|
|
29
29
|
return false;
|
|
@@ -36,7 +36,7 @@ module Propinsi
|
|
|
36
36
|
def Propinsi.findpropinsi(input)
|
|
37
37
|
prop=self.all
|
|
38
38
|
index=prop.each_with_index do |row,idx|
|
|
39
|
-
break idx if(input.to_s == row["id"].to_s ||
|
|
39
|
+
break idx if(input.to_s == row["id"].to_s || row["name"].to_s.downcase.include? input.to_s.downcase)
|
|
40
40
|
end
|
|
41
41
|
if index.kind_of?(Array)
|
|
42
42
|
return false;
|
data/lib/propinsi/version.rb
CHANGED