transponder 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/transponder/engine.rb +6 -0
- data/lib/transponder/version.rb +3 -0
- data/lib/transponder.rb +5 -0
- data/transponder.gemspec +19 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/error.coffee +12 -0
- data/vendor/assets/javascripts/init.coffee +11 -0
- data/vendor/assets/javascripts/presenter.coffee +64 -0
- data/vendor/assets/javascripts/request.coffee +13 -0
- data/vendor/assets/javascripts/service.coffee +0 -0
- data/vendor/assets/javascripts/setup.coffee +1 -0
- data/vendor/assets/javascripts/transponder.coffee +11 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 910bf6b26de20271d2a806365fb9918eacf8ca30
|
4
|
+
data.tar.gz: aa915a656b029f04d20b2f4f2f281e7f7ab2f74c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a63746faa9870c15b830eb5449a4efdb0e6d08bf7257eca8405683c9c22274d36740a82bcf7c85ac5232e5a8f93b0356e266c2e8d4ee4774904316808bcf75c
|
7
|
+
data.tar.gz: 8e4df1e5e93f02c6bf3d64113d5c21a13590d2020e2e032fde6d34e5e561f63279a3f4e555d332422aa7173495836c1bfe1a61de3148cbc8b7ca02a55f3c5158
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Zack Siri
|
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,29 @@
|
|
1
|
+
# Transponder
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'transponder'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install transponder
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/transponder.rb
ADDED
data/transponder.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'transponder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "transponder"
|
8
|
+
gem.version = Transponder::VERSION
|
9
|
+
gem.authors = ["Zack Siri"]
|
10
|
+
gem.email = ["zack@artellectual.com"]
|
11
|
+
gem.description = %q{A Cleaner way of working with rails frontend code}
|
12
|
+
gem.summary = %q{This library gives you more control over rails ujs, it compliments turbolinks, and any other library you use. It is opinionated and helps you clean up your client side code in many ways.}
|
13
|
+
gem.homepage = "http://github.com/zacksiri/transponder"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Transponder.Error
|
2
|
+
response: null
|
3
|
+
|
4
|
+
constructor: ->
|
5
|
+
doc = $(document)
|
6
|
+
doc.ajaxError(@handleError)
|
7
|
+
|
8
|
+
handleError: (event, xhr, settings, error) ->
|
9
|
+
unless xhr.responseText is ""
|
10
|
+
@response = JSON.parse(xhr.responseText)
|
11
|
+
eventType = Transponder.buildEvent ['ujs', @response.namespace, @response.controller, @response.action]
|
12
|
+
$(document).trigger(eventType, @response)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Transponder.Presenter
|
2
|
+
defaultActions: ['new', 'index', 'show', 'update', 'edit', 'create', 'destroy']
|
3
|
+
params: {}
|
4
|
+
|
5
|
+
presenterName: null
|
6
|
+
nameSpace: null
|
7
|
+
modelName: null
|
8
|
+
|
9
|
+
element: null
|
10
|
+
response: null
|
11
|
+
|
12
|
+
constructor: (options = {}) ->
|
13
|
+
options.presenterName = @presenterName unless options.presenterName
|
14
|
+
options.nameSpace = @nameSpace unless options.nameSpace
|
15
|
+
options.actions = @defaultActions unless options.actions
|
16
|
+
|
17
|
+
doc = $(document)
|
18
|
+
events = []
|
19
|
+
for action in options.actions
|
20
|
+
events.push(Transponder.buildEvent(['ujs', options.nameSpace, options.presenterName, action]))
|
21
|
+
doc.on(events.join(' '), @runAction)
|
22
|
+
|
23
|
+
elify: (event, response) ->
|
24
|
+
if @response.errors
|
25
|
+
if @response.id then "##{@modelName}_#{@response.id}" else "#new_#{@modelName}"
|
26
|
+
else
|
27
|
+
"#{event.target.localName}##{event.target.id}"
|
28
|
+
|
29
|
+
beforeFilter: (event, response) ->
|
30
|
+
@response = response
|
31
|
+
@element = @elify(event, response)
|
32
|
+
@params = Transponder.req.objectifyParams()
|
33
|
+
|
34
|
+
runAction: (event, response) =>
|
35
|
+
@beforeFilter(event, response)
|
36
|
+
if @response.errors
|
37
|
+
@errorOut()
|
38
|
+
else
|
39
|
+
@[event.type.split(':').pop()]()
|
40
|
+
@afterFilter(event, response)
|
41
|
+
|
42
|
+
afterFilter: (event, response) ->
|
43
|
+
|
44
|
+
|
45
|
+
triggerEmpty: (eventName) ->
|
46
|
+
console.log "#{eventName} triggered! Override this action in your own controller"
|
47
|
+
|
48
|
+
errorOut: ->
|
49
|
+
console.log "an error has occured!"
|
50
|
+
|
51
|
+
index: ->
|
52
|
+
@triggerEmpty('Index')
|
53
|
+
show: ->
|
54
|
+
@triggerEmpty('Show')
|
55
|
+
new: ->
|
56
|
+
@triggerEmpty('New')
|
57
|
+
edit: ->
|
58
|
+
@triggerEmpty('Edit')
|
59
|
+
update: ->
|
60
|
+
@triggerEmpty('Update')
|
61
|
+
create: ->
|
62
|
+
@triggerEmpty('Create')
|
63
|
+
destroy: ->
|
64
|
+
@triggerEmpty('Destroy')
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Transponder.Request
|
2
|
+
url: ''
|
3
|
+
|
4
|
+
constructor: ->
|
5
|
+
$(document).on 'ajax:beforeSend', (event, xhr, settings) =>
|
6
|
+
@url = ''
|
7
|
+
@url = settings.url
|
8
|
+
|
9
|
+
objectifyParams: ->
|
10
|
+
if @url.split('?').length is 2
|
11
|
+
JSON.parse('{"' + @url.split('?')[1].replace(/&/g, "\",\"").replace(/\=/g,"\":\"") + '"}')
|
12
|
+
else
|
13
|
+
{}
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
window.Transponder = {}
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transponder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zack Siri
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Cleaner way of working with rails frontend code
|
14
|
+
email:
|
15
|
+
- zack@artellectual.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE.txt
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/transponder.rb
|
26
|
+
- lib/transponder/engine.rb
|
27
|
+
- lib/transponder/version.rb
|
28
|
+
- transponder.gemspec
|
29
|
+
- vendor/assets/javascripts/.DS_Store
|
30
|
+
- vendor/assets/javascripts/error.coffee
|
31
|
+
- vendor/assets/javascripts/init.coffee
|
32
|
+
- vendor/assets/javascripts/presenter.coffee
|
33
|
+
- vendor/assets/javascripts/request.coffee
|
34
|
+
- vendor/assets/javascripts/service.coffee
|
35
|
+
- vendor/assets/javascripts/setup.coffee
|
36
|
+
- vendor/assets/javascripts/transponder.coffee
|
37
|
+
homepage: http://github.com/zacksiri/transponder
|
38
|
+
licenses: []
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.0.0
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: This library gives you more control over rails ujs, it compliments turbolinks,
|
60
|
+
and any other library you use. It is opinionated and helps you clean up your client
|
61
|
+
side code in many ways.
|
62
|
+
test_files: []
|