humane-rails 4.0.0 → 5.0.0

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.
Files changed (36) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +15 -9
  3. data/Rakefile +4 -2
  4. data/app/assets/javascripts/humane-rails.js +13 -0
  5. data/app/assets/stylesheets/humane-rails/bigbox.css +3 -0
  6. data/app/assets/stylesheets/humane-rails/boldlight.css +3 -0
  7. data/app/assets/stylesheets/humane-rails/jackedup.css +3 -0
  8. data/app/assets/stylesheets/humane-rails/libnotify.css +3 -0
  9. data/app/assets/stylesheets/humane-rails/original.css +3 -0
  10. data/app/helpers/humane_rails/flash_messages_helper.rb +21 -0
  11. data/lib/humane-rails.rb +1 -1
  12. data/lib/humane-rails/engine.rb +15 -2
  13. data/lib/humane-rails/version.rb +1 -1
  14. data/spec/internal/app/assets/javascripts/application.js +2 -0
  15. data/spec/internal/app/assets/stylesheets/application.css +3 -0
  16. data/spec/internal/app/controllers/application_controller.rb +2 -0
  17. data/spec/internal/app/controllers/flash_controller.rb +7 -0
  18. data/spec/internal/app/views/flash/index.html.erb +8 -0
  19. data/spec/internal/app/views/layouts/application.html.erb +12 -0
  20. data/spec/internal/config/routes.rb +3 -0
  21. data/spec/internal/log/test.log +2291 -0
  22. data/spec/internal/public/favicon.ico +0 -0
  23. data/spec/requests/navigation_spec.rb +30 -0
  24. data/spec/spec_helper.rb +16 -0
  25. metadata +121 -19
  26. data/.gitignore +0 -4
  27. data/Gemfile +0 -5
  28. data/app/assets/javascripts/humane.jquery.js +0 -229
  29. data/app/assets/javascripts/humane.js +0 -13
  30. data/app/assets/stylesheets/bigbox.css +0 -123
  31. data/app/assets/stylesheets/boldlight.css +0 -122
  32. data/app/assets/stylesheets/jackedup.css +0 -123
  33. data/app/assets/stylesheets/libnotify.css +0 -115
  34. data/app/assets/stylesheets/original.css +0 -72
  35. data/app/helpers/humane_flash_messages_helper.rb +0 -19
  36. data/humane-rails.gemspec +0 -21
File without changes
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe "navigation", :js => true do
4
+ describe "flash with notice" do
5
+ it do
6
+ notice = "This is a notice."
7
+ visit "/?notice=#{ERB::Util.url_encode notice}"
8
+ page.should have_css(".humane-info")
9
+ page.should have_content(notice)
10
+ end
11
+ end
12
+
13
+ describe "flash with error" do
14
+ it do
15
+ error = "This is an error."
16
+ visit "/?error=#{ERB::Util.url_encode error}"
17
+ page.should have_css(".humane-error")
18
+ page.should have_content(error)
19
+ end
20
+ end
21
+
22
+ describe "flash with alert" do
23
+ it do
24
+ alert = "This is an alert."
25
+ visit "/?alert=#{ERB::Util.url_encode alert}"
26
+ page.should have_css(".humane-error")
27
+ page.should have_content(alert)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require "combustion"
5
+ require "capybara/rspec"
6
+
7
+ Combustion.initialize! :action_controller, :action_view, :sprockets
8
+
9
+ require "rspec/rails"
10
+ require "capybara/rails"
11
+
12
+ require "capybara/poltergeist"
13
+ Capybara.javascript_driver = :poltergeist
14
+
15
+ RSpec.configure do |config|
16
+ end
metadata CHANGED
@@ -1,15 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humane-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Harrigan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: poltergeist
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: combustion
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
13
97
  description: A gemified version of Marc Harter's humane-js.
14
98
  email:
15
99
  - martinharrigan@gmail.com
@@ -17,22 +101,29 @@ executables: []
17
101
  extensions: []
18
102
  extra_rdoc_files: []
19
103
  files:
