motion-encodable 0.0.1 → 0.0.2

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: 195f164b3633c8ad4a79e14493d5a7065be2a304
4
- data.tar.gz: 37f4ec00e489977d48d3499ec0f2e21f52f4e73c
3
+ metadata.gz: 8b280c2117cce5bcc4ff553bb33cab8cf468d6a1
4
+ data.tar.gz: fd9690c242ece1c1453a8a9d52a2241a2be139cf
5
5
  SHA512:
6
- metadata.gz: 9dcb3e05621b325cc7e94a1cf24b6ba7e8e650ab4af93dddf1307babbe683cae869748dca732b8bde0dfde067bb932539ee9020f883efd006eab33fee534387c
7
- data.tar.gz: 2f099f88a21d3bc297d750c29af95e5722efea3afd0187a8ea9226430fa7dd948b4660c1dd3205f2c2dbd349413161db66032f5345a82c1dd7d55d20455f2e85
6
+ metadata.gz: d81ec337fde70ab58d13169b7aaab1075762b9f59cddc427e2806071e7ae1bfde152d7a576897b14e527fc14b0a2d162a16824b078ada5eadccec7acdeffdfb3
7
+ data.tar.gz: a1c776ce78741097a019fcde670911409656cce8021a0c33a56d710ebd1d82419b7d0af8cfe4f5a6ad1cf603a3434ec1a8615395f3d05788eedf2f4417aff7e4
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ nbproject
15
15
  .sass-cache
16
16
  .idea
17
17
  Gemfile.lock
18
+ pkg
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # motion-encodable
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/motion-encodable.png)](http://badge.fury.io/rb/motion-encodable)
3
4
  [![Build Status](https://travis-ci.org/satococoa/motion-encodable.png?branch=master)](https://travis-ci.org/satococoa/motion-encodable)
4
5
  [![Dependency Status](https://gemnasium.com/satococoa/motion-encodable.png)](https://gemnasium.com/satococoa/motion-encodable)
5
6
  [![Code Climate](https://codeclimate.com/github/satococoa/motion-encodable.png)](https://codeclimate.com/github/satococoa/motion-encodable)
@@ -24,7 +25,7 @@ Or install it yourself as:
24
25
 
25
26
  ```
26
27
  class Entry
27
- include Encodable
28
+ include Motion::Encodable
28
29
  properties :title, :body
29
30
  end
30
31
  ```
@@ -25,6 +25,10 @@ class Motion
25
25
  def to_data
26
26
  NSKeyedArchiver.archivedDataWithRootObject(self)
27
27
  end
28
+
29
+ def save_to_file(path)
30
+ NSKeyedArchiver.archiveRootObject(self, toFile: path)
31
+ end
28
32
 
29
33
  # NSCoding protocol
30
34
  def initWithCoder(decoder)
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "motion-encodable"
@@ -16,6 +16,18 @@ describe Motion::Encodable do
16
16
  describe 'NSCoder protocol' do
17
17
  before do
18
18
  @entry = Entry.new(@params)
19
+ dir_path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
20
+ @file_path = dir_path + '/entry.dat'
21
+ end
22
+
23
+ after do
24
+ # remove saved file
25
+ file_manager = NSFileManager.defaultManager
26
+ if file_manager.fileExistsAtPath(@file_path)
27
+ error = Pointer.new(:object)
28
+ file_manager.removeItemAtPath(@file_path, error: error)
29
+ raise error[0] if error[0]
30
+ end
19
31
  end
20
32
 
21
33
  it 'should responds to required methods' do
@@ -23,10 +35,17 @@ describe Motion::Encodable do
23
35
  @entry.respond_to?(:'encodeWithCoder:').should == true
24
36
  end
25
37
 
26
- it 'should be able to load' do
38
+ it 'should be able to load as data' do
27
39
  entry_as_data = @entry.to_data
28
40
  loaded_entry = Entry.load(entry_as_data)
29
41
  loaded_entry.title.should == @params[:title]
30
42
  end
43
+
44
+ it 'should be able to save into file' do
45
+ @entry.save_to_file(@file_path)
46
+ entry_as_data = NSData.dataWithContentsOfFile(@file_path)
47
+ loaded_entry = Entry.load(entry_as_data)
48
+ loaded_entry.title.should == @params[:title]
49
+ end
31
50
  end
32
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-encodable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Ebisawa