Giter VIP home page Giter VIP logo

bubblewrap's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bubblewrap's Issues

Running a spec separately

What's the right way to run a single spec file?

I wanted to add some tests for kvo.rb, so thinking it would be quicker to be able to run just kvo_spec, I added under the :spec namespace the following:
task :kvo do
sh "bacon #{Dir.glob("spec/motion/core/kvo_spec.rb")}"
end

when I run this with 'rake spec:kvo', I get:
./spec/motion/core/kvo_spec.rb:6: uninitialized constant KvoExample::BW (NameError)

This sounds like when the spec is run, kvo.rb hasn't been properly included. But as I'm not too familiar with rake I'm puzzled how to set up my task so the bacon runtime is aware ov kvo.rb.

wrap UITableView for simple use cases

In most cases, developers use a UITableView to read/write local data.
The wrapper should provide a simple interface including datasource ( using App::Persistence) and an automated way to read/write/update/delete data.

Without thinking too much about it, I think that we could provide a data source class that implements all the required methods and can be easily subclassed for customization. Then we could create a controller that takes care of the basic delegates and connects to the data source.

Another option would be to provide a subclass of UITableViewController with data source and delegates.

BubbleWrap not work well with other gems

it seems BubbleWrap will overwrite app.files which cause following issue:

  • other gems try to add themself via app.files += some_files will not work
  • project using custom load path via app.files += Dir.glob('lib/**/*.rb')

App::Persistence behavior with nested attributes

Hi,
I stumbled upon some unexpected behavior using App::Persistence. It goes something like this:

(main)> App::Persistence[:test] = {a:1,b:2}
=> {:a=>1, :b=>2}
(main)> App::Persistence[:test][:c]=3
2012-07-11 20:04:43.777 my-app[11064:15203] can't modify frozen/immutable hash (RuntimeError)
=> #<RuntimeError: can't modify frozen/immutable hash>
(main)> exit
[rubymotion][~/Documents/web/my-app/rubymotion] rake
     Build ./build/iPhoneSimulator-5.1-Development
     ...
(main)> App::Persistence[:test]
=> {"a"=>1, "b"=>2}
(main)> App::Persistence[:test][:c]=3
=> 3
(main)> App::Persistence[:test]
=> {"a"=>1, "b"=>2, "c"=>3}
(main)> exit
[rubymotion][~/Documents/web/my-app/rubymotion] rake
     Build ./build/iPhoneSimulator-5.1-Development
     ...
(main)> App::Persistence[:test]
=> {"a"=>1, "b"=>2}

The middle case puzzled me for a bit as to why it wasn't returned in step 3, but I see now that the assignment of :c actually failed, but it appears as if it succeeded. I'm not sure if there is a way it could be more clear that this isn't possible (as in the first case).

Or... even better if there was a way to achieve this type of direct assignment of nested attributes. It would save some trouble from having to get the existing hash, set the nested attributes, and then persist.

Thoughts?

Location

Hi,

Trying to use location described in Readme however it doesn't work (can't find the class), I can see it in the files, but not in the bubble-wrap.io documentation.

What's the status of bubble-wrap/location plz ?

How to run the tests?

rake spec crashes with:

