css3-progress-bar-rails 0.0.4 → 0.0.5

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.
@@ -1,64 +1,91 @@
1
+ # Rails Helper that generates the HTML for displaying a CSS3 progress bar using
2
+ # Josh Sullivan's CSS3-Progress-bars (https://github.com/jsullivan/CSS3-Progress-bars).
1
3
  module Css3ProgressBarsHelper
4
+
5
+ # Accepts a value between 0 and 100 that represents the percentage amount displayed
6
+ # as filled on the progress bar's div style.
7
+ #
8
+ # An options hash may also be passed to the method, with boolean options for
9
+ # :rounded and :tiny. Pass a string in the :color option from the available
10
+ # choices of 'green', 'orange', 'pink', 'blue', and 'purple'.
2
11
  def progress_bar percentage, *opts
3
12
  options = opts.extract_options!
4
13
 
5
- container_classes = %w(bar_container)
6
- bar_classes = %w(progress)
7
- mortice_classes = %w(bar_mortice)
14
+ html_classes = setup_default_container_classes
8
15
 
9
16
  if options[:rounded] && options[:rounded] == true
10
- container_classes << 'rounded_bar_container'
11
- bar_classes << 'rounded'
12
- mortice_classes << 'rounded'
17
+ handle_rounded_classes(html_classes)
13
18
  end
14
-
15
- if options[:color] && bar_colors.include?(options[:color])
16
- container_classes << "#{options[:color]}_container"
17
- bar_classes << options[:color]
18
- mortice_classes << "#{options[:color]}_mortice"
19
+
20
+ if options[:tiny] && options[:tiny] == true
21
+ handle_tiny_classes(html_classes)
19
22
  end
20
23
 
21
- if options[:tiny] && options[:tiny] == true
22
- container_classes << 'container_tiny'
23
- bar_classes << 'progress_tiny'
24
- mortice_classes << 'mortice_tiny'
24
+ if options[:color] && bar_colors.include?(options[:color])
25
+ handle_color_classes(html_classes, options[:color])
25
26
  end
26
27
 
27
- bar_html = bar_div(bar_classes, bar_style(percentage))
28
- mortice_html = mortice_div(bar_html, mortice_classes)
28
+ bar_html = bar_div(html_classes[:bar_classes], bar_style(percentage))
29
+ mortice_html = mortice_div(bar_html, html_classes[:mortice_classes])
29
30
 
30
- content_tag :div, mortice_html, :class => container_classes.join(' ')
31
+ content_tag :div, mortice_html, :class => html_classes[:container_classes].join(' ')
31
32
  end
32
33
 
33
- def combo_progress_bar *opts
34
+ # Accepts an array of values between 0 and 100 to represent the combo progress
35
+ # values. As there is a limit to the number of colors, only the first five
36
+ # elements of the array will be used.
37
+ #
38
+ # An options hash may also be passed to the method, with boolean options for
39
+ # :rounded and :tiny.
40
+ def combo_progress_bar percentages, *opts
34
41
  options = opts.extract_options!
35
-
36
- container_classes = %w(bar_container)
37
- bar_classes = %w(progress)
38
- mortice_classes = %w(bar_mortice)
42
+ html_classes = setup_default_container_classes
39
43
 
40
44
  if options[:rounded] && options[:rounded] == true
41
- container_classes << 'rounded_bar_container'
42
- bar_classes << 'rounded'
43
- mortice_classes << 'rounded'
45
+ handle_rounded_classes(html_classes)
44
46
  end
45
-
47
+
46
48
  if options[:tiny] && options[:tiny] == true
47
- container_classes << 'container_tiny'
48
- bar_classes << 'progress_tiny'
49
- mortice_classes << 'mortice_tiny'
49
+ handle_tiny_classes(html_classes)
50
50
  end
51
51
 
52
52
  bars = ''
