Missing constant in BubbleWrap in rubymotion 3.8 - rubymotion

I got #<NameError: uninitialized constant BubbleWrap::HTTP>,
And I have no idea what's wrong with it
There is no HTTP method in BW object.
BW.constants.grep(/htt/mi)
=> [:MCHTTPRequestor, :NSHTTPURLResponseInternal, :NSHTTPURLResponse, :MCGlobalHTTPProxyPayload, :NSHTTPURLRequestParameters, :NSHTTPCookieStorage, :MCHTTPTransaction, :NSHTTPCookieStorageInternal, :NSHTTPCookie, :CILightTunnel]
(main)> BW::HTTP
2015-04-14 13:27:51.673 hello[80662:629086] uninitialized constant BubbleWrap::HTTP (NameError)
=> #<NameError: uninitialized constant BubbleWrap::HTTP>
% motion --version
3.8
- bubble-wrap (1.8.0)

The HTTP library has been deprecated, but you can find it at github.com/rubymotion/BubbleWrap-HTTP (gem "bubble-wrap-http")

Related

Mass assignment in Rails 5

I tried to upgrade Mindapp Gem from Rails 4 to Rails 5. There are a lots of codes like below need to be fixed because Rails 5.1 no longer support mass assignment to_bson directly.
Mindapp::Xmain.create :service=>service,
:start=>Time.now,
:name=>service.name,
:ip=> get_ip,
:status=>'I', # init
:user=>current_user,
:xvars=> {
:service_id=>service.id, :p=>params,
:id=>params[:id],
:user_id=>current_user.try(:id),
:custom_controller=>custom_controller,
:host=>request.host,
:referer=>request.env['HTTP_REFERER']
}
Then error:
DEPRECATION WARNING: Method to_bson is deprecated and will be removed in Rails 5.1, as `ActionController::Parameters` no longer inherits from hash. Using this deprecated behavior exposes potential security problems. If you continue to use this method you may be creating a security vulnerability in your app that can be exploited. Instead, consider using one of these documented methods which are not deprecated: http://api.rubyonrails.org/v5.0.2/classes/ActionController/Parameters.html
To comply with Rails 5.1 from this WARNING: I put params (without understand really) to:
Mindapp::Xmain.create(xmain_params)
def xmain_params
params.permit(
:service=>service,
:start=>Time.now,
:name=>service.name,
:ip=> get_ip,
:status=>'I', # init
:user=>current_user,
:xvars=> {
:service_id=>service.id, :p=>params,
:id=>params[:id],
:user_id=>current_user.try(:id),
:custom_controller=>custom_controller,
:host=>request.host,
:referer=>request.env['HTTP_REFERER']
}
)
end
Problem: It's not create as supposed to do.
This code (before modified) work in rails 4 but Warning in 5.0 and Now not work in Rails 5.1 all using Ruby 2.4.1.
What should I do/Thanks
And when tried
Mindapp::Xmain.create :service=>params.permit(service),
:start=>params.permit(Time.now),
:name=>params.permit(service.name),
:ip=>params.permit(get_ip),
:status=>params.permit('I'), # init
:user=>params.permit(current_user),
:xvars=> params.permit({
:service_id=>service.id, :p=>params,
:id=>params[:id],
:user_id=>current_user.try(:id),
:custom_controller=>custom_controller,
:host=>request.host,
:referer=>request.env['HTTP_REFERER']
})
Errors:
Mongoid::Errors::InvalidValue -
message:
Value of type ActionController::Parameters cannot be written to a field of type Hash
summary:
Tried to set a value of type ActionController::Parameters to a field of type Hash
resolution:
Verify if the value to be set correspond to field definition:
And try using params.
Mindapp::Xmain.create :service=>params.service,
:start=>params.Time.now,
:name=>params.service.name,
:ip=> params.get_ip,
:status=>params('I'), # init
:user=>params.current_user,
:xvars=> {
:service_id=>params.service.id, :p=>params,
:id=>params[:id],
:user_id=>params.current_user.try(:id),
:custom_controller=>params.custom_controller,
:host=>params.request.host,
:referer=>params.request.env['HTTP_REFERER']
}
Errors:
NoMethodError - undefined method `service' for #<ActionController::Parameters:0x007ff6b07158f0>:
actionpack (5.0.2) lib/action_controller/metal/strong_parameters.rb:646:in `method_missing'
app/controllers/mindapp_controller.rb:384:in `create_xmain'
The issue is :p=>params. I'm assuming params is a params object from the request. Under Rails 5.1, it will no longer support standard hash functions such as to_bson, which mindapp library appears to be using (or maybe one of its dependent libraries is using it).
A simple fix is probably to replace it with :p=>params.to_unsafe_hash or for a safer solution, :p=>params.permit(:foo, :bar) (whatever params should be used, these should possibly be checked/cleansed first).

Less::ParseError: Cannot call method 'split' of undefined - Rails 4.0

Note: ruby 2.0.0p481, Rails 4.0.13
Execute : RAILS_ENV=development bundle exec rake assets:precompile
Trace:
DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped.
(called from at
/host_share/project/config/application.rb:9) rake aborted!
Less::ParseError: Cannot call method 'split' of undefined (in
/host_share/project/app/assets/stylesheets/main.css.less) at
/home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/less-2.6.0/lib/less/js/lib/less/parser.js:604:31
/home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/less-2.6.0/lib/less/parser.rb:100:in
`block in to_css'
I dont know whats wrong ... please help me..
The error is quite clear here: In your app/assets/stylesheets/main.css.less you are doing a .split() operation on an undefined object, hence this is raising an error. Go in that file, search for the .split() method and check why the object you are calling this method on is not defined.
Go to your app/assets/stylesheets/main.css.less search for split. Remove split from the file and inspect the object you're calling split on to see if it's not nill