20
- - .gitignore
21
- - Gemfile
22
- - README.md
23
- - Rakefile
24
- - app/assets/javascripts/humane.jquery.js
25
- - app/assets/javascripts/humane.js
26
- - app/assets/stylesheets/bigbox.css
27
- - app/assets/stylesheets/boldlight.css
28
- - app/assets/stylesheets/jackedup.css
29
- - app/assets/stylesheets/libnotify.css
30
- - app/assets/stylesheets/original.css
31
- - app/helpers/humane_flash_messages_helper.rb
32
- - humane-rails.gemspec
33
- - lib/humane-rails.rb
104
+ - app/assets/javascripts/humane-rails.js
105
+ - app/assets/stylesheets/humane-rails/bigbox.css
106
+ - app/assets/stylesheets/humane-rails/boldlight.css
107
+ - app/assets/stylesheets/humane-rails/jackedup.css
108
+ - app/assets/stylesheets/humane-rails/libnotify.css
109
+ - app/assets/stylesheets/humane-rails/original.css
110
+ - app/helpers/humane_rails/flash_messages_helper.rb
34
111
  - lib/humane-rails/engine.rb
35
112
  - lib/humane-rails/version.rb
113
+ - lib/humane-rails.rb
114
+ - Rakefile
115
+ - README.md
116
+ - spec/internal/app/assets/javascripts/application.js
117
+ - spec/internal/app/assets/stylesheets/application.css
118
+ - spec/internal/app/controllers/application_controller.rb
119
+ - spec/internal/app/controllers/flash_controller.rb
120
+ - spec/internal/app/views/flash/index.html.erb
121
+ - spec/internal/app/views/layouts/application.html.erb
122
+ - spec/internal/config/routes.rb
123
+ - spec/internal/log/test.log
124
+ - spec/internal/public/favicon.ico
125
+ - spec/requests/navigation_spec.rb
126
+ - spec/spec_helper.rb
36
127
  homepage: http://github.com/harrigan/humane-rails
37
128
  licenses:
38
129
  - MIT
@@ -52,9 +143,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
143
  - !ruby/object:Gem::Version
53
144
  version: '0'
54
145
  requirements: []
55
- rubyforge_project: humane-rails
146
+ rubyforge_project:
56
147
  rubygems_version: 2.0.4
57
148
  signing_key:
58
149
  specification_version: 4
59
150
  summary: A gemified version of Marc Harter's humane-js.
