dvl-flashes 0.0.1 → 0.0.2

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: 24a6068bf2afaa7eb4db3b7696f4fa6048696328
4
- data.tar.gz: f6b2a1ea0c0cdfb88ee6ad09cb13cd6967c06614
3
+ metadata.gz: b9628d4e2fb13c1af198f10ac0b72e38b28f1bc8
4
+ data.tar.gz: 2b909df8016c192d5c1e13529e9143a09dbee4dc
5
5
  SHA512:
6
- metadata.gz: e5f03d05b079d3990aa2de9bb122ff6caa0798da30849696aeebd76fc5ba84faa97d90fc05eeae32c62be25b8e25deffde96e4d49dc377d0d76f36cbf19e9498
7
- data.tar.gz: c17fab77e892d9421d6900c8674dad50f2f2c4358c3ba9e7bb8a7bc4a0c328618e366d93abfbebbf592e44a9511a88fc9284aa8958592c961310b3624f523470
6
+ metadata.gz: 29ee7797cf386a886e4771ba10eff663f782357351b662f7ee1538652bb67a157196b098fe114a095a250a2b53268f9e1d275f369b2211943f783c205c86a367
7
+ data.tar.gz: a459639d04d87fac5dce3bce86db771f74b8975a9f24921b4b569549dba735c60ac69a999d6754e2e4c22c18aa4cc3a87eb6e6fbb759f2bd1eab388ee9d1bcbd
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .sass-cache
2
2
  Gemfile.lock