Poco::JSON::Object::Ptr set function not working on 1.6.1

I have a piece of code as follows:
Poco::JSON::Parser a;
Poco::Dynamic::Var v = a.parse(str); //str is a json string
Poco::JSON::Object::Ptr p = v.extract<Poco::JSON::Object::Ptr>();
p->set("key","value");
in Poco v 1.6.0 this works completely fine, and the content of v is changed according to the set function, yet in 1.6.1 it's not working anymore, is there a difference on the set function call between 1.6.0 and 1.6.1? Or what could be the potential problem? (My current observation is that in 1.6.1 the set line is not executed at all.)
Thank you for reading this.
Note: If there's any work around that can achieve the same effect but doesn't have to use the set function I'll be appreciated.
So I find out the answer today and decided to share with people.
Answer: the set() function Poco::JSON::Object is different in 1.6.0 and 1.6.1. In 1.6.1 it will not function if there's already value assigned to that give key, while in 1.6.0 it will just overwrite it. A very simple work around for 1.6.1 is you can first do remove() function then do the set() function, then it will work the same. But yes, the implementation is different and can be checked in the source code of the Poco library.

printing mathematical signs not enabled

I get an error when I try to call the init_printing function from scipy
init_printing(use_latex=True)
TypeError: init_printing() got an unexpected keyword argument 'use_latex'
How do I correctly enable latex?
help(init_printing)
Help on function init_printing in module sympy.interactive.printing:
init_printing(pretty_print=True, order=None, use_unicode=None, wrap_line=None, no_global=False, ip=None)
Initializes pretty-printer depending on the environment.
You probably aren't using a new enough version of SymPy. Make sure you are using 0.7.4.1, the latest.

RubyMotion with CoreAnimation constant issue

I'm trying to use some CATransition constants in my rubymotion app thusly:
transition = CATransition.animation
transition.duration = 0.4
transition.type = kCATransitionMoveIn
transition.subtype = kCATransitionFromBottom
But am getting undefined local variable or method `kCATransitionMoveIn'. I've added quartzcore to frameworks in my rake file:
app.frameworks += ['CoreLocation', 'MapKit', 'QuartzCore']
Does anyone know why I can't access this constant? Thanks.
Constants in Ruby can't start with a lowercase letter. You'll want to use KCATransitionMoveIn and KCATransitionFromBottom.