2012-05-16 22:13:32.873 MotionLibTestSuite[64387:f803] *** Assertion failure in int UIApplicationMain(int, char **, NSString *, NSString *)(), /SourceCache/UIKit_Sim/UIKit-1914.84/UIApplication.m:1765
2012-05-16 22:13:32.877 MotionLibTestSuite[64387:f803] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to instantiate the UIApplication delegate instance. No class named TestSuiteDelegate is loaded.'
*** First throw call stack:
(0x1616022 0x25ccd6 0x15bea48 0xf2b336 0x594569 0x243c 0x2235)
terminate called throwing an exception*** simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 "The simulated application quit." UserInfo=0x100517550 {NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=-1}
rake aborted!
Command failed with status (1): [DYLD_FRAMEWORK_PATH="/Applications/Xcode.a...]

Tasks: TOP => simulator
(See full trace by running task with --trace)

Using credentials with HTTP module

Why is this line commented in HTTP module? Is there a bug or something?

# new_request.setValue(@credentials.inspect, forHTTPHeaderField:'Authorization') # disabled while we figure this one out

BW shortcut not loaded

If you don't require core (ex just require 'bubble-wrap/http'), the BW shorthand isn't included:

(main)> BW
2012-06-27 23:09:28.272 Test[6175:f803] uninitialized constant BW (NameError)
=> #<NameError: uninitialized constant BW>

If you run that while requiring core it works fine.

I see BW = BubbleWrap in loader.rb, which is required in bubble-wrap/http.rb, but I don't know why it's not loading.

Split up into multiple gems

This gem is already feeling ridiculously crowded. Just scroll down the readme. There's a RSS parser!? What's next, email?

Here's what I suggest:

  1. Keep a "core" gem that is JUST App, Device, HTTP
  2. Extract the following parts to gems:
  • RSS
  • JSON
  • Camera
  • UI*
  • Reactor
  • KVO
  1. Stop allowing anyone to push in this kind of stuff into BW's core. If it doesn't follow under App, Device, or HTTP, just create a plugin. We can get a list going of plugins used and apps using them too.

This also creates a nice set of gem examples for how to build on top of BW. Thoughts?

HTTP fails in 'rake spec'

You can find the code to reproduce this here: https://github.com/franzen/rubymotion-spec

describe "http request" do
  it "should get front page" do
    resp = {}
    BubbleWrap::HTTP.get('http://www.rubymotion.com/') do |r|
      r.status_code.should.equal 200
      resp[:ok] = true
    end

    wait 2.0 do
      resp[:ok].should.equal true
    end
  end

  it "should get help" do
    resp = {}
    BubbleWrap::HTTP.get('http://www.rubymotion.com/getting-started/') do |r|
      r.status_code.should.equal 200
      resp[:ok] = true
    end

    wait 2.0 do
      resp[:ok].should.equal true
    end
  end
end
rake spec
     Build ./build/iPhoneSimulator-5.1-Development
   Compile ./spec/test1.rb
   Compile ./spec/test2.rb
      Link ./build/iPhoneSimulator-5.1-Development/rubymotion-spec_spec.app/rubymotion-spec
    Create ./build/iPhoneSimulator-5.1-Development/rubymotion-spec_spec.dSYM
  Simulate ./build/iPhoneSimulator-5.1-Development/rubymotion-spec_spec.app
http request
  - should get front page2012-07-10 15:11:56.524 rubymotion-spec[29179:10103] http.rb:260:in `call_delegator_with_response': undefined method `[]=' for false:FalseClass (NoMethodError)
    from http.rb:216:in `connectionDidFinishLoading:'
2012-07-10 15:11:56.526 rubymotion-spec[29179:10103] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'http.rb:260:in `call_delegator_with_response': undefined method `[]=' for false:FalseClass (NoMethodError)
    from http.rb:216:in `connectionDidFinishLoading:'
'
*** First throw call stack:
(0x944022 0x2d4cd6 0x16a044 0x369e 0x2f25)
terminate called throwing an exception

Avoid Kernel methods

I would be weary of adding Kernel methods as they pollute all methods, e.g. do we really need Hash#ipad? Module methods would be a good alternative, e.g. Screen.orientation, though you have to figure out the appropriate module --or make your own.

Can't run specs anymore

rake spec --trace                                                                                                                               
(in /Users/mneorr/Workspace/Repositories/BubbleWrap)
rake aborted!
cannot load such file -- bubble-wrap/ext
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/mneorr/Workspace/Repositories/BubbleWrap/lib/bubble-wrap.rb:6:in `<top (required)>'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/mneorr/Workspace/Repositories/BubbleWrap/Rakefile:4:in `<top (required)>'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/Users/mneorr/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/Users/mneorr/.rbenv/versions/1.9.3-p0/bin/rake:32:in `<main>'

cannot load such file -- bubble-wrap/rss_parser

I'm trying to use BubbleWrap's RSS parser but I can't seem to access it.

I've created a vanilla Rubymotion app and tried to require bubble-wrap/rss_parser in my project - no luck

The error is: cannot load such file -- bubble-wrap/rss_parser

When I require 'bubble-wrap' the app compiles OK but I can't call BW::RSSParser.new(myFeed) as the RSSParser constant is not found... am I doing something wrong?

`rake spec` broken

New RubyMotion update changed which files are included when running rake spec[1].

I've hacked it for my own use by doing this in ./Rakefile, but haven't read enough on what the proper procedure is:

Motion::Project::App.setup do |app|
  spec_files = app.spec_files + Dir.glob(File.join(app.specs_dir, '**', '*.rb'))
  app.instance_variable_set("@spec_files", spec_files.uniq!)
end

[1] HipByte/RubyMotion@5a37c3d#L3R324

Payload data that has nested hashes

When passing a payload that contains a nested hash to an HTTP post call, the web service (Rails-based) sees the parameter as one key with the entire nested hash as the value in string format. This makes sense given the following code:

unless @payload.nil?
  @payload = @payload.map{|k,v| "#{k}=#{v}"}.join('&') if @payload.is_a?(Hash)
  if @method == "GET"
    url_string = "#{url_string}?#{@payload}"
  end
end

Unfortunately, I need to be able to pass a payload that may include any number of nested hashes. I'm not sure how to best alter the code to handle this case.

add a HACKING.md file

Hey James, could you please start a hacking.md file explaining the structure of the project and how to add new wrappers and tests?
Since you are the one who reorganized the structure, I think it would be best if you start this file and we can all contribute.

Current Gem is not Current with Readme / Repo

Thought I would point this out as new users (and users who want to use new functionality) will most definitely have trouble installing if they try to follow the install directions in the Readme: gem install bubble-wrap

They'll be missing most of the new functionality such as RSS, etc, and will run into errors unless they clone the current repo and replace the gem in Library with these files. (This currently goes for whats on bubblewrap.io --none of the new documentation is current with the Gem.)

I think it's time put push a new version out, or at least point out specific instructions about how to use what is currently outlined, no?

BW = BubbleWrap defined twice

BW is defined twice in lib/bubble-wrap/loader.rb:23 and motion/core.rb:24 causing warning message: warning: already initialized constant BW

specs are failing

Bacon::Error: [123, [1, 2, 3], "bar", "baz", {"a"=>1, "b"=>2}].==([123, [1, 2, 3], "bar", "baz", {:a=>1, :b=>2}]) failed
    spec.rb:526:in `satisfy:': generating a JSON string from an object - should encode and decode and object losslessly

Escaping LFs

I'm not sure if this was a typo, or it has to be like this:
When parsing the HTTP headers, this was here from the beginning:

hash.each{|k,v| escaped_hash[k] = v.gsub("\n", '\\n') }

What I'm asking about is, shouldn't they be escaped using \r\n ?

hash.each{|k,v| escaped_hash[k] = v.gsub("\n", '\r\n') }

Should we call the delegator in connection:didFailWithError?

Looking for thoughts on adding in code to call the delegator if one exists when the http request fails. Use case is when showing an activity indicator while a request is processing, and dismissing it in the block. The block never gets triggered if the request fails. It would probably be a good idea to still call the block and pass in something if the request fails.

I don't mind taking a stab at the code if this sounds good.

better test coverage

We have a decent test coverage, but we need to improve it before releasing 1.0

can't require 'bubble-wrap/core' in a project

require 'bubble-wrap/core'
$ rake --trace
rake aborted!
uninitialized constant BubbleWrap
/Users/mattetti/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
/Users/mattetti/.rvm/gems/ruby-1.9.3-p125/gems/bubble-wrap-0.4.0/lib/bubble-wrap/core.rb:1:in `<top (required)>'
/Users/mattetti/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/Users/mattetti/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/Users/mattetti/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'

File dependency real world tests

It would be awesome if we could add a sample app that just uses Bubblewrap,
with some other gems / resources, etc.

Maybe we could also write an automated test for that.
It should launch the app, and check the status code (if it broke, it shouldn't be zero).

Query.generate_get_params should support arrays

Currently, generate_get_params encodes arrays as a string instead of encoding each element individually.

I don't have test code for this, so not issuing a pull request, but here is how I fixed the code to properly handle arrays in the param hash:

      def generate_get_params(payload, prefix=nil)
        list = []
        payload.each do |k,v|
          if v.is_a?(Hash)
            new_prefix = prefix ? "#{prefix}[#{k.to_s}]" : k.to_s
            param = generate_get_params(v, new_prefix)
            list << param
          elsif v.is_a?(Array)
            v.each do |val|
              param = prefix ? "#{prefix}[#{k}][]=#{val}" : "#{k}[]=#{val}"
              list << param
            end
          else
            param = prefix ? "#{prefix}[#{k}]=#{v}" : "#{k}=#{v}"
            list << param
          end
        end
        return list.flatten
      end

The UIGestureRecognizer should be passed to the 'when' blocks

For example, I have a pan gesture that needs to know the translation, which is available on the gesture recognizer object. I would like to do this:

view.whenPanned do |gesture|
  translation = gesture.translationInView(@otherView)
  # ...
end

But 'gesture' is not passed to the block. (It's a crazy floating point number, probably from a chunk of memory.)

uninitialized constant BubbleWrap::Location

A brand new, clean project including bubble-wrap (1.1.0) using bundler w/ this app_delegate:

class AppDelegate
  def application(application, didFinishLaunchingWithOptions:launchOptions)
    BW::Location.get do |result|
      p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}"
      p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}"
    end
    true
  end
end

Results with: uninitialized constant BubbleWrap::Location

Failing test

Here's the output of rake test on a clean checkout of BubbleWrap:

UIButton
  - should support the 'when' event handler

Bacon::Error: Fixnum.==(NSNotification) failed
    spec.rb:526:in `satisfy:': NSNotificationCenter - add observer
    spec.rb:540:in `method_missing:'
    ns_notification_center.rb:21:in `post:'
    spec.rb:461:in `change?'
    spec.rb:540:in `block in method_missing:'
    spec.rb:518:in `satisfy:'
    spec.rb:540:in `method_missing:'
    spec.rb:156:in `block in run_spec_block'
     4:in `execute_block'
    spec.rb:156:in `run_spec_block'
    spec.rb:171:in `run'

16 specifications (26 requirements), 1 failures, 0 errors

gem packaging breaks

if you follow the read me with siuying's packaging, it breaks the install. the bubblewrap directory no longer appears under the vendor director.

BW.require not working with relative path

I'm trying to have BubbleWrap load in the teacup library using BW.require. It works when I supply an absolute path to the directory where teacup resides, but not with a relative one.

So

BW.require '/Users/bsvec/<a few more dirs>/vendor/teacup/lib/**/*.rb' 

works, but

BW.require './vendor/teacup/lib/**/*.rb' 

does not.

Notification Center helper block do not pass the notification object

In NSNotificationCenter observe helper, the block should pass the notification as parameter of the block, but currently it is not.

As referred in spec: mattetti@dba25c6

Bacon::Error: Fixnum.==(NSNotification) failed
    spec.rb:526:in `satisfy:': NSNotificationCenter - add observer
    spec.rb:540:in `method_missing:'
    ns_notification_center.rb:21:in `post:'
    spec.rb:461:in `change?'
    spec.rb:540:in `block in method_missing:'
    spec.rb:518:in `satisfy:'
    spec.rb:540:in `method_missing:'
    spec.rb:156:in `block in run_spec_block'
     4:in `execute_block'
    spec.rb:156:in `run_spec_block'
    spec.rb:171:in `run'

no idea why a fixnum here...

test suite doesn't seem to run anymore

i'm trying to run the test suite on iOS 5.1 with RubyMotion 1.15 and here is what I'm getting:
Terminating since there is no system event server. (Run the EventPump or pass the argument "-RegisterForSystemEvents" if you want to run without SpringBoard.

Can someone confirm the problem and does anyone have a clue what's going on and why SpringBoard doesn't start? (looks like our delegate isn't used anymore)

Add more sample projects

As bubble-wrap grow, it seems its time to create sample projects that demo each features. This help new comers easier to learn and use the project.

I see there are two way to do it:

  • one large app (like Three20 TTCatalog) that demo many different features
  • many small apps that demo one or few related features at a time

To begin I have added a sample on gesture helpers. What do you think?

Camera wrapper api

Opening a ticket following a post on the mailing list.

"The API might have to be slightly more complicated than that, but I think that we can have something not too far such as:

Camera.picture(options={}) do |result|
end

Where we would wrap a UIImagePickerController modal and provide the information in the result object (including the image data if available)."

I don't know enough about iOS to provide much more here, beyond the fact that I think this would be very useful and appreciate.

Add KVO support, like the NSNotification center

It would be nice to have the wrapper for Key-Value observing

[person addObserver:observer forKeyPath:@"surname" options:NSKeyValueObservingOptionsNew context:nil];

and the delegate method

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {

}

I guess it could be done the similar way as the NSNotifications are handled with blocks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.