60
- test_files: []
151
+ test_files:
152
+ - spec/internal/app/assets/javascripts/application.js
153
+ - spec/internal/app/assets/stylesheets/application.css
154
+ - spec/internal/app/controllers/application_controller.rb
155
+ - spec/internal/app/controllers/flash_controller.rb
156
+ - spec/internal/app/views/flash/index.html.erb
157
+ - spec/internal/app/views/layouts/application.html.erb
158
+ - spec/internal/config/routes.rb
159
+ - spec/internal/log/test.log
160
+ - spec/internal/public/favicon.ico
161
+ - spec/requests/navigation_spec.rb
162
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "rails", "3.1.1"
4
-
5
- gem "jquery-rails"
@@ -1,229 +0,0 @@
1
- /**
2
- * humane.js
3
- * Humanized Messages for Notifications
4
- * @author Marc Harter (@wavded)
5
- * @example
6
- * humane.log('hello world');
7
- * See more usage examples at: http://wavded.github.com/humane-js/
8
- */
9
-
10
- ;!function (name, context, definition) {
11
- if (typeof module !== 'undefined') module.exports = definition(name, context)
12
- else if (typeof define === 'function' && typeof define.amd === 'object') define(definition)
13
- else context[name] = definition(name, context)
14
- }('humane', this, function (name, context) {
15
- var win = window
16
- var doc = document
17
-
18
- var ENV = {
19
- on: function (el, type, cb) {
20
- 'addEventListener' in win ? el.addEventListener(type,cb,false) : el.attachEvent('on'+type,cb)
21
- },
22
- off: function (el, type, cb) {
23
- 'removeEventListener' in win ? el.removeEventListener(type,cb,false) : el.detachEvent('on'+type,cb)
24
- },
25
- bind: function (fn, ctx) {
26
- return function () { fn.apply(ctx,arguments) }
27
- },
28
- isArray: Array.isArray || function (obj) { return Object.prototype.toString.call(obj) === '[object Array]' },
29
- config: function (preferred, fallback) {
30
- return preferred != null ? preferred : fallback
31
- },
32
- transSupport: false,
33
- useFilter: /msie [678]/i.test(navigator.userAgent), // sniff, sniff
34
- _checkTransition: function () {
35
- var el = doc.createElement('div')
36
- var vendors = { webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' }
37
-
38
- for (var vendor in vendors)
39
- if (vendor + 'Transition' in el.style) {
40
- this.vendorPrefix = vendors[vendor]
41
- this.transSupport = true
42
- }
43
- }
44
- }
45
- ENV._checkTransition()
46
-
47
- var Humane = function (o) {
48
- o || (o = {})
49
- this.queue = []
50
- this.baseCls = o.baseCls || 'humane'
51
- this.addnCls = o.addnCls || ''
52
- this.timeout = 'timeout' in o ? o.timeout : 2500
53
- this.waitForMove = o.waitForMove || false
54
- this.clickToClose = o.clickToClose || false
55
- this.timeoutAfterMove = o.timeoutAfterMove || false
56
- this.container = o.container
57
-
58
- try { this._setupEl() } // attempt to setup elements
59
- catch (e) {
60
- ENV.on(win,'load',ENV.bind(this._setupEl, this)) // dom wasn't ready, wait till ready
61
- }
62
- }
63
-
64
- Humane.prototype = {
65
- constructor: Humane,
66
- _setupEl: function () {
67
- var el = doc.createElement('div')
68
- el.style.display = 'none'
69
- if (!this.container){
70
- if(doc.body) this.container = doc.body;
71
- else throw 'document.body is null'
72
- }
73
- this.container.appendChild(el)
74
- this.el = el
75
- this.removeEvent = ENV.bind(function(){ if (!this.timeoutAfterMove){this.remove()} else {setTimeout(ENV.bind(this.remove,this),this.timeout);}},this)
76
- this.transEvent = ENV.bind(this._afterAnimation,this)
77
- this._run()
78
- },
79
- _afterTimeout: function () {
80
- if (!ENV.config(this.currentMsg.waitForMove,this.waitForMove)) this.remove()
81
-
82
- else if (!this.removeEventsSet) {
83
- ENV.on(doc.body,'mousemove',this.removeEvent)
84
- ENV.on(doc.body,'click',this.removeEvent)
85
- ENV.on(doc.body,'keypress',this.removeEvent)
86
- ENV.on(doc.body,'touchstart',this.removeEvent)
87
- this.removeEventsSet = true
88
- }
89
- },
90
- _run: function () {
91
- if (this._animating || !this.queue.length || !this.el) return
92
-
93
- this._animating = true
94
- if (this.currentTimer) {
95
- clearTimeout(this.currentTimer)
96
- this.currentTimer = null
97
- }
98
-
99
- var msg = this.queue.shift()
100
- var clickToClose = ENV.config(msg.clickToClose,this.clickToClose)
101
-
102
- if (clickToClose) {
103
- ENV.on(this.el,'click',this.removeEvent)
104
- ENV.on(this.el,'touchstart',this.removeEvent)
105
- }
106
-
107
- var timeout = ENV.config(msg.timeout,this.timeout)
108
-
109
- if (timeout > 0)
110
- this.currentTimer = setTimeout(ENV.bind(this._afterTimeout,this), timeout)
111
-
112
- if (ENV.isArray(msg.html)) msg.html = '<ul><li>'+msg.html.join('<li>')+'</ul>'
113
-
114
- this.el.innerHTML = msg.html
115
- this.currentMsg = msg
116
- this.el.className = this.baseCls
117
- if (ENV.transSupport) {
118
- this.el.style.display = 'block'
119
- setTimeout(ENV.bind(this._showMsg,this),50)
120
- } else {
121
- this._showMsg()
122
- }
123
-
124
- },
125
- _setOpacity: function (opacity) {
126
- if (ENV.useFilter){
127
- try{
128
- this.el.filters.item('DXImageTransform.Microsoft.Alpha').Opacity = opacity*100
129
- } catch(err){}
130
- } else {
131
- this.el.style.opacity = String(opacity)
132
- }
133
- },
134
- _showMsg: function () {
135
- var addnCls = ENV.config(this.currentMsg.addnCls,this.addnCls)
136
- if (ENV.transSupport) {
137
- this.el.className = this.baseCls+' '+addnCls+' '+this.baseCls+'-animate'
138
- }
139
- else {
140
- var opacity = 0
141
- this.el.className = this.baseCls+' '+addnCls+' '+this.baseCls+'-js-animate'
142
- this._setOpacity(0) // reset value so hover states work
143
- this.el.style.display = 'block'
144
-
145
- var self = this
146
- var interval = setInterval(function(){
147
- if (opacity < 1) {
148
- opacity += 0.1
149
- if (opacity > 1) opacity = 1
150
- self._setOpacity(opacity)
151
- }
152
- else clearInterval(interval)
153
- }, 30)
154
- }
155
- },
156
- _hideMsg: function () {
157
- var addnCls = ENV.config(this.currentMsg.addnCls,this.addnCls)
158
- if (ENV.transSupport) {
159
- this.el.className = this.baseCls+' '+addnCls
160
- ENV.on(this.el,ENV.vendorPrefix ? ENV.vendorPrefix+'TransitionEnd' : 'transitionend',this.transEvent)
161
- }
162
- else {
163
- var opacity = 1
164
- var self = this
165
- var interval = setInterval(function(){
166
- if(opacity > 0) {
167
- opacity -= 0.1
168
- if (opacity < 0) opacity = 0
169
- self._setOpacity(opacity);
170
- }
171
- else {
172
- self.el.className = self.baseCls+' '+addnCls
173
- clearInterval(interval)
174
- self._afterAnimation()
175
- }
176
- }, 30)
177
- }
178
- },
179
- _afterAnimation: function () {
180
- if (ENV.transSupport) ENV.off(this.el,ENV.vendorPrefix ? ENV.vendorPrefix+'TransitionEnd' : 'transitionend',this.transEvent)
181
-
182
- if (this.currentMsg.cb) this.currentMsg.cb()
183
- this.el.style.display = 'none'
184
-
185
- this._animating = false
186
- this._run()
187
- },
188
- remove: function (e) {
189
- var cb = typeof e == 'function' ? e : null
190
-
191
- ENV.off(doc.body,'mousemove',this.removeEvent)
192
- ENV.off(doc.body,'click',this.removeEvent)
193
- ENV.off(doc.body,'keypress',this.removeEvent)
194
- ENV.off(doc.body,'touchstart',this.removeEvent)
195
- ENV.off(this.el,'click',this.removeEvent)
196
- ENV.off(this.el,'touchstart',this.removeEvent)
197
- this.removeEventsSet = false
198
-
199
- if (cb && this.currentMsg) this.currentMsg.cb = cb
200
- if (this._animating) this._hideMsg()
201
- else if (cb) cb()
202
- },
203
- log: function (html, o, cb, defaults) {
204
- var msg = {}
205
- if (defaults)
206
- for (var opt in defaults)
207
- msg[opt] = defaults[opt]
208
-
209
- if (typeof o == 'function') cb = o
210
- else if (o)
211
- for (var opt in o) msg[opt] = o[opt]
212
-
213
- msg.html = html
214
- if (cb) msg.cb = cb
215
- this.queue.push(msg)
216
- this._run()
217
- return this
218
- },
219
- spawn: function (defaults) {
220
- var self = this
221
- return function (html, o, cb) {
222
- self.log.call(self,html,o,cb,defaults)
223
- return self
224
- }
225
- },
226
- create: function (o) { return new Humane(o) }
227
- }
228
- return new Humane()
229
- })