attack 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6f607650ac2e90d2d18290c5f5335037175a3b1
4
+ data.tar.gz: 1fe517ac9fc1d4215473c56e884bf6c92f4c7331
5
+ SHA512:
6
+ metadata.gz: 5f3ed80d4b7dac1e2654c27599ac09f37e9db4aa0e726712cbb99fa49043cc899c5cd69a3132cf310995ee6da9a9b04505641e6a281e74c122e877b67dfaa779
7
+ data.tar.gz: 511a7af0dfc2e2fffa6013c3595d5423555aff9c28c78f42f315f1d2cb8408d30871bd6a396de4d0ebbf323d61c27f3936f404a8babafebe7e6421fc2b086427
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in attack.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 fireho
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ attack
2
+ ======
3
+
4
+ Attach(k) events!
5
+
6
+ With violence.
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+
5
+ task :update_attack do
6
+
7
+ puts "Generate .js"
8
+ puts "Generate .min.js"
9
+ version = false
10
+ #File.foreach('vendor/assets/javascripts/attack.js') do |line|
11
+
12
+
13
+ puts "\e[32mDone!\e[0m"
14
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/attack/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "attack"
6
+ s.version = Attack::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Renan Tomal Fernandes", "Marcos Piccinini"]
9
+ s.email = ["talk@fireho.com"]
10
+ s.homepage = "http://rubygems.org/gems/attack"
11
+ s.summary = "Attach (K) events!"
12
+ s.description = "This gem provides a nice way to attack, attack events. Rails ready."
13
+ s.license = "MIT"
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+ s.rubyforge_project = "attack"
17
+
18
+ s.add_dependency "railties", ">= 3.0", "< 5.0"
19
+ #s.add_dependency "thor", ">= 0.14", "< 2.0"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
23
+ s.require_path = 'lib'
24
+ end
@@ -0,0 +1 @@
1
+ require 'attack/rails'
@@ -0,0 +1,8 @@
1
+ require 'attack/rails/engine' if ::Rails.version >= '3.1'
2
+ require 'attack/rails/railtie'
3
+ require 'attack/rails/version'
4
+
5
+ module Attack
6
+ module Rails
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Attack
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ # Used to ensure that Rails 3.0.x, as well as Rails >= 3.1 with asset pipeline disabled
2
+ # get the minified version of the scripts included into the layout in production.
3
+ module Attack
4
+ module Rails
5
+ class Railtie < ::Rails::Railtie
6
+ config.before_configuration do
7
+ if config.action_view.javascript_expansions
8
+ jq_defaults = ::Rails.env.production? || ::Rails.env.test? ? %w(jquery.min) : %w(jquery)
9
+
10
+ config.action_view.javascript_expansions[:defaults] |= jq_defaults + ['attack']
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ module Attack
2
+ VERSION = "1.0.0"
3
+ module Rails
4
+ ATTACK_VERSION = "1.0.0"
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ require 'rails'
2
+
3
+ # Supply generator for Rails 3.0.x or if asset pipeline is not enabled
4
+ if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled
5
+ module Attack
6
+ module Generators
7
+ class InstallGenerator < ::Rails::Generators::Base
8
+
9
+ desc "This generator installs attack #{Attack::Rails::ATTACK_VERSION}"
10
+ source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
11
+
12
+ def copy_attack
13
+ say_status("copying", "attack (#{Attack::Rails::ATTACK_VERSION})", :green)
14
+ copy_file "attack.js", "public/javascripts/attack.js"
15
+ copy_file "attack.min.js", "public/javascripts/attack.min.js"
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ else
22
+ module Attack
23
+ module Generators
24
+ class InstallGenerator < ::Rails::Generators::Base
25
+ desc "Just show instructions so people will know what to do when mistakenly using generator for Rails 3.1 apps"
26
+
27
+ def do_nothing
28
+ say_status("deprecated", "You are using Rails 3.1 with the asset pipeline enabled, so this generator is not needed.")
29
+ say_status("", "The necessary files are already in your asset pipeline.")
30
+ say_status("", "Just add `//= require attack` to your app/assets/javascripts/application.js")
31
+ say_status("", "If you upgraded your app from Rails 3.0 and still have attack.js, rails.js, or attack_ujs.js in your javascripts, be sure to remove them.")
32
+ say_status("", "If you do not want the asset pipeline enabled, you may turn it off in application.rb and re-run this generator.")
33
+ # ok, nothing
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,129 @@
1
+ #= require jquery
2
+ # TO BE COMMENTED!
3
+ #
4
+ do($=jQuery) ->
5
+ $ ->
6
+ setTimeout ->
7
+ $.fireAllCreatedEvents()
8
+ , 0
9
+
10
+ # turbolinks
11
+ $(document).on 'page:change', () ->
12
+ $.fireAllCreatedEvents()
13
+
14
+ $.fireAllCreatedEvents = ->
15
+ for k of jQuery.cache
16
+ if jQuery.cache[k]?.events?.created?
17
+ for obj in jQuery.cache[k].events.created
18
+ els = $(obj.selector, jQuery.cache[k].handle.elem)
19
+ if els.length
20
+ for el in els
21
+ el.__triggered_created or= {}
22
+ el.__triggered_created[k] or= []
23
+ unless obj in el.__triggered_created[k]
24
+ el.__triggered_created[k].push(obj)
25
+ obj.handler.apply(el, [])
26
+
27
+
28
+
29
+ parseDOMArguments = (args, i)->
30
+ $(args).map (i2, arg) ->
31
+ if arg instanceof $
32
+ if i then arg.clone(true) else arg
33
+ else if arg?.tagName
34
+ $(arg)
35
+ else if typeof(arg) == 'string' and /^\s*\</.test(arg) and (tmpArg=$(arg)).length
36
+ tmpArg
37
+ else if arg instanceof Array and arg.length
38
+ parseDOMArguments(arg)
39
+ else
40
+ arg
41
+
42
+ cascadeTrigger = (el, event)->
43
+ #fode geral
44
+ ###if el instanceof $
45
+ $el = el
46
+ el = el.get(0)
47
+ else
48
+ $el = $(el)
49
+
50
+ if el and !el.hasOwnProperty('__triggered_'+event)
51
+ el["__triggered_"+event] = true
52
+ console.log 'cascade', el
53
+ $el.trigger(event) # eh o mesmo
54
+ for child in el.children
55
+ cascadeTrigger(child, event)###
56
+
57
+ return unless el
58
+ ev = "__triggered_"+event
59
+
60
+ $el = $(el)
61
+
62
+ parents = $el.parents().toArray()
63
+ return unless document.body in parents
64
+ parents.push(window.document)
65
+
66
+ children = $el.find('*').toArray()
67
+
68
+ #don't touch, black magic'
69
+ for k of jQuery.cache
70
+ if jQuery.cache[k]?.events?[event]?
71
+ element = jQuery.cache[k].handle?.elem
72
+ continue unless element
73
+ if element == el or element in parents
74
+ for obj in jQuery.cache[k].events[event]
75
+ childEls = $(obj.selector, element)
76
+ childEls.push element
77
+ for childEl in childEls
78
+ childEl[ev] or= {}
79
+ childEl[ev][k] or= []
80
+ if (childEl == el or childEl in children)
81
+ continue if obj in childEl[ev][k]
82
+ childEl[ev][k].push(obj)
83
+ obj.handler.apply(childEl, [])
84
+
85
+
86
+ avoidCustom = false
87
+ originalAppend = $.fn.append
88
+ for methodName in ['append', 'prepend', 'before', 'after']
89
+ do(originalMethod=$.fn[methodName]) ->
90
+ $.fn[methodName] = ->
91
+ if avoidCustom
92
+ return originalMethod.apply(@, arguments)
93
+
94
+ triggerAll = (targets)->
95
+ if targets instanceof $ or targets instanceof Array
96
+ for target in targets
97
+ triggerAll(target)
98
+ else if targets.tagName?
99
+ cascadeTrigger(targets, 'created')
100
+
101
+ div = $('<div></div>')
102
+ avoidCustom = true
103
+ originalAppend.apply(div, arguments)
104
+ avoidCustom = false
105
+ html = div.html()
106
+ args = arguments
107
+ hasElements = div.children().length
108
+ @.each (i, self)->
109
+ if hasElements
110
+ if i == 0
111
+ elements = div.children()
112
+ else
113
+ elements = $(html)
114
+ else
115
+ elements = args
116
+
117
+ originalMethod.apply($(self), elements)
118
+
119
+ triggerAll(elements)
120
+
121
+
122
+ do(originalMethod=$.fn.html) ->
123
+ $.fn.html = ->
124
+ out = originalMethod.apply(@, arguments)
125
+ unless avoidCustom
126
+ if arguments.length
127
+ for el in @.children()
128
+ cascadeTrigger(el, 'created')
129
+ out
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: attack
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Renan Tomal Fernandes
8
+ - Marcos Piccinini
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '3.0'
21
+ - - <
22
+ - !ruby/object:Gem::Version
23
+ version: '5.0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '3.0'
31
+ - - <
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ description: This gem provides a nice way to attack, attack events. Rails ready.
35
+ email:
36
+ - talk@fireho.com
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - .gitignore
42
+ - Gemfile
43
+ - MIT-LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - attack.gemspec
47
+ - lib/attack.rb
48
+ - lib/attack/rails.rb
49
+ - lib/attack/rails/engine.rb
50
+ - lib/attack/rails/railtie.rb
51
+ - lib/attack/version.rb
52
+ - lib/generators/attack/install/install_generator.rb
53
+ - vendor/assets/javascripts/attack.js.coffee
54
+ homepage: http://rubygems.org/gems/attack
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: 1.3.6
72
+ requirements: []
73
+ rubyforge_project: attack
74
+ rubygems_version: 2.0.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Attach (K) events!
78
+ test_files: []
79
+ has_rdoc: