motion-ostruct 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbdf89c5c536bc1a7f1da4ff85e0f165ddd035a3
4
+ data.tar.gz: 3c9e7b930c90f5d381667f5e1db47c5c251e5deb
5
+ SHA512:
6
+ metadata.gz: 204b53340eb28511922cff76a2ebc4c21ed04ac5d3a2385a8eb6001a940993d79e6bd9349a58f8da4bebabca588fa05ae500e6a06b6379ce2021c2366def8a38
7
+ data.tar.gz: 30eec0c5c4a2d3f3281ce606833e4ba575a39d32515dd810ca57d4c5f8e9dd4a16b3e847dddfe1fe340386adbae9ba3e7e2cd12c09865d498829192de3adaad3
@@ -0,0 +1,7 @@
1
+ .rake_tasks~
2
+ pkg/*
3
+ build/
4
+ .DS_Store
5
+ .repl_history
6
+ 0
7
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2014, Jack Watson-Hamblin
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,27 @@
1
+ OpenStruct implement for RubyMotion
2
+
3
+ Usage
4
+ ---
5
+ ```
6
+ v = Motion::OpenStruct.new(:one => 'two')
7
+ p = Motion::OpenStruct.new(:one => 'two')
8
+ puts v
9
+ puts v == p
10
+ ```
11
+
12
+ Installation
13
+ ---
14
+ 1. Add this to your `Gemfile`: `gem 'motion-ostruct'`
15
+ 2. Run `bundle install`
16
+
17
+ License
18
+ ---
19
+ BSD 2-clause. See LICENSE file.
20
+
21
+ Questions
22
+ ---
23
+ * Email: [hboon@motionobj.com](mailto:hboon@motionobj.com)
24
+ * Web: [http://hboon.com/](http://hboon.com/)
25
+ * Twitter: [http://twitter.com/hboon](http://twitter.com/hboon)
26
+
27
+ [Code](https://gist.github.com/FluffyJack/6ecd13fda8ff9c6be879) is courtesy of [Jack Watson-Hamblin](https://twitter.com/FluffyJack).
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ $:.unshift("/Library/RubyMotion/lib")
3
+ #require 'motion/project/template/ios'
4
+ require 'motion/project/template/osx'
5
+ require "bundler/gem_tasks"
6
+ require "bundler/setup"
7
+ Bundler.require
8
+
9
+ Motion::Project::App.setup do |app|
10
+ app.name = 'motion-ostruct'
11
+ end
@@ -0,0 +1,5 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+ Dir.glob(File.join(File.dirname(__FILE__), 'motion-ostruct/**/*.rb')).each do |file|
7
+ app.files.unshift(file)
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ module Motion
2
+ end
@@ -0,0 +1,29 @@
1
+ # Courtesy https://gist.github.com/FluffyJack/6ecd13fda8ff9c6be879
2
+ module Motion
3
+ class OpenStruct < BasicObject
4
+ def initialize(hash)
5
+ @struct = ::Struct.new(*hash.keys.map { |k| k.to_sym })
6
+ @struct = @struct.new(*hash.values)
7
+ end
8
+
9
+ def ==(other)
10
+ to_h == other.to_h
11
+ end
12
+
13
+ def method_missing(method_name, *args, &block)
14
+ if method_name.to_s.index('=') && !@struct.respond_to?(method_name)
15
+ vals = @struct.to_h.values
16
+ getter_name = method_name.to_s.gsub('=', '')
17
+ getters = ((@struct.to_h.keys.map { |k| k.to_sym }) + [getter_name.to_sym])
18
+ @struct = ::Struct.new(*getters)
19
+ @struct = @struct.new(*vals)
20
+ end
21
+ @struct.send(method_name, *args, &block)
22
+ end
23
+
24
+ def respond_to_missing?(method_name, include_private = false)
25
+ return true if @struct.respond_to?(method_name)
26
+ return true if super
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module Motion
2
+ class OpenStruct < BasicObject
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/motion-ostruct/version.rb', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'motion-ostruct'
6
+ gem.version = Motion::OpenStruct::VERSION
7
+ gem.licenses = ['BSD-2-Clause']
8
+
9
+ gem.authors = ['Hwee-Boon Yar']
10
+
11
+ gem.description = 'Add variations of attr_accessor for RubyMotion for iOS & macOS'
12
+ gem.summary = gem.description
13
+ gem.homepage = 'https://github.com/hboon/motion-ostruct'
14
+ gem.email = 'hboon@motionobj.com'
15
+
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.require_paths = ['lib']
18
+ gem.test_files = gem.files.grep(%r{^spec/})
19
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-ostruct
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hwee-Boon Yar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Add variations of attr_accessor for RubyMotion for iOS & macOS
14
+ email: hboon@motionobj.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - Gemfile
21
+ - LICENSE
22
+ - README.md
23
+ - Rakefile
24
+ - app/app_delegate.rb
25
+ - lib/motion-ostruct.rb
26
+ - lib/motion-ostruct/motion-ostruct.rb
27
+ - lib/motion-ostruct/open_struct.rb
28
+ - lib/motion-ostruct/version.rb
29
+ - motion-ostruct.gemspec
30
+ homepage: https://github.com/hboon/motion-ostruct
31
+ licenses:
32
+ - BSD-2-Clause
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.5.1
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Add variations of attr_accessor for RubyMotion for iOS & macOS
54
+ test_files: []