css3-progress-bar-rails 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -22,14 +22,24 @@ Into the application.css header:
22
22
 
23
23
  *= require 'css3-progress-bar'
24
24
 
25
+ In a view:
26
+
27
+ <%= progress_bar(33, :color => 'blue', :rounded => true) %>
28
+
29
+ Also, I have added support for the upcoming [Twitter Bootstrap 2][tweetin]
30
+ progress bar styling as well. To use:
31
+
32
+ <%= bootstrap_progress_bar(33, :color => 'info', :striped => true) %>
33
+
25
34
  [View Examples Here][examples]
26
35
 
27
36
  ## Indication
28
37
 
29
38
  Except where indicated:
30
- Copyright (c) 2011 [Nicholas Fine][vanity], released under the MIT license.
39
+ Copyright (c) 2012 [Nicholas Fine][vanity], released under the MIT license.
31
40
 
32
41
  [js]: http://dipperstove.com/index.html
33
42
  [blog]: http://dipperstove.com/design/css3-progress-bars.html
34
43
  [vanity]: http://ndfine.com
35
44
  [examples]: http://ndfine.com/2012/01/03/css3-progress-bars-for-rails.html
45
+ [tweetin]: http://markdotto.com/bs2/docs/components.html#progress
@@ -33,6 +33,29 @@ module Css3ProgressBarsHelper
33
33
  content_tag :div, mortice_html, :class => html_classes[:container_classes].join(' ')
34
34
  end
35
35
 
36
+ def bootstrap_progress_bar percentage, *opts
37
+ percentage = scrub_percentage(percentage)
38
+ options = opts.extract_options!
39
+
40
+ container_classes = %w(progress)
41
+
42
+ if options[:striped] && options[:striped] == true
43
+ container_classes << 'progress-striped'
44
+ end
45
+
46
+ if options[:active] && options[:active] == true
47
+ container_classes << 'active'
48
+ end
49
+
50
+ if options[:color] && %w(info success danger).include?(options[:color])
51
+ container_classes << "progress-#{options[:color]}"
52
+ end
53
+
54
+ bar_html = bar_div(%w('bar'), bar_style(percentage))
55
+
56
+ content_tag :div, bar_html, :class => container_classes.join(' ')
57
+ end
58
+
36
59
  # Accepts an array of values between 0 and 100 to represent the combo progress
37
60
  # values. As there is a limit to the number of colors, only the first five
38
61
  # elements of the array will be used.
@@ -2,7 +2,7 @@ module Css3
2
2
  module Progress
3
3
  module Bar
4
4
  module Rails
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
8
8
  end
@@ -7,6 +7,34 @@ include ActionView::Context
7
7
  include Css3ProgressBarsHelper
8
8
 
9
9
  describe Css3ProgressBarsHelper do
10
+ describe '#bootstrap_progress_bar' do
11
+ describe 'with the color option' do
12
+ describe 'using an invalid color option' do
13
+ it 'does not set a color class in container div' do
14
+ Nokogiri::HTML(bootstrap_progress_bar(33, :color => 'foo')).search('div.progress').first.attributes["class"].wont_match /progress-foo/
15
+ end
16
+ end
17
+
18
+ describe 'using a valid color option' do
19
+ it 'sets the correct class in container div' do
20
+ Nokogiri::HTML(bootstrap_progress_bar(33, :color => 'info')).search('div.progress').first.attributes["class"].must_match /progress-info/
21
+ end
22
+ end
23
+ end
24
+
25
+ describe 'with the striped option' do
26
+ it 'sets the correct class in container div' do
27
+ Nokogiri::HTML(bootstrap_progress_bar(33, :striped => true)).search('div.progress').first.attributes["class"].must_match /progress-striped/
28
+ end
29
+ end
30
+
31
+ describe 'with the active option' do
32
+ it 'sets the correct class in container div' do
33
+ Nokogiri::HTML(bootstrap_progress_bar(12, :active => true)).search('div.progress').first.attributes["class"].must_match /active/
34
+ end
35
+ end
36
+ end
37
+
10
38
  describe '#combo_progress_bar' do
11
39
  describe 'given a collection that contains an invalid percentage value' do
12
40
  it 'raises an ArgumentError' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css3-progress-bar-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nicholas Fine
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-01-13 00:00:00 -06:00
19
+ date: 2012-01-31 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency