indonesian-territory-rails 0.1.0 → 0.1.1
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/Gemfile +1 -3
- data/README.md +27 -8
- data/db/seed/indonesian_territory_csv.rb +8 -0
- data/db/seed/{indonesian_territory.rb → indonesian_territory_ruby.rb} +0 -0
- data/db/seed/indonesian_territory_sql.rb +4 -1
- data/indonesian-territory-rails.gemspec +0 -1
- data/lib/indonesian/territory/rails/version.rb +1 -1
- data/lib/tasks/indonesian_territory.rake +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b5c657abcdfb32366307203af9dfa6f82a63d81ea04f2d27fbcf65c64bbce50
|
4
|
+
data.tar.gz: d5e8d9be70bc06685497cf61308a1479cbcd15b4c4b5d3c891d82cff3f9ed9d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 745f94aa5734335e56f0bff9e6070855816af9db6df5fe2e0c90a5c6ee21c31a055cfa87b5e904b94edb0f3e3b3f2f8ad54dc11849482606a81008ce97ecde73
|
7
|
+
data.tar.gz: 68982a0ab7c465634dfaadd93d1a00ac962d1888f72ea24ef652f0f9dadcef711d7663db494fd041419f0417a646fb6155673d7fc23eea5c6629a87bb46bf594
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -32,32 +32,48 @@ $ gem install indonesian-territory-rails
|
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
|
-
|
35
|
+
#### Install Migration
|
36
|
+
|
37
|
+
Copy for schema migration:
|
36
38
|
```bash
|
37
39
|
$ rails g indonesian_territory:migration install
|
38
40
|
```
|
39
41
|
|
40
|
-
Migration
|
42
|
+
#### Migration
|
43
|
+
|
44
|
+
Migration database for data Indonesian Territory:
|
41
45
|
```bash
|
42
46
|
$ rails db:migrate
|
43
47
|
```
|
44
48
|
|
45
|
-
|
49
|
+
#### Seed
|
50
|
+
|
51
|
+
##### Ruby
|
52
|
+
Run seeding data Indonesian Territory use ruby method (this takes a very long time):
|
46
53
|
```bash
|
47
|
-
$ rails db:seed:
|
54
|
+
$ rails db:seed:indonesian_territory_ruby
|
48
55
|
```
|
49
56
|
|
50
|
-
|
57
|
+
##### SQL
|
58
|
+
Run seeding data Indonesian Territory use sql method (not not so bad, not as long as the ruby method above):
|
51
59
|
```bash
|
52
60
|
$ rails db:seed:indonesian_territory_sql
|
53
61
|
```
|
54
62
|
|
55
|
-
|
63
|
+
##### CSV
|
64
|
+
Run seeding data Indonesian Territory use csv method (not not so bad, not as long as the ruby method above):
|
65
|
+
```bash
|
66
|
+
$ rails db:seed:indonesian_territory_csv
|
67
|
+
```
|
68
|
+
|
69
|
+
#### Try Rails Console
|
70
|
+
|
71
|
+
Run Rails console:
|
56
72
|
```bash
|
57
73
|
$ rails c
|
58
74
|
```
|
59
75
|
|
60
|
-
Enter console to get data from the Province
|
76
|
+
Enter console to get data from the Province:
|
61
77
|
```console
|
62
78
|
irb(main):001:0> Province.all
|
63
79
|
```
|
@@ -67,7 +83,10 @@ Output:
|
|
67
83
|
=> #<ActiveRecord::Relation [#<Province id: 1, name: "ACEH", created_at: "2019-02-24 13:35:17", updated_at: "2019-02-24 13:35:17">, #<Province id: 2, name: "SUMATERA UTARA", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 3, name: "SUMATERA BARAT", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 4, name: "RIAU", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 5, name: "JAMBI", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 6, name: "SUMATERA SELATAN", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 7, name: "BENGKULU", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 8, name: "LAMPUNG", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 9, name: "KEPULAUAN BANGKA BELITUNG", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, #<Province id: 10, name: "KEPULAUAN RIAU", created_at: "2019-02-24 13:35:18", updated_at: "2019-02-24 13:35:18">, ...]>
|
68
84
|
```
|
69
85
|
|
70
|
-
|
86
|
+
#### Override Class Model
|
87
|
+
|
88
|
+
If you want to modify the model, please overwrite it by entering the generate command below:
|
89
|
+
|
71
90
|
```bash
|
72
91
|
$ rails g indonesian_territory:model
|
73
92
|
```
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# TODO:
|
2
|
+
# - ruby script to import csv
|
3
|
+
# - update for timestamp
|
4
|
+
#
|
5
|
+
# Province.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
6
|
+
# Regency.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
7
|
+
# District.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
8
|
+
# Village.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
File without changes
|
@@ -1,4 +1,7 @@
|
|
1
|
-
# TODO:
|
1
|
+
# TODO:
|
2
|
+
# - ruby script to import sql
|
3
|
+
# - update for timestamp
|
4
|
+
#
|
2
5
|
# Province.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
3
6
|
# Regency.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
4
7
|
# District.update_all(created_at: DateTime.now, updated_at: DateTime.now)
|
@@ -2,7 +2,7 @@ namespace :db do
|
|
2
2
|
namespace :seed do
|
3
3
|
Dir[File.expand_path('../../db/seed/*.rb', __dir__)].each do |filename|
|
4
4
|
task_name = File.basename(filename, '.rb')
|
5
|
-
desc "
|
5
|
+
desc "Loads the seed data from db/seed/*.rb in gem indonesian-territory-rails"
|
6
6
|
task task_name.to_sym => :environment do
|
7
7
|
load(filename) if File.exist?(filename)
|
8
8
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indonesian-territory-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cahyadi Triyansyah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,7 +78,8 @@ files:
|
|
78
78
|
- db/seed/includes/ruby/provinces.rb
|
79
79
|
- db/seed/includes/ruby/regencies.rb
|
80
80
|
- db/seed/includes/ruby/villages.rb
|
81
|
-
- db/seed/
|
81
|
+
- db/seed/indonesian_territory_csv.rb
|
82
|
+
- db/seed/indonesian_territory_ruby.rb
|
82
83
|
- db/seed/indonesian_territory_sql.rb
|
83
84
|
- indonesian-territory-rails.gemspec
|
84
85
|
- lib/generators/indonesian_territory/migration_generator.rb
|