53
- options[:percentages][0..4].each_with_index do |p, i|
54
- bars += bar_div((bar_classes << bar_colors[i]), bar_style(p))
53
+ percentages[0..4].each_with_index do |p, i|
54
+ bars += bar_div((html_classes[:bar_classes] << bar_colors[i]), bar_style(p))
55
55
  end
56
56
 
57
- mortice_html = mortice_div(bars, mortice_classes)
58
- content_tag :div, mortice_html, :class => container_classes.join(' ')
57
+ mortice_html = mortice_div(bars, html_classes[:mortice_classes])
58
+ content_tag :div, mortice_html, :class => html_classes[:container_classes].join(' ')
59
59
  end
60
60
 
61
61
  protected
62
+
63
+ def setup_default_container_classes
64
+ {
65
+ :container_classes => %w(bar_container),
66
+ :bar_classes => %w(progress),
67
+ :mortice_classes => %w(bar_mortice)
68
+ }
69
+ end
70
+
71
+ def handle_color_classes html_classes, color
72
+ html_classes[:container_classes] << "#{color}_container"
73
+ html_classes[:bar_classes] << color
74
+ html_classes[:mortice_classes] << "#{color}_mortice"
75
+ end
76
+
77
+ def handle_tiny_classes html_classes
78
+ html_classes[:container_classes] << 'container_tiny'
79
+ html_classes[:bar_classes] << 'progress_tiny'
80
+ html_classes[:mortice_classes] << 'mortice_tiny'
81
+ end
82
+
83
+ def handle_rounded_classes html_classes
84
+ html_classes[:container_classes] << 'rounded_bar_container'
85
+ html_classes[:bar_classes] << 'rounded'
86
+ html_classes[:mortice_classes] << 'rounded'
87
+ end
88
+
62
89
  def bar_colors
63
90
  %w(green orange pink blue purple)
64
91
  end
@@ -2,7 +2,7 @@ module Css3
2
2
  module Progress
3
3
  module Bar
4
4
  module Rails
5
- VERSION = "0.0.4"
5
+ VERSION = "0.0.5"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,35 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: css3-progress-bar-rails
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 5
10
+ version: 0.0.5
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Nicholas Fine
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-01-02 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-01-02 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: rails
16
- requirement: &17889940 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
22
33
  type: :runtime
23
- prerelease: false
24
- version_requirements: *17889940
25
- description: Integrates Josh Sullivan's CSS3 Progress Bars into Rails and adds ActionView
26
- helpers for generation.
27
- email:
34
+ version_requirements: *id001
35
+ description: Integrates Josh Sullivan's CSS3 Progress Bars into Rails and adds ActionView helpers for generation.
36
+ email:
28
37
  - nicholas.fine@gmail.com
29
38
  executables: []
39
+
30
40
  extensions: []
41
+
31
42
  extra_rdoc_files: []
32
- files:
43
+
44
+ files:
33
45
  - .gitignore
34
46
  - Gemfile
35
47
  - Rakefile
@@ -38,28 +50,39 @@ files:
38
50
  - css3-progress-bar-rails.gemspec
39
51
  - lib/css3-progress-bar-rails.rb
40
52
  - lib/css3-progress-bar-rails/version.rb
41
- homepage: ''
53
+ has_rdoc: true
54
+ homepage: ""
42
55
  licenses: []
56
+
43
57
  post_install_message:
44
58
  rdoc_options: []
45
- require_paths:
59
+
60
+ require_paths:
46
61
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
62
+ required_ruby_version: !ruby/object:Gem::Requirement
48
63
  none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
72
  none: false
55
- requirements:
56
- - - ! '>='
57
- - !ruby/object:Gem::Version
58
- version: '0'
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
59
80
  requirements: []
81
+
60
82
  rubyforge_project: css3-progress-bar-rails
61
- rubygems_version: 1.8.6
83
+ rubygems_version: 1.4.2
62
84
  signing_key:
63
85
  specification_version: 3
64
86
  summary: Integrates Josh Sullivan's CSS3 Progress Bars into Rails 3.1+ Projects.
65
87
  test_files: []
88
+