transponder 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d094cd6ef47d3bc712d1647d17b4b5c68011ff10
4
- data.tar.gz: 9b13bddf38ff70a3fe0c4f737c49ed70f8a8aebe
3
+ metadata.gz: 50641edd10cac838b85cc05911ce56e8f144dcd4
4
+ data.tar.gz: 5133536fb40261c5cea194221682cb81aa7f2e12
5
5
  SHA512:
6
- metadata.gz: ce68924a068a7bf1ea96c5c481c3e679e8c593d0e55515d2c4dbfda76c0dc5a75649c96a1adabdc80da5446909748e701b4a4f5c5b4eda9e455e8d5eb1d7865b
7
- data.tar.gz: d712bb28e15ab17f64d4a3e32bbd0cbaf8e930ee0e04ca8568c3fec8cd0dfea9f748da9a8b3ea8cd88573fb3ef910d90b5bb15a905735519593ca0cc91eb2127
6
+ metadata.gz: e2bdda46aeeb3b3204c2e95949aba6f4f2b956baa630577ae8d6a2ec1787189961f78db6abe82e40e3b8e7e7a3d85f989c3849ba13db515b80c45a93bd4fc968
7
+ data.tar.gz: bc36daf253d95130c30a4eba9ab17a3499037c55d37622b225f9273aaaa9d1ea67f36d3eee6fca17493439e6f79734c2d040f0253df8f2816906dca52c56f08c
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in transponder.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,119 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ transponder (0.0.3)
5
+ railties (~> 3.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.13)
11
+ actionpack (= 3.2.13)
12
+ mail (~> 2.5.3)
13
+ actionpack (3.2.13)
14
+ activemodel (= 3.2.13)
15
+ activesupport (= 3.2.13)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.13)
24
+ activesupport (= 3.2.13)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.13)
27
+ activemodel (= 3.2.13)
28
+ activesupport (= 3.2.13)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.13)
32
+ activemodel (= 3.2.13)
33
+ activesupport (= 3.2.13)
34
+ activesupport (3.2.13)
35
+ i18n (= 0.6.1)
36
+ multi_json (~> 1.0)
37
+ arel (3.0.2)
38
+ builder (3.0.4)
39
+ capybara (2.1.0)
40
+ mime-types (>= 1.16)
41
+ nokogiri (>= 1.3.3)
42
+ rack (>= 1.0.0)
43
+ rack-test (>= 0.5.4)
44
+ xpath (~> 2.0)
45
+ coffee-rails (3.2.2)
46
+ coffee-script (>= 2.2.0)
47
+ railties (~> 3.2.0)
48
+ coffee-script (2.2.0)
49
+ coffee-script-source
50
+ execjs
51
+ coffee-script-source (1.6.2)
52
+ colorize (0.5.8)
53
+ erubis (2.7.0)
54
+ execjs (1.4.0)
55
+ multi_json (~> 1.0)
56
+ hike (1.2.2)
57
+ i18n (0.6.1)
58
+ journey (1.0.4)
59
+ json (1.8.0)
60
+ konacha (2.6.0)
61
+ actionpack (>= 3.1, < 5)
62
+ capybara
63
+ colorize
64
+ railties (>= 3.1, < 5)
65
+ sprockets
66
+ mail (2.5.4)
67
+ mime-types (~> 1.16)
68
+ treetop (~> 1.4.8)
69
+ mime-types (1.23)
70
+ multi_json (1.7.3)
71
+ nokogiri (1.5.9)
72
+ polyglot (0.3.3)
73
+ rack (1.4.5)
74
+ rack-cache (1.2)
75
+ rack (>= 0.4)
76
+ rack-ssl (1.3.3)
77
+ rack
78
+ rack-test (0.6.2)
79
+ rack (>= 1.0)
80
+ rails (3.2.13)
81
+ actionmailer (= 3.2.13)
82
+ actionpack (= 3.2.13)
83
+ activerecord (= 3.2.13)
84
+ activeresource (= 3.2.13)
85
+ activesupport (= 3.2.13)
86
+ bundler (~> 1.0)
87
+ railties (= 3.2.13)
88
+ railties (3.2.13)
89
+ actionpack (= 3.2.13)
90
+ activesupport (= 3.2.13)
91
+ rack-ssl (~> 1.3.2)
92
+ rake (>= 0.8.7)
93
+ rdoc (~> 3.4)
94
+ thor (>= 0.14.6, < 2.0)
95
+ rake (10.0.4)
96
+ rdoc (3.12.2)
97
+ json (~> 1.4)
98
+ sprockets (2.2.2)
99
+ hike (~> 1.2)
100
+ multi_json (~> 1.0)
101
+ rack (~> 1.0)
102
+ tilt (~> 1.1, != 1.3.0)
103
+ thor (0.18.1)
104
+ tilt (1.4.1)
105
+ treetop (1.4.12)
106
+ polyglot
107
+ polyglot (>= 0.3.1)
108
+ tzinfo (0.3.37)
109
+ xpath (2.0.0)
110
+ nokogiri (~> 1.3)
111
+
112
+ PLATFORMS
113
+ ruby
114
+
115
+ DEPENDENCIES
116
+ coffee-rails
117
+ konacha
118
+ rails (~> 3.2.13)
119
+ transponder!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
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)
13
+
14
+ class Transponder.InvalidService
15
+ constructor: (message) ->
16
+ @message = message
17
+ @name = "InvalidService"
@@ -0,0 +1 @@
1
+ new Transponder.init()
@@ -0,0 +1,64 @@
1
+ class Transponder.Presenter
2
+ actions: ['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 = @actions 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 presenter"
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
+ {}
@@ -0,0 +1,16 @@
1
+ class Transponder.Service
2
+ serviceName: null
3
+ element: null
4
+
5
+ constructor: ->
6
+ throw new Transponder.InvalidService('no service name specified.') unless @serviceName?
7
+ _this = this
8
+ $(document).on _this.serviceName, (e) ->
9
+ service = _this.serviceName.split(':').pop()
10
+ $(".#{service}:not(#{service}_active)").each (i, e) ->
11
+ _this.element = $(this)
12
+ _this.element.addClass("#{service}_active")
13
+ _this.serve()
14
+
15
+ serve: ->
16
+
@@ -0,0 +1,8 @@
1
+ window.Transponder =
2
+ buildEvent: (array) ->
3
+ eventType = array.filter (val) -> val != null
4
+ eventType.join(':')
5
+
6
+ init: ->
7
+ Transponder.eh = new Transponder.Error()
8
+ Transponder.req = new Transponder.Request()
@@ -0,0 +1,22 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Transponder
4
+ module Generators
5
+ class Base < ::Rails::Generators::Base
6
+ def self.source_root
7
+ @_transponder_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'transponder', generator_name, 'templates'))
8
+ end
9
+
10
+ def self.banner
11
+ "rails generate transponder:#{generator_name} #{self.arguments.map{ |a| a.usage}.join(' ')} [options]"
12
+ end
13
+
14
+ private
15
+
16
+ def print_usage
17
+ self.class.help(Thor::Base.shell.new)
18
+ exit
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ Description:
2
+ The transponder:install will generate the services, presenters
3
+ and helpers folder in your assets/javascripts directory,
4
+ it will also generate a manifest and setup file with your
5
+ application name usually app_name.js.coffee
6
+
7
+ Output:
8
+ rails generate transponder:install
9
+
10
+ Services: app/assets/javascripts/services
11
+ Presenters: app/assets/javascripts/presenters
12
+ Helper: app/assets/javascripts/helpers
13
+ Setup: app/assets/javascripts/app_name-setup.js.coffee
14
+ Manifest: app/assets/javascripts/app_name-manifest.js.coffee
@@ -0,0 +1,30 @@
1
+ require 'generators/transponder'
2
+ require 'generators/transponder/resource_helpers'
3
+
4
+ module Transponder
5
+ module Generators
6
+ class InstallGenerator < Base
7
+ include Transponder::Generators::ResourceHelpers
8
+
9
+ def create_services
10
+ directory 'services', 'app/assets/javascripts/services'
11
+ end
12
+
13
+ def create_presenters
14
+ directory 'presenters', 'app/assets/javascripts/presenters'
15
+ end
16
+
17
+ def create_helpers
18
+ directory 'helpers', 'app/assets/javascripts/helpers'
19
+ end
20
+
21
+ def add_setup
22
+ template 'setup.coffee', "app/assets/javascripts/#{js_app_name}-setup.coffee"
23
+ end
24
+
25
+ def add_manifest
26
+ template 'manifest.coffee', "app/assets/javascripts/#{js_app_name}-manifest.coffee"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ Transponder.services_manifest = ->
2
+ # fill in your manifest here
3
+ # example:
4
+ # if you want to trigger a service on your entire app
5
+ # $('body').trigger 'app_name:services:service_name'
6
+ #
7
+ # If you want a more fine grained control for
8
+ # different pages you can add a class to your body
9
+ # in your views/layouts/application.html.erb
10
+ # on your body tag you can do something like this
11
+ #
12
+ # <body class="[controller_name] [action_name]">
13
+ #
14
+ # You now have a more fine grained control in
15
+ # your manifest file
16
+ # $('body.posts.show').trigger 'app_name:services:service_name'
17
+ #
18
+ # if you need to trigger the same services on multiple pages
19
+ # $('body.posts.show,
20
+ # body.dashboard.show,
21
+ # body.photos.index').trigger 'app_name:services:service_name'
22
+ #
23
+
24
+ run_ready = ->
25
+ Transponder.services_manifest()
26
+
27
+ $(document).ready run_ready
28
+ $(document).on 'page:load', run_ready
@@ -0,0 +1,4 @@
1
+ window.<%= application_name.camelize %> =
2
+ Helpers: {}
3
+ Services: {}
4
+ Presenters: {}
@@ -0,0 +1,21 @@
1
+ module Transponder
2
+ module Generators
3
+ module ResourceHelpers
4
+
5
+
6
+ def js_app_name
7
+ application_name.downcase
8
+ end
9
+
10
+ # gets the application name
11
+ def application_name
12
+ if defined?(Rails) && ::Rails.application
13
+ ::Rails.application.class.name.split('::').first
14
+ else
15
+ "application"
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ module Transponder
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Transponder
2
+ VERSION = "0.0.5"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transponder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Siri
@@ -31,10 +31,27 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - lib/assets/javascripts/transponder/error.coffee
35
+ - lib/assets/javascripts/transponder/init.coffee
36
+ - lib/assets/javascripts/transponder/presenter.coffee
37
+ - lib/assets/javascripts/transponder/request.coffee
38
+ - lib/assets/javascripts/transponder/service.coffee
39
+ - lib/assets/javascripts/transponder/setup.coffee
34
40
  - lib/assets/javascripts/transponder.coffee
41
+ - lib/generators/transponder/install/install_generator.rb
42
+ - lib/generators/transponder/install/templates/manifest.coffee
43
+ - lib/generators/transponder/install/templates/setup.coffee
44
+ - lib/generators/transponder/install/USAGE
45
+ - lib/generators/transponder/resource_helpers.rb
46
+ - lib/generators/transponder.rb
47
+ - lib/transponder/engine.rb
48
+ - lib/transponder/version.rb
35
49
  - lib/transponder.rb
36
- - README.md
50
+ - Gemfile
51
+ - Gemfile.lock
37
52
  - LICENSE.txt
53
+ - Rakefile
54
+ - README.md
38
55
  homepage: http://github.com/zacksiri/transponder
39
56
  licenses: []
40
57
  metadata: {}