motion-yaml 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
1
+ # motion-yaml
2
+
3
+ motion-yaml provides methods to access "YAML Ain't Markup Language" for RubyMotion projects.
4
+
5
+ ## Requirements
6
+
7
+ - RubyMotion 1.0 or greater (see http://www.rubymotion.com).
8
+
9
+ ## Installation
10
+
11
+ ```
12
+ $ sudo gem install motion-yaml
13
+ ```
14
+
15
+ ## Setup
16
+
17
+ 1. Edit the `Rakefile` of your RubyMotion project and add the following require lines.
18
+
19
+ require 'rubygems'
20
+ require 'motion-yaml'
21
+
22
+ ## Methods
23
+
24
+ ### YAML.dump(obj)
25
+
26
+ - Converts _obj_ to YAML.
27
+
28
+ YAML.dump([{ 'a' => 'b' }, 'foo']) #=> "- a: b\n- foo\n"
29
+
30
+ ### YAML.load(string)
31
+
32
+ - Loads YAML from a _string_.
33
+
34
+ YAML.load("- a: b\n- foo\n") #=> [{"a"=>"b"}, "foo"]
35
+
36
+ ### NSObject#to_yaml
37
+
38
+ - Converts _self_ to YAML.
39
+
40
+ [{ 'a' => 'b' }, 'foo'].to_yaml #=> "- a: b\n- foo\n"
41
+
42
+ ## Special thanks
43
+
44
+ Special thanks for Patrick Thomson who created [yamlkit](https://github.com/patrickt/yamlkit).
45
+
46
+ ## License
47
+
48
+ Copyright (c) 2013, HipByte SPRL and Contributors
49
+ All rights reserved.
50
+
51
+ Redistribution and use in source and binary forms, with or without
52
+ modification, are permitted provided that the following conditions are met:
53
+
54
+ 1. Redistributions of source code must retain the above copyright notice, this
55
+ list of conditions and the following disclaimer.
56
+ 2. Redistributions in binary form must reproduce the above copyright notice,
57
+ this list of conditions and the following disclaimer in the documentation
58
+ and/or other materials provided with the distribution.
59
+
60
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
61
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
63
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
64
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
65
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
67
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
68
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,26 @@
1
+ /*
2
+ * YAMLKit.h
3
+ * YAMLKit
4
+ *
5
+ * Created by Patrick Thomson on 12/29/08.
6
+ * Copyright 2008 Patrick Thomson. All rights reserved.
7
+ *
8
+ */
9
+
10
+ #import "YKParser.h"
11
+ #import "YKEmitter.h"
12
+
13
+ @interface YAMLKit : NSObject
14
+ {
15
+
16
+ }
17
+
18
+ + (NSString *)dumpObject:(id)object;
19
+ + (BOOL)dumpObject:(id)object toFile:(NSString *)path;
20
+ + (BOOL)dumpObject:(id)object toURL:(NSURL *)path;
21
+
22
+ + (id)loadFromString:(NSString *)aString;
23
+ + (id)loadFromFile:(NSString *)path;
24
+ + (id)loadFromURL:(NSURL *)url;
25
+
26
+ @end
@@ -0,0 +1,7 @@
1
+ //
2
+ // Prefix header for all source files of the 'YAMLKit' target in the 'YAMLKit' project
3
+ //
4
+
5
+ #ifdef __OBJC__
6
+ #import <Foundation/Foundation.h>
7
+ #endif
@@ -0,0 +1,22 @@
1
+ /*
2
+ * YKConstants.h
3
+ * YAMLKit
4
+ *
5
+ * Created by Patrick Thomson on 1/1/09.
6
+ * Copyright 2009 Patrick Thomson. All rights reserved.
7
+ *
8
+ */
9
+
10
+
11
+
12
+ NSString *YKErrorDomain = @"YKErrorDomain";
13
+ const NSString *YKProblemValueKey = @"YKProblemValue";
14
+ const NSString *YKProblemOffsetKey = @"YKProblemOffset";
15
+ const NSString *YKProblemIndexKey = @"YKProblemIndex";
16
+ const NSString *YKProblemLineKey = @"YKProblemLine";
17
+ const NSString *YKProblemColumnKey = @"YKProblemColumn";
18
+ const NSString *YKProblemDescriptionKey = @"YKProblemDescription";
19
+ const NSString *YKErrorContextIndexKey = @"YKErrorContextIndex";
20
+ const NSString *YKErrorContextLineKey = @"YKErrorContextLine";
21
+ const NSString *YKErrorContextColumnKey = @"YKErrorContextColumn";
22
+ const NSString *YKErrorContextDescriptionKey = @"YKErrorContext";
@@ -0,0 +1,26 @@
1
+ //
2
+ // YKEncoder.h
3
+ // YAMLKit
4
+ //
5
+ // Created by Patrick Thomson on 12/29/08.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "yaml.h"
10
+
11
+ @interface YKEmitter : NSObject {
12
+ yaml_emitter_t emitter;
13
+ NSMutableData *buffer;
14
+ BOOL usesExplicitDelimiters;
15
+ NSStringEncoding encoding;
16
+ }
17
+
18
+ - (void)emitItem:(id)item;
19
+ - (NSString *)emittedString;
20
+ - (NSData *)emittedData;
21
+
22
+ @property(assign) BOOL usesExplicitDelimiters;
23
+ @property(assign) NSStringEncoding encoding;
24
+
25
+
26
+ @end
@@ -0,0 +1,26 @@
1
+ //
2
+ // YKParser.h
3
+ // YAMLKit
4
+ //
5
+ // Created by Patrick Thomson on 12/29/08.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "yaml.h"
10
+
11
+ @interface YKParser : NSObject {
12
+ BOOL readyToParse;
13
+ FILE* fileInput;
14
+ const char *stringInput;
15
+ yaml_parser_t parser;
16
+ }
17
+
18
+ - (void)reset;
19
+ - (BOOL)readString:(NSString *)path;
20
+ - (BOOL)readFile:(NSString *)path;
21
+ - (NSArray *)parse;
22
+ - (NSArray *)parseWithError:(NSError **)e;
23
+
24
+ @property(readonly) BOOL readyToParse;
25
+
26
+ @end
Binary file
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2013, HipByte SPRL and Contributors
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ # this list of conditions and the following disclaimer in the documentation
11
+ # and/or other materials provided with the distribution.
12
+ #
13
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
+ # POSSIBILITY OF SUCH DAMAGE.
24
+
25
+ unless defined?(Motion::Project::Config)
26
+ raise "This file must be required within a RubyMotion project Rakefile."
27
+ end
28
+
29
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
30
+ Motion::Project::App.setup do |app|
31
+ app.files.concat(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
32
+ app.vendor_project(File.join(lib_dir_path, "YAMLKit"), :static)
33
+ end
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2013, HipByte SPRL and Contributors
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ # this list of conditions and the following disclaimer in the documentation
11
+ # and/or other materials provided with the distribution.
12
+ #
13
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
+ # POSSIBILITY OF SUCH DAMAGE.
24
+
25
+ class YAML < YAMLKit
26
+ def self.load(string)
27
+ loadFromString(string)
28
+ end
29
+
30
+ def self.dump(object)
31
+ dumpObject(object)
32
+ end
33
+ end
34
+
35
+ class NSObject
36
+ def to_yaml
37
+ YAML.dump(self)
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-yaml
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Laurent Sansonetti
9
+ - Shizuo Fujita
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-01-29 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: motion-yaml provides methods to access "YAML Ain't Markup Language" for
16
+ RubyMotion projects.
17
+ email:
18
+ - lrz@hipbyte.com
19
+ - watson1978@gmail.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - README.md
25
+ - lib/motion-yaml.rb
26
+ - lib/project/yaml.rb
27
+ - lib/YAMLKit/libYAMLKit.a
28
+ - lib/YAMLKit/YAMLKit.h
29
+ - lib/YAMLKit/YAMLKit_Prefix.pch
30
+ - lib/YAMLKit/YKConstants.h
31
+ - lib/YAMLKit/YKEmitter.h
32
+ - lib/YAMLKit/YKParser.h
33
+ homepage: https://github.com/HipByte/motion-yaml
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.23
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: motion-yaml provides methods to access "YAML Ain't Markup Language" for RubyMotion
57
+ projects.
58
+ test_files: []