3
+ *.gem
4
+ screenshots/
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ ruby:
2
+ enabled: true
3
+
4
+ coffee_script:
5
+ enabled: true
data/README.md CHANGED
@@ -1,36 +1,71 @@
1
- dvl-flashes
1
+ dvl-flashes [![version]](http://rubygems.org/gems/dvl-flashes) [![build_status]](https://circleci.com/gh/dobtco/dvl-flashes)
2
2
  ====
3
3
 
4
4
  Flash alerts for the DOBT View Layer.
5
5
 
6
6
  ## Usage
7
7
 
8
+ ### Gemfile
9
+
8
10
  ```
9
- # Gemfile
10
11
  gem 'dvl-flashes'
11
12
  ```
12
13
 
14
+ ### assets/javascripts/application.css.scss
15
+
13
16
  ```
14
- # assets/javascripts/application.css.scss
15
17
  @import 'dvl/flashes';
16
18
  ```
17
19
 
20
+ ### assets/javascripts/application.js
21
+
18
22
  ```
19
- # assets/javascripts/application.js
20
23
  //= require dvl/flashes
21
24
  ```
22
25
 
26
+ ### layouts/application.rb
27
+
23
28
  ```
24
- # layouts/application.rb
25
29
  widget Dvl::Flashes::Views::Flashes.new(flash: flash)
26
30
  ```
27
31
 
32
+ ### Javascript API
33
+
34
+ ```
35
+ DvlFlash('error', 'An error occured...');
36
+ ```
37
+
38
+ ## Screenshots
39
+
40
+ ### Error
41
+
42
+ ![screenshot_error]
43
+
44
+ ### Success
45
+
46
+ ![screenshot_success]
47
+
48
+ ### Info
49
+
50
+ ![screenshot_info]
51
+
52
+ ### Mobile
53
+
54
+ ![screenshot_mobile]
55
+
28
56
  ## Development
29
57
 
30
58
  1. `script/bootstrap`
31
59
  2. `script/preview`
32
- 3. Open http://localhost:4567 in your web browser
60
+ 3. Open [http://localhost:4567](http://localhost:4567) in your web browser
33
61
 
34
62
  ## License
35
63
 
36
64
  MIT
65
+
66
+ [version]: https://img.shields.io/gem/v/dvl-flashes.svg
67
+ [build_status]: https://circleci-badges.herokuapp.com/dobtco/dvl-flashes/cfb22255e126bd760d2bafdfba40ffbac7786f30
68
+ [screenshot_error]: http://artifinder.herokuapp.com/gh/dobtco/dvl-flashes/x/artifacts/0/home/ubuntu/dvl-flashes/screenshots/error.png
69
+ [screenshot_success]: http://artifinder.herokuapp.com/gh/dobtco/dvl-flashes/x/artifacts/0/home/ubuntu/dvl-flashes/screenshots/success.png
70
+ [screenshot_info]: http://artifinder.herokuapp.com/gh/dobtco/dvl-flashes/x/artifacts/0/home/ubuntu/dvl-flashes/screenshots/info.png
71
+ [screenshot_mobile]: http://artifinder.herokuapp.com/gh/dobtco/dvl-flashes/x/artifacts/0/home/ubuntu/dvl-flashes/screenshots/error_mobile.png
data/circle.yml ADDED
@@ -0,0 +1,7 @@
1
+ general:
2
+ artifacts:
3
+ - "screenshots"
4
+
5
+ test:
6
+ override:
7
+ - script/cibuild
data/dvl-flashes.gemspec CHANGED
@@ -21,7 +21,11 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'erector-rails4'
22
22
  s.add_dependency 'sass'
23
23
 
24
+ s.add_development_dependency 'capybara', '2.4.2'
25
+ s.add_development_dependency 'poltergeist', '1.5.1'
24
26
  s.add_development_dependency 'rerun', '0.10.0'
27
+ s.add_development_dependency 'rspec', '3.1.0'
28
+ s.add_development_dependency 'rspec-html-matchers', '0.6.1'
25
29
  s.add_development_dependency 'sinatra', '1.4.5'
26
30
  s.add_development_dependency 'sinatra-assetpack', '0.3.3'
27
31
  end
@@ -1,5 +1,5 @@
1
1
  module Dvl
2
2
  module Flashes
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -6,8 +6,8 @@ module Dvl::Flashes::Views
6
6
  def content
7
7
  @flash.select { |k, v| k.to_s.in?(%w(success error info)) && v.present? }.each do |k, v|
8
8
  div(class: "flash flash_#{k}") {
9
- a.close '×'.html_safe
10
- text v
9
+ a.flash_close '×'.html_safe
10
+ span text v
11
11
  }
12
12
  end
13
13
  end
data/preview/app.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'sinatra/base'
2
2
  require 'sinatra/assetpack'
3
- require 'erector'
4
3
  require 'active_support/all'
4
+ require 'erector'
5
5
  require 'dvl/flashes'
6
6
 
7
7
  class App < Sinatra::Base
@@ -21,6 +21,7 @@ class App < Sinatra::Base
21
21
  html {
22
22
  head {
23
23
  link href: '/css/dvl/flashes.css', rel: 'stylesheet', type: 'text/css', media: 'all'
24
+ style '* {box-sizing:border-box;}'.html_safe, type: 'text/css'
24
25
  }
25
26
  body {
26
27
  # Uncomment to test rendering from existing HTML
data/script/bootstrap CHANGED
@@ -21,20 +21,22 @@ do
21
21
  fi
22
22
  done
23
23
 
24
- ## Create .ruby-gemset if it doesn't exist
25
- printf "Checking for .ruby-gemset... "
24
+ if [ -d ~/.rvm ]; then
25
+ ## Create .ruby-gemset if it doesn't exist
26
+ printf "Checking for .ruby-gemset... "
26
27
 
27
- if [ ! -f .ruby-gemset ]; then
28
- printf "\nWriting .ruby-gemset..."
29
- printf 'dvl-flashes' >> .ruby-gemset
30
- fi
28
+ if [ ! -f .ruby-gemset ]; then
29
+ printf "\nWriting .ruby-gemset..."
30
+ printf 'dvl-flashes' >> .ruby-gemset
31
+ fi
31
32
 
32
- printf "OK\n"
33
+ printf "OK\n"
33
34
 
34
- ## Ensure RVM is using our ruby + gemset
35
- source ~/.rvm/scripts/rvm
36
- rvm use `cat .ruby-version`
37
- rvm gemset use --create `cat .ruby-gemset`
35
+ ## Ensure RVM is using our ruby + gemset
36
+ source ~/.rvm/scripts/rvm
37
+ rvm use `cat .ruby-version`
38
+ rvm gemset use --create `cat .ruby-gemset`
39
+ fi
38
40
 
39
41
  ## Bundle
40
42
  printf "Bundling...\n"
data/script/cibuild ADDED
@@ -0,0 +1,3 @@
1
+ #! /bin/sh
2
+
3
+ bundle exec rspec
data/script/preview CHANGED
@@ -1,3 +1,3 @@
1
1
  #! /bin/sh
2
2
 
3
- rerun 'ruby preview/app.rb'
3
+ bundle exec rerun 'ruby preview/app.rb'
data/script/release ADDED
@@ -0,0 +1,38 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ # Make sure we're in the project root.
7
+
8
+ cd $(dirname "$0")/..
9
+
10
+ # Build a new gem archive.
11
+
12
+ rm -rf dvl-flashes-*.gem
13
+ gem build -q dvl-flashes.gemspec
14
+
15
+ # Make sure we're on the master branch.
16
+
17
+ (git branch | grep -q '* master') || {
18
+ echo "Only release from the master branch."
19
+ exit 1
20
+ }
21
+
22
+ # Figure out what version we're releasing.
23
+
24
+ tag=v`ls dvl-flashes-*.gem | sed 's/^dvl-flashes-\(.*\)\.gem$/\1/'`
25
+
26
+ # Make sure we haven't released this version before.
27
+
28
+ git fetch -t origin
29
+
30
+ (git tag -l | grep -q "$tag") && {
31
+ echo "Whoops, there's already a '${tag}' tag."
32
+ exit 1
33
+ }
34
+
35
+ # Tag it and bag it.
36
+
37
+ gem push dvl-flashes-*.gem && git tag "$tag" &&
38
+ git push origin master && git push origin "$tag"
@@ -0,0 +1,67 @@
1
+ require 'capybara/rspec'
2
+ require 'capybara/poltergeist'
3
+ require 'rspec-html-matchers'
4
+ require 'active_support/all'
5
+ require 'erector'
6
+ require 'dvl/flashes'
7
+ require_relative '../preview/app'
8
+
9
+ Capybara.app = App
10
+ Capybara.javascript_driver = :poltergeist
11
+
12
+ def take_screenshot(error_type, filename, res_x = 900, res_y = 150)
13
+ describe "taking screenshot: #{filename}.png" do
14
+ before do
15
+ page.driver.resize(res_x, res_y)
16
+ end
17
+
18
+ it 'works' do
19
+ visit '/'
20
+ click_link error_type
21
+ page.save_screenshot "screenshots/#{filename}.png"
22
+ end
23
+ end
24
+ end
25
+
26
+ describe Dvl::Flashes do
27
+
28
+ describe 'Integration', type: :feature, js: true do
29
+ it 'Flashes properly' do
30
+ visit '/'
31
+ page.execute_script "DvlFlash('error', 'Yeah!')"
32
+ expect(page).to have_selector '.flash.flash_error', text: 'Yeah!'
33
+ sleep 4
34
+ expect(page).to_not have_selector '.flash.flash_error', text: 'Yeah!'
35
+ end
36
+ end
37
+
38
+ describe 'Screenshots', type: :feature, js: true do
39
+ take_screenshot 'Error', 'error'
40
+ take_screenshot 'Success', 'success'
41
+ take_screenshot 'Info', 'info'
42
+ take_screenshot 'Error', 'error_mobile', 320, 150
43
+ end
44
+
45
+ describe Dvl::Flashes::Views::Flashes do
46
+ let!(:success_html) do
47
+ described_class.new(
48
+ flash: { 'success' => 'Yeah!' }
49
+ ).to_html
50
+ end
51
+
52
+ let!(:error_html) do
53
+ described_class.new(
54
+ flash: { 'error' => 'No!' }
55
+ ).to_html
56
+ end
57
+
58
+ it 'renders the proper html' do
59
+ expect(success_html).to have_tag('div.flash_success', content: 'Yeah!')
60
+ end
61
+
62
+ it 'renders the proper html' do
63
+ expect(error_html).to have_tag('div.flash_error', content: 'No!')
64
+ end
65
+ end
66
+
67
+ end
@@ -13,19 +13,23 @@ window.DvlFlash = (alertType, message, lengthInMilliseconds) ->
13
13
  else
14
14
  $alert = $("""
15
15
  <div class="flash flash_#{alertType}">
16
- <a class='close'>&times;</a>
17
- #{message}
16
+ <a class='flash_close'>&times;</a>
17
+ <span>#{message}</span>
18
18
  </div>
19
19
  """).appendTo("body")
20
20
 
21
- setTimeout ( -> $alert.addClass 'in' ), 0
21
+ setTimeout ->
22
+ $alert.addClass 'is_visible'
23
+ , 0
22
24
 
23
25
  mousedOver = undefined
24
26
  timeoutExpired = undefined
25
27
 
26
28
  hide = ->
27
- $alert.removeClass 'in'
28
- setTimeout ( -> $alert.remove() ), TRANSITION_LENGTH
29
+ $alert.removeClass 'is_visible'
30
+ setTimeout ->
31
+ $alert.remove()
32
+ , TRANSITION_LENGTH
29
33
 
30
34
  setTimeout ->
31
35
  hide() unless mousedOver
@@ -39,6 +43,6 @@ window.DvlFlash = (alertType, message, lengthInMilliseconds) ->
39
43
  mousedOver = undefined
40
44
  hide() if timeoutExpired
41
45
 
42
- $alert.on 'click', '.close', ->
46
+ $alert.on 'click', '.flash_close', ->
43
47
  mousedOver = undefined
44
48
  hide()
@@ -1,73 +1,85 @@
1
- $dvlFlashBackground: #efefef !default;
2
- $dvlFlashCloseDarkColor: #aaa !default;
3
- $dvlFlashCloseDarkHoverColor: #777 !default;
4
- $dvlFlashCloseLightColor: #e5e5e5 !default;
5
- $dvlFlashCloseLightHoverColor: #fff !default;
6
- $dvlFlashErrorColor: #c12f2e !default;
7
- $dvlFlashSuccessColor: #2aa828 !default;
8
- $dvlFlashZIndex: 1031 !default; // above modal backdrop..
1
+ $dvlFlashZIndex: 1031 !default; // above modal
2
+
3
+ // Remove when we add `based` as a package
4
+ $radius: 3px;
5
+ $black: #222;
6
+ $white: #fff;
7
+ $lighterGray: #efefef;
8
+ $lightGray: #e5e5e5;
9
+ $darkGray: #aaa;
10
+ $darkerGray: #777;
11
+ $errorColor: #c12f2e;
12
+ $successColor: #2aa828;
9
13
 
10
14
  .flash {
11
15
  position: fixed;
12
- top: -100px;
13
- transition: top 0.3s linear;
16
+ left: 0;
17
+ top: 0;
18
+ transform: translateY(-8rem);
19
+ opacity: 0;
20
+ transition: transform 0.3s ease-out, opacity 0.15s ease-out;
14
21
  width: 95%;
15
- left: 2.5%;
22
+ margin: 1rem 2.5% 0;
16
23
  z-index: $dvlFlashZIndex;
17
- background: $dvlFlashBackground;
18
- padding: 0.5rem 1.5rem 0.5rem 1rem;
24
+ background: $lighterGray;
25
+ border-radius: $radius;
26
+ padding: 0.75rem 1rem;
19
27
  font-size: 0.9rem;
20
28
  color: #333;
21
- box-shadow: 1px 1px 1px 0 #333;
22
-
29
+ box-shadow: 0 1px 0 rgba(#000,0.2);
30
+ line-height: 1rem;
31
+ span {
32
+ display: inline-block;
33
+ max-width: 95%;
34
+ }
23
35
  a {
24
- color: #222;
25
36
  text-decoration: underline;
37
+ }
38
+ &.is_visible {
39
+ opacity: 1;
40
+ transform: translateY(0);
41
+ }
42
+ .flash_close {
43
+ position: absolute;
44
+ line-height: 2.5rem;
45
+ text-decoration: none;
46
+ right: 1rem;
47
+ top: 0;
26
48
  font-weight: bold;
49
+ color: $darkGray;
27
50
  &:hover {
51
+ color: $darkerGray;
28
52
  text-decoration: none;
29
53
  }
30
54
  }
55
+ }
31
56
 
32
- .close {
33
- position: absolute;
34
- top: 1px;
35
- right: 8px;
36
- color: $dvlFlashCloseDarkColor;
37
- font-size: 1.5rem;
38
- text-decoration: none;
39
- &:hover {
40
- color: $dvlFlashCloseDarkHoverColor;
41
- }
57
+ // Colors
58
+ .flash_error, .flash_success {
59
+ color: $white;
60
+ a {
61
+ color: $white;
42
62
  }
43
- &.flash_error, &.flash_success {
44
- color: #fff;
45
- a {
46
- color: #fff;
47
- }
48
- .close {
49
- color: $dvlFlashCloseLightColor;
50
- &:hover {
51
- color: $dvlFlashCloseLightHoverColor;
52
- }
63
+ .flash_close {
64
+ color: $lightGray;
65
+ &:hover {
66
+ color: $white;
53
67
  }
54
68
  }
55
- &.flash_error {
56
- background: $dvlFlashErrorColor;
57
- }
69
+ }
58
70
 
59
- &.flash_success{
60
- background: $dvlFlashSuccessColor;
61
- }
62
- &.in {
63
- top: 14px;
64
- }
71
+ .flash_error {
72
+ background: $errorColor;
73
+ }
74
+
75
+ .flash_success {
76
+ background: $successColor;
65
77
  }
66
78
 
67
79
  @media only screen and (min-width: 768px) {
68
80
  .flash {
69
- width: 700px;
70
- margin-left: -350px;
81
+ width: 50rem;
82
+ margin-left: -25rem;
71
83
  left: 50%;
72
84
  }
73
85
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dvl-flashes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-14 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.4.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.4.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: poltergeist
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.5.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.5.1
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rerun
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +108,34 @@ dependencies:
80
108
  - - '='
81
109
  - !ruby/object:Gem::Version
82
110
  version: 0.10.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.1.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 3.1.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-html-matchers
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.6.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.6.1
83
139
  - !ruby/object:Gem::Dependency
84
140
  name: sinatra
85
141
  requirement: !ruby/object:Gem::Requirement
@@ -115,17 +171,22 @@ extensions: []
115
171
  extra_rdoc_files: []
116
172
  files:
117
173
  - ".gitignore"
174
+ - ".hound.yml"
118
175
  - ".ruby-version"
119
176
  - Gemfile
120
177
  - LICENSE.md
121
178
  - README.md
179
+ - circle.yml
122
180
  - dvl-flashes.gemspec
123
181
  - lib/dvl/flashes.rb
124
182
  - lib/dvl/flashes/version.rb
125
183
  - lib/dvl/flashes/views/flashes.rb
126
184
  - preview/app.rb
127
185
  - script/bootstrap
186
+ - script/cibuild
128
187
  - script/preview
188
+ - script/release
189
+ - spec/dvl_flashes_spec.rb
129
190
  - vendor/assets/javascripts/dvl/flashes.coffee
130
191
  - vendor/assets/stylesheets/dvl/flashes.scss
131
192
  homepage: http://github.com/dobtco/dvl-flashes
@@ -152,4 +213,6 @@ rubygems_version: 2.2.2
152
213
  signing_key:
153
214
  specification_version: 4
154
215
  summary: Flash alerts for the DOBT View Layer.
155
- test_files: []
216
+ test_files:
217
+ - spec/dvl_flashes_spec.rb
218
+ has_rdoc: