volley_motion 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/lib/volley_motion/error_listener.rb +12 -0
- data/lib/volley_motion/json_array_request.rb +9 -0
- data/lib/volley_motion/request_listener.rb +16 -0
- data/lib/volley_motion/request_queue.rb +9 -0
- data/lib/volley_motion/version.rb +3 -0
- data/lib/volley_motion.rb +36 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a58b5a1055617ed3d5691184509d5529bbbf47d
|
4
|
+
data.tar.gz: 103ed323306db5ec1947c6f0cf2f89ccbfa6597b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d57b49e97b13d5cf2a2365867f2f15e457d755bd45b8486f66963df50cb9cee1901e5a770e2a6531fd84a2460947628f36c21cfa52a948e75eb9eb0f97e27106
|
7
|
+
data.tar.gz: 89b7a97cc30708ad0b47b6e6bf273e4851395e350d5aa0b43aa839d5119e50d72ae8fb52222ad501ef8011d196c5a8ffb0e9c193f34374903af521b1c2620c82
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 TigerWolf
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# VolleyMotion
|
2
|
+
|
3
|
+
A gem to add the Volley Library to your RubyMotion Android Project.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'volley_motion'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install volley_motion
|
20
|
+
|
21
|
+
## Setup
|
22
|
+
|
23
|
+
Inside a RubyMotion Android project
|
24
|
+
|
25
|
+
`motion create my_project --template=android`
|
26
|
+
|
27
|
+
1. Edit the `Rakefile` of your RubyMotion project and add the following require
|
28
|
+
lines:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'rubygems'
|
32
|
+
require 'volley_motion'
|
33
|
+
```
|
34
|
+
|
35
|
+
2. Ensure you have the internet permission in your rake file
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
app.permissions = [:internet]
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
Inside of your activity create a request like the following example:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
def fetch_list
|
47
|
+
url = "http://example.com/api/list"
|
48
|
+
success_listener = VolleyMotion::RequestListener.new(self, List)
|
49
|
+
error_listener = VolleyMotion::ErrorListener.new
|
50
|
+
get = VolleyMotion::JsonArrayRequest.build(url, success_listener, error_listener)
|
51
|
+
VolleyMotion::RequestQueue.build(self).add(get)
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
Create a model (List):
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
class List
|
59
|
+
attr_reader :list
|
60
|
+
|
61
|
+
def initialize(json)
|
62
|
+
# read your JSON response here for example:
|
63
|
+
for i in 0..(json.length-1)
|
64
|
+
object = json.get(i)
|
65
|
+
# Your code here
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
Also add this method to your activity:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
def update_display(lists)
|
75
|
+
# do something with your object here like adding to a ListView
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
See https://github.com/TigerWolf/volley_example for a working example.
|
80
|
+
|
81
|
+
## Contributing
|
82
|
+
|
83
|
+
1. Fork it ( https://github.com/TigerWolf/volley_motion/fork )
|
84
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
85
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
87
|
+
5. Create a new Pull Request
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VolleyMotion
|
2
|
+
class RequestListener
|
3
|
+
attr_accessor :activity, :responder
|
4
|
+
|
5
|
+
def initialize(activity, responder)
|
6
|
+
@activity = activity
|
7
|
+
@responder = responder
|
8
|
+
end
|
9
|
+
|
10
|
+
def onResponse(json)
|
11
|
+
responder = @responder.new(json)
|
12
|
+
@activity.update_display(responder)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "volley_motion/version"
|
2
|
+
|
3
|
+
module VolleyMotion
|
4
|
+
|
5
|
+
class Methods
|
6
|
+
DEPRECATED_GET_OR_POST = -1
|
7
|
+
GET = 0
|
8
|
+
POST = 1
|
9
|
+
PUT = 2
|
10
|
+
DELETE = 3
|
11
|
+
HEAD = 4
|
12
|
+
OPTIONS = 5
|
13
|
+
TRACE = 6
|
14
|
+
PATCH = 7
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
unless defined?(Motion::Project::Config)
|
20
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
21
|
+
end
|
22
|
+
|
23
|
+
$:.unshift("./volley_motion/")
|
24
|
+
require 'volley_motion/request_listener'
|
25
|
+
require 'volley_motion/request_queue'
|
26
|
+
require 'volley_motion/error_listener'
|
27
|
+
require 'volley_motion/json_array_request'
|
28
|
+
require 'volley_motion/version'
|
29
|
+
|
30
|
+
Motion::Project::App.setup do |app|
|
31
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'volley_motion/**/*.rb')).each do |file|
|
32
|
+
app.files << file
|
33
|
+
end
|
34
|
+
|
35
|
+
app.vendor_project jar: File.join(File.dirname(__FILE__), '../vendor/volley/volley-1.0.10.jar')
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: volley_motion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TigerWolf
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A gem to add the Volley Library to your RubyMotion Android Project.
|
42
|
+
email:
|
43
|
+
- hiddentiger@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE.txt
|
49
|
+
- README.md
|
50
|
+
- lib/volley_motion.rb
|
51
|
+
- lib/volley_motion/error_listener.rb
|
52
|
+
- lib/volley_motion/json_array_request.rb
|
53
|
+
- lib/volley_motion/request_listener.rb
|
54
|
+
- lib/volley_motion/request_queue.rb
|
55
|
+
- lib/volley_motion/version.rb
|
56
|
+
homepage: https://github.com/TigerWolf/volley_motion
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Volley Android Library for RubyMotion
|
80
|
+
test_files: []
|
81
|
+
has_rdoc:
|