purplish-accessors 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: 06d15a8d1206a37b826f6014e80cf375d34034a1
4
+ data.tar.gz: 60e520a85761c0f43cdfc0f35ede3ac783385d7b
5
+ SHA512:
6
+ metadata.gz: 1395ecb6f21ec3f91bee9b36044542c2e515321af1d3bb2cddbc4382a11cd283e95f8c7540685a72fa5e7223e412369ab7f0846e34752db7b9ddc6941e177db0
7
+ data.tar.gz: 250ce9ac4e831b77d2ddc622de862f66628a16b08bb1fd14b4f261a64fc33cd515b6eecb425c516a205263a024546d6190729e5c216661438748be00120c5b56
@@ -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) 2017, Hwee-Boon Yar
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,28 @@
1
+ #Make working with rects, sizes and points more convenient with [RubyMotion](http://rubymotion.com) for iOS & OS X
2
+
3
+ Usage
4
+ ---
5
+ ```
6
+ class AppDelegate
7
+ private_attr_accessor :datastore
8
+ private_bool_attr_accessor :foo
9
+ bool_attr_accessor :bar
10
+ block_attr_accessor :foobar
11
+ symbol_attr_accessor :alignment
12
+ end
13
+ ```
14
+
15
+ Installation
16
+ ---
17
+ 1. Add this to your `Gemfile`: `gem 'purplish-accessors'`
18
+ 2. Run `bundle install`
19
+
20
+ License
21
+ ---
22
+ BSD 2-clause. See LICENSE file.
23
+
24
+ Questions
25
+ ---
26
+ * Email: [hboon@motionobj.com](mailto:hboon@motionobj.com)
27
+ * Web: [http://hboon.com/](http://hboon.com/)
28
+ * Twitter: [http://twitter.com/hboon](http://twitter.com/hboon)
@@ -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 = 'purplish-accessors'
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__), 'purplish-accessors/**/*.rb')).each do |file|
7
+ app.files.unshift(file)
8
+ end
9
+ end
@@ -0,0 +1,56 @@
1
+ class Class
2
+ def private_attr_accessor(*attr)
3
+ attr_accessor(*attr)
4
+ private(*attr)
5
+ attr.each { |e| private("#{e}=".to_sym) }
6
+ end
7
+
8
+ def private_bool_attr_accessor(*attr)
9
+ method_names = bool_attr_accessor(*attr)
10
+ classes = method_names.map(&:class)
11
+ private(*method_names)
12
+ end
13
+
14
+ # Returns the list of method names (symbols) generated. Useful for making them private
15
+ def bool_attr_accessor(*my_accessors)
16
+ method_names = []
17
+ my_accessors.each do |accessor|
18
+ name = ("#{accessor}?").to_sym
19
+ method_names << name
20
+ define_method(name) do
21
+ !!instance_variable_get("@#{accessor}") #rubocop:disable DoubleNegation
22
+ end
23
+
24
+ name = "#{accessor}=".to_sym
25
+ method_names << name
26
+ define_method(name) do |accessor_value|
27
+ instance_variable_set("@#{accessor}", accessor_value)
28
+ end
29
+ end
30
+ method_names
31
+ end
32
+
33
+ def block_attr_accessor(*my_accessors)
34
+ my_accessors.each do |accessor|
35
+ define_method(accessor) do
36
+ instance_variable_get("@#{accessor}")
37
+ end
38
+
39
+ define_method("#{accessor}=") do |accessor_value|
40
+ instance_variable_set("@#{accessor}", accessor_value ? accessor_value.weak! : nil)
41
+ end
42
+ end
43
+ end
44
+
45
+ def symbol_attr_accessor(*my_accessors)
46
+ my_accessors.each do |accessor|
47
+ define_method(accessor) do
48
+ instance_variable_get("@#{accessor}")
49
+ end
50
+
51
+ define_method("#{accessor}=") do |accessor_value|
52
+ instance_variable_set("@#{accessor}", accessor_value.to_sym)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,2 @@
1
+ module PurplishAccessors
2
+ end
@@ -0,0 +1,3 @@
1
+ module PurplishAccessors
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/purplish-accessors/version.rb', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'purplish-accessors'
6
+ gem.version = PurplishAccessors::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/purplish-accessors'
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: purplish-accessors
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-04 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/purplish-accessors.rb
26
+ - lib/purplish-accessors/class.rb
27
+ - lib/purplish-accessors/purplish_accessors.rb
28
+ - lib/purplish-accessors/version.rb
29
+ - purplish-accessors.gemspec
30
+ homepage: https://github.com/hboon/purplish-accessors
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: []