rubymotion-community / motion-support Goto Github PK
View Code? Open in Web Editor NEWCommonly useful extensions to the standard library for RubyMotion
License: MIT License
Commonly useful extensions to the standard library for RubyMotion
License: MIT License
(main)> today = Date.today
=> Thu, 30 Jan 2014
(main)> Time.at(today.to_time.to_i)
=> 2014-01-30 02:19:38 -0800
(main)> tomorrow = Date.today + 1.day
=> Fri, 31 Jan 2014
(main)> Time.at(tomorrow.to_time.to_i)
=> 2014-01-30 16:00:00 -0800
Using @wndxlori PR #42 to resolve relative path issues, trying to require the full motion-support gem causes the app to crash with no error info:
Create ./build/Development-26/classes.dex
Merged dex #1 (6 defs/1.9KiB)
Merged dex #2 (48 defs/15.1KiB)
Result is 54 defs/20.6KiB. Took 0.0s
Create ./build/Development-26/Hello.apk
Sign ./build/Development-26/Hello.apk
Align ./build/Development-26/Hello.apk
Install ./build/Development-26/Hello.apk
Start com.yourcompany.hello/.MainActivity
--------- beginning of main
--------- beginning of system
--------- beginning of crash
(main)>
Remote process has quit.
error: no devices found
Steps:
create a new project: motion create --template=android Hello
Add to Gemfile: gem 'motion-support', git: 'https://github.com/wndxlori/motion-support.git', ref: '3fedd09', require: false
Add to Rakefile: require 'motion-support'
Then run bundle and bundle exec rake
motion --version: 5.17 on mohave
Strange issue, not sure if it's related with RubyMotion or MotionSupport.
When I write in motion console, it works fine:
(main)> Time.now + 1.month
=> 2014-04-05 17:56:07 +0400
But when I write the same in compiled method:
def test
Time.now + 1.month
end
It raises exception:
app_delegate.rb:156:in `test': can't convert MotionSupport::Duration into an exact number (TypeError)
It works fine if i write Time.now + 1.month.to_i
This issue started from latest RubyMotion (2.23/2.24).
Do you know something about it?
Thanks.
So @kastiglione has a branch of ActiveSupport which doesn't have string-based evals (eval-less, so in theory it should be compatible with RubyMotion.
You'd have to do some tricks with require
and static analysis to convert it to the whole RubyMotion file dependencies shtick, but it feels doable.
Whatchu think?
The version on rubygems.org was too old, released at Dec 28 2013
https://rubygems.org/gems/motion-support
At least this update is very useful:
#22
I encountered a file dependency issue recently, the root cause is that 'motion-yapper' gem set detect_dependencies to false for motion-support, but Promotion-menu gem can't work without auto dependency detection.
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
If I store an end_of_year time object in NSUserDefaults, there is a rounding error due to the microseconds that ups it to the beginning of the next year. See below (where $defaults is my NSUserDefaults object):
Time.local(2015, 12, 31, 23, 59, 59, Rational(999999999, 1000))
=> 2015-12-31 23:59:59 -0800
$defaults[:filters_date_to] = Time.local(2015, 12, 31, 23, 59, 59, Rational(999999999, 1000))
=> 2015-12-31 23:59:59 -0800
$defaults[:filters_date_to]
=> 2016-01-01 00:00:00 -0800
motion-support code in question is below. I don't know a safe way to fix this w/o a dirty hacking, so it's more of any FYI to other users for now.
# Returns a new Time representing the end of the day, 23:59:59.999999 (.999999999 in ruby1.9)
def end_of_day
change(
:hour => 23,
:min => 59,
:sec => 59,
:usec => Rational(999999999, 1000)
)
end
Seems like there's some really useful stuff here. Main problem I have with this gem, is that it can't be used when you have app dependencies turned on, which is a requirement for me.
(main)> Date.today
=> Sun, 15 Nov 2015
(main)> Date.tomorrow
=> Mon, 16 Nov 2015
(main)> Date.today.to_time
=> 2015-11-15 18:33:29 -0600
(main)> Date.tomorrow.to_time
=> 2015-11-16 00:00:00 UTC
This manifests itself in interesting ways, including that Date.tomorrow.future?
is not true
in the above case (thank you timezones)
I'm the creator of MotionModel. It was intended to emulate DataMapper/ActiveModel in many ways and that meant also creating some core extensions to types like Hash and String as well as an Inflector.
I've been wanting an ActiveSupport type of gem outside of MotionModel, and yours looks like a great place. I wonder if you could have a look at the core extensions in https://github.com/sxross/MotionModel/blob/master/lib/motion_model/ext.rb and see whether you agree these might better be in your motion-support than in my MotionModel. This would put us on the road to giving the whole RubyMotion community a single definitive ActiveSupport-like gem.
Thoughts?
STR:
bundle exec rake spec
Spec crash in plus_with_duration
method
$ motion doctor
= ENVIRONMENT INFO =
Swift Runtime: ✅
RubyMotion Templates: ✅
RubyMotion Commands: ✅
= RubyMotion =
version: 8.6
osx sdks: 10.10, 10.11, 10.12, 10.13, 10.14, 10.15, 10.9, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 12.2, 12.3, librubymotion-repl.dylib
ios sdks: 10.0, 10.1, 10.2, 10.3, 11.0, 11.1, 11.2, 11.3, 11.4, 12.0, 12.1, 12.2, 12.4, 13.0, 13.2, 13.4, 13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 15.0, 15.1, 15.2, 15.4, 15.5, 16.0, 5.0, 5.1, 6.0, 6.1, 7.0, 7.1, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, 9.2, 9.3
tv sdks: 9.0, 9.1, 9.2
watch sdks: 2.0, 2.1, 2.2
android sdks: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
= xcodebuild =
Xcode 14.0
Build version 14A309
= clang =
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode-14.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
= xcode-select =
version: xcode-select version 2395.
path: /Applications/Xcode-14.0.0.app/Contents/Developer
= Xcode =
osx platform: MacOSX.sdk, MacOSX12.3.sdk, MacOSX12.sdk
ios platform: iPhoneOS.sdk, iPhoneOS16.0.sdk
tv platform: AppleTVOS.sdk, AppleTVOS16.0.sdk
watch platform: WatchOS.sdk, WatchOS9.0.sdk
= Android =
android sdks: (none)
android ndk: (none)
= Java =
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
= MacOS =
System Version: macOS 12.6 (21G115)
= ENV =
RUBYMOTION_ANDROID_SDK=
RUBYMOTION_ANDROID_NDK=
= Ruby Manager =
rvm: /Users/xxxxxx/.rvm/bin/rvm
rbenv:
chruby:
asdf:
= Ruby =
/Users/xxxxxx/.rvm/rubies/ruby-2.4.1/bin/ruby
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin18]
= Homebrew =
Homebrew 3.6.1
Homebrew/homebrew-core (git revision 379fea565f2; last commit 2022-09-14)
Homebrew/homebrew-cask (git revision c353f213b2; last commit 2022-09-14)
adwaita-icon-theme, aom, apr, apr-util, argon2, aspell, assimp, atk, atkmm, [email protected], autoconf, automake, awscli, bdw-gc, bmake, boost, boost-build, brotli, c-ares, ca-certificates, cabextract, cairo, cairomm, [email protected], cjson, cloc, cmake, cmocka, cocoapods, codeclimate, composer, coreutils, curl, dav1d, dbus, dfu-util, dnsmasq, docbook, docbook-xsl, docker, double-conversion, dyld-shared-cache-extractor, dylibbundler, elasticsearch-full, [email protected], fastlane, ffmpeg, fftw, flac, fontconfig, freetds, freetype, frei0r, fribidi, gcc, gd, gdbm, gdk-pixbuf, gettext, ghostscript, giflib, gigalixir, glib, glib-networking, glibmm, [email protected], gmp, gnu-getopt, gnutls, go, gobject-introspection, goocanvas, gpredict, graphite2, graphviz, gsettings-desktop-schemas, gsl, gtk+, gtk+3, gtkmm, gts, guile, hamlib, harfbuzz, heroku, heroku-node, hicolor-icon-theme, hunspell, hwloc, icu4c, ideviceinstaller, imagemagick, imath, intltool, isl, jasper, jbig2dec, jemalloc, jpeg, jpeg-xl, json-c, krb5, lame, leptonica, libarchive, libass, libavif, libb2, libbitcoin, libbitcoin-client, libbitcoin-explorer, libbitcoin-network, libbitcoin-protocol, libbluray, libde265, libepoxy, libev, libevent, libffi, libgpg-error, libheif, libidn, libidn2, libimobiledevice, libksba, liblqr, libmetalink, libmng, libmpc, libnghttp2, libogg, libomp, libplist, libpng, libpq, libpqxx, libpsl, libpthread-stubs, libraw, librist, librsvg, libsamplerate, libscrypt, libsigc++, libsigc++@2, libsigsegv, libsndfile, libsodium, libsoup, libsoxr, libssh2, libtasn1, libtiff, libtool, libunistring, libusb, libusb-compat, libusbmuxd, libuv, libvidstab, libvmaf, libvorbis, libvpx, libx11, libxau, libxcb, libxdmcp, libxext, libxml2, libxrender, libyaml, libzip, little-cms, little-cms2, lz4, lzo, m4, macos-term-size, makedepend, mbedtls, md4c, minimodem, minisign, mk-configure, mongosh, mpdecimal, mpfr, mtr, [email protected], netpbm, nettle, nghttp2, nmap, node, node@14, nspr, nss, oniguruma, open-mpi, opencore-amr, openexr, openjdk, openjpeg, openldap, opensearch, [email protected], opus, p11-kit, p7zip, pandoc, pango, pangomm, [email protected], pcre, pcre2, phantomjs, [email protected], pixman, pkg-config, poppler, popt, portaudio, postgresql, postgresql@14, potrace, pulseaudio, python@2, [email protected], [email protected], qrencode, qt, qt@5, rav1e, readline, redis, rsync, rtmpdump, rubberband, ruby, [email protected], [email protected], rust, sdl2, shared-mime-info, six, snap, snappy, speex, speexdsp, sqlite, squashfs, srt, tcl-tk, telnet, terminal-notifier, tesseract, theora, tidy-html5, tor, unbound, unixodbc, unrar, unzip, [email protected], vala, webp, wget, x264, x265, xmlto, xorgproto, xvid, xxhash, xz, yarn, zeromq, zimg, zlib, zstd, chirp, chromedriver, fastlane, java8, ngrok, xcodes
Hey guys, I'm on High Sierra running RubyMotion 5.8 and I am hitting this error on build:
Simulate ./wds-ios/build/iPhoneSimulator-8.0-Development/WDS App.app (main)>
2018-05-02 12:03:08.783 WDS App[62727:63049444] vendor/bundle/ruby/2.4.0/gems/motion-support-1.2.0/motion/core_ext/ns_dictionary.rb:11:in `<main>':
undefined method `delegate' for NSDictionary:Class (NoMethodError) from vendor/bundle/ruby/2.4.0/gems/motion-support-1.2.0/motion/core_ext/ns_dictionary.rb:11:in `<main>'
2018-05-02 12:03:08.795 WDS App[62727:63049444]*** Terminating app due to uncaught exception 'NoMethodError', reason: 'vendor/bundle/ruby/2.4.0/gems/motion-support-1.2.0/motion/core_ext/ns_dictionary.rb:11:in `<main>': undefined method `delegate' for NSDictionary:Class (NoMethodError) from vendor/bundle/ruby/2.4.0/gems/motion-support-1.2.0/motion/core_ext/ns_dictionary.rb:11:in `<main>'
Any thoughts? Thanks!
I'm using motion-support with ProMotion. ProMotion requires
detect_dependencies = true
while motion-support requires
detect_dependencies = false
I'm confused. Any idea to this problem?
After installing the gem I am now getting this error. It looks like it is looking for the SDK 6.1, but I am using 7.0
Using @wndxlori PR #42 to resolve relative path issues, I get the following error when requiring motion-support/core_ext on a brand new project:
03-31 17:52:38.106 2099 2099 E com/yourcompany/hello: Exception raised: NoMethodError: undefined method method_defined?' for Class:Class 03-31 17:52:38.108 2099 2099 E com/yourcompany/hello: from /Users/davetrollope/.gems/bundler/gems/motion-support-3fedd0920d88/motion/hash_with_indifferent_acc 03-31 17:52:38.108 2099 2099 E com/yourcompany/hello: from /Users/davetrollope/.gems/bundler/gems/motion-support-3fedd0920d88/motion/hash_with_indifferent_acc 03-31 17:52:38.110 2099 2099 E com/yourcompany/hello: Uncaught exception when initializing
hash_with_indifferent_access.rb.x86.o' scope -- aborting
--------- beginning of crash
03-31 17:52:38.114 2099 2099 E AndroidRuntime: FATAL EXCEPTION: main
03-31 17:52:38.114 2099 2099 E AndroidRuntime: Process: com.yourcompany.hello, PID: 2099
03-31 17:52:38.114 2099 2099 E AndroidRuntime: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/com.yourcompany.hello-uxty06nv7-kMBV1yHlleMg==/lib/x86/libpayload.so"
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1657)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at com.yourcompany.hello.MainActivity.(MainActivity.java:10)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at java.lang.Class.newInstance(Native Method)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6541)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
03-31 17:52:38.114 2099 2099 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Steps:
create a new project: motion create --template=android Hello
Add to Gemfile: gem 'motion-support', git: 'https://github.com/wndxlori/motion-support.git', ref: '3fedd09', require: false
Add to Rakefile: require 'motion-support/core_ext'
Then run bundle and bundle exec rake
motion --version: 5.17 on mohave
Hello,
I have updated ruby motion version to v5 and using xcode9.2(ios11) and getting undefined method
+' for class Date' (NameError)
/.rvm/gems/ruby-2.3.1/gems/motion-support-1.1.0/motion/core_ext/date/calculation: undefined method
+' for class Date' (NameError)
While 2 days ago same was working absolutely fine with xcode8.3(ios10). and before updating rubymotion version.
Thanks
See issue below where today is greater than tomorrow
(main)> today = Date.today
=> Sat, 04 Jan 2014
(main)> tomorrow = Date.today + 1.day
=> Sun, 05 Jan 2014
(main)> today > tomorrow
=> true
(main)> today.to_time.to_i > tomorrow.to_time.to_i
=> true
I am using the following version - motion-support (0.2.6)
Gemfile:
gem "motion-support", require: false
Rakefile:
require "motion-support/core_ext/time"
Looks like all of the string extensions are done to String
, but I think it should be done to NSString
?
A lot of times when objects are deserialized via Cocoa (i.e. NSUserDefaults
), strings are made as instance sof NSString
, which means these methods won't be found.
ERROR: undefined method `mattr_writer' for MotionSupport:Class
motion-support (1.2.0)
rubymotion 5.16
mac os 10.14
Hello,
Is there any chance of this gem get Android support?
Or any alternatives for "cattr_accessor", for example?
Thanks,
I'm noticing things are not up to date in 0.1 rubygem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.