ika 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -4
  3. data/lib/ika/version.rb +1 -1
  4. data/lib/ika.rb +9 -4
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9d601e456604b7ef58cdc9b299c8be7039e2859
4
- data.tar.gz: 4083a46fa4be849c07adbf671946cc66beddb4ac
3
+ metadata.gz: 445850d5ed265759a2d0fbf1e139ea2af728b2d2
4
+ data.tar.gz: ae8be98de4260f41331a00be42991cb6b7922a4e
5
5
  SHA512:
6
- metadata.gz: 33ce07999c380e9b01f8a01d94b33996e1dc15ddd63b528d32edb1c87a2d9b98fc6cb9689e7e901eceb6b92d29811a760aa4b0c1c768e249398b15276fa2baa9
7
- data.tar.gz: 22f9e29e4f51c65fa5784e06e529b4a7a7c2931c82e1473592e91910aa1046c1874640a4026b9ac1d0f0ae5598a13f85620152a09f59a34cc9f014d7056839b7
6
+ metadata.gz: b05f0fa66d21a8521298d4118ff59e615712c5c9bd5c546d0d9106c0d1f44e55f04eade81b7edf01b7f490a010ee15d4d226dc1b457e7cc6a667c59b5bb00106
7
+ data.tar.gz: 5e49528daa04168f46033066a439f0a0fffe1a89d11066e7e9ed17f6b4a79c3c349d5a7bfea7675d61331f6ac4a22189e7b737a35ed8417cfeff3136ac991926
data/README.md CHANGED
@@ -76,13 +76,10 @@ User.exist?(id: 2)
76
76
 
77
77
  ## Others
78
78
 
79
+ * **DO NOT USE sync mode if you are using `include` option.**
79
80
  * If the same id exists, Ika uses `UPDATE`.
80
81
  * Uploaded files by `carrierwave` will be checked their md5 hash and do nothing if they exist and md5 is matched.
81
82
 
82
- ## Not yet implemented features
83
-
84
- * Sync mode (If class method `import` is called with sync mode, delete all data that are not contained exporting json)
85
-
86
83
  ## License
87
84
 
88
85
  Copyright (c) 2015 Aqutras
data/lib/ika/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ika
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
data/lib/ika.rb CHANGED
@@ -34,11 +34,16 @@ module Ika
34
34
  else
35
35
  if new.try(key.to_sym).class.superclass == CarrierWave::Uploader::Base
36
36
  need_update = true
37
- if File.exist?('public' + object[key]['url'])
38
- md5 = Digest::MD5.file('public' + object[key]['url'])
39
- need_update = false if md5 == object[key]['md5'] && record_exists == true
37
+ obj_url = object[key]['url'] || object[key][:url]
38
+ obj_md5 = object[key]['md5'] || object[key][:md5]
39
+ obj_data = object[key]['data'] || object[key][:data]
40
+ obj_name = object[key]['name'] || object[key][:name]
41
+ if obj_url && File.exist?('public' + obj_url)
42
+ md5 = Digest::MD5.file('public' + obj_url)
43
+ need_update = false if md5 == obj_md5 && record_exists == true
44
+ elsif obj_url
45
+ object_params[key] = base64_conversion(obj_data, obj_name) if need_update
40
46
  end
41
- object_params[key] = base64_conversion(object[key]['data'], object[key]['name']) if need_update
42
47
  else
43
48
  object_params[key] = object[key]
44
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ika
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makoto NAKAYA
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-06 00:00:00.000000000 Z
12
+ date: 2015-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails