motion-assets-library 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e02eb3f8cd1a385657cfb4c9897b0cae4c90602
4
- data.tar.gz: d6019f9f6e859ace296f0500ce9964c84beb3606
3
+ metadata.gz: 16e9bcd714d565dd822c7085bb6d5d975d7bed0b
4
+ data.tar.gz: 14979958de66700c941139c38167e057961083ba
5
5
  SHA512:
6
- metadata.gz: 2e9811d2c90b27a44ac7eb5cae107deb4c6838ab78de516c6ef0a21205f7d22045a94b88bf6cd2458e0ada4f2b6151c67f20f7dcbb4194197160d26a94b74686
7
- data.tar.gz: 7fa87d1c8846236c637739b7686c03c2a417d4ea483dd1e0ca44b44f788c05dfba13dad519e5f889bfca50f9866ec1d959ea3b0ee515a531118dee6792b3e24f
6
+ metadata.gz: eac8e6d1c0f5ecad6ce24687b08694e67b6866875ad59847b1de085322b054c878e6ce279d33d9ccf0b6cb775e895c2b45618cd5ad5f236aec8c61466069718d
7
+ data.tar.gz: c15a908d5a7f838d7862d318e237f4b50fe15a1f814ea0aab7b3c2bf28c2929b50d6e61d1d4f0a046dd688391a4cc06fefd0748ec63bd6033e18e3aa6cebe052
@@ -17,6 +17,7 @@ class Motion
17
17
 
18
18
  def save(image, to_album: album_name, &block)
19
19
  @success_callback = block
20
+ @album_found = false
20
21
 
21
22
  if access_denied?
22
23
  denied_callback.call if denied_callback
@@ -43,24 +44,28 @@ class Motion
43
44
  })
44
45
  end
45
46
 
46
- def add_asset_url(asset_url, to_album: album_name)
47
- album_found = false
47
+ def album_found?
48
+ !!@album_found
49
+ end
48
50
 
51
+ def add_asset_url(asset_url, to_album: album_name)
49
52
  assets_library.enumerateGroupsWithTypes(ALAssetsGroupAlbum, usingBlock: lambda { |group, stop|
50
- if group && album_name === group.valueForProperty(ALAssetsGroupPropertyName)
51
- album_found = stop = true
52
-
53
- assets_library.assetForURL(asset_url, resultBlock: lambda { |asset|
54
- group.addAsset(asset)
55
- }, failureBlock: nil)
56
- end
53
+ if group
54
+ if album_name === group.valueForProperty(ALAssetsGroupPropertyName)
55
+ @album_found = true
57
56
 
58
- if album_found == false
59
- assets_library.addAssetsGroupAlbumWithName(album_name, resultBlock: lambda { |group|
60
57
  assets_library.assetForURL(asset_url, resultBlock: lambda { |asset|
61
58
  group.addAsset(asset)
62
59
  }, failureBlock: nil)
63
- }, failureBlock: nil)
60
+ end
61
+ else
62
+ unless album_found?
63
+ assets_library.addAssetsGroupAlbumWithName(album_name, resultBlock: lambda { |new_group|
64
+ assets_library.assetForURL(asset_url, resultBlock: lambda { |asset|
65
+ new_group.addAsset(asset)
66
+ }, failureBlock: nil)
67
+ }, failureBlock: nil)
68
+ end
64
69
  end
65
70
  }, failureBlock: nil)
66
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-assets-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devon Blandin