bootstrap_progressbar 0.1.1 → 0.2.0

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: 268dd4c0b64651b82e1d4ab971b3da0989eb09b1
4
- data.tar.gz: b645d9464c28e131d6e119257a6c57ab9ad5d85a
3
+ metadata.gz: 6fe1c695b26c317eb510ec2b50113f60853db122
4
+ data.tar.gz: c52267d35411beb0f21dad10590a20d4bc1af93d
5
5
  SHA512:
6
- metadata.gz: 66a1e3985eeddf27feb2c1849cdb847c8478058d938d8c298ac1a293892006b79ea4c5076cc5c9df886824780e16ddc5da4342f83bd7a94f655524a615ebf065
7
- data.tar.gz: de4c17fef798764ff99774415f4a5d5283f4c0658594a3ae2947a82bb7207e5cbea85de8f46fb92b185a71d388b4f540ce0ebbb641e0219534139120c59d8562
6
+ metadata.gz: 54c14d2f93eee9da201af33c5a983f549c4336473b64f2757b29b158d358104fe12823679b8684eb273f2ff1963849bbad21026569cfe8cd673f1314ae6c83c9
7
+ data.tar.gz: 411745110eeb7d66f090f3ad774ac957c6b91b02eaa0f84ecfbf9425b0f6e8c9683f85f31ab519425f1352bebd54c20a15a5783aca4d6775f75202b66a1a3c0e
@@ -8,7 +8,6 @@ module BootstrapProgressbar
8
8
  end
9
9
  end
10
10
 
11
- # generate a bootstrap progress-bar with a percent and custom options
12
11
  # Params:
13
12
  # +percent+:: +Fixnum+ between 0 to 1.00
14
13
  # +options+::
@@ -42,15 +41,17 @@ module BootstrapProgressbar
42
41
  striped = ""
43
42
  end
44
43
 
45
- clazz = options[:class] if options[:class]
46
-
44
+ clazz = [options[:class], 'progress-bar', alternative, striped].join(' ').strip()
47
45
  unless options[:label]
48
46
  percent_and_label = "<span class='sr-only'>#{percent}%</span>"
49
47
  else
50
48
  percent_and_label = "#{percent}%"
51
49
  end
52
50
 
53
- "<div class='#{[clazz, 'progress-bar', alternative, striped].join(' ').strip()}' role='progressbar' aria-valuenow='#{percent}' aria-valuemin='0' aria-valuemax='100' style='width: #{percent}%'>#{percent_and_label}</div>"
51
+ style = ["width: #{percent}%", options[:style]].join().strip()
52
+ id = " id='#{options[:id]}'" if options[:id]
53
+
54
+ "<div class='#{clazz}'#{id} role='progressbar' aria-valuenow='#{percent}' aria-valuemin='0' aria-valuemax='100' style='#{style}'>#{percent_and_label}</div>"
54
55
  end
55
56
 
56
57
  end
@@ -61,13 +62,13 @@ module BootstrapProgressbar
61
62
  def progress_bar(percent, options = {})
62
63
  Private.check_percent(percent)
63
64
 
64
- if options[:class]
65
- clazz = options[:class]
66
- options[:class] = ""
67
- end
65
+ clazz = [options.delete(:class), 'progress'].join(' ').strip()
66
+ id = " id='#{options.delete(:id)}' " if options[:id]
67
+ style = " style='#{options.delete(:style)}' " if options[:style]
68
+
68
69
  progress_bar = Private.only_progress_bar(percent, options)
69
70
 
70
- raw "<div class='#{[clazz, 'progress'].join(' ').strip()}'>#{progress_bar}</div>"
71
+ raw "<div class='#{clazz}'#{id}#{style}>#{progress_bar}</div>"
71
72
  end
72
73
 
73
74
  # only generate the progress-bar
@@ -1,3 +1,3 @@
1
1
  module BootstrapProgressbar
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -70,4 +70,19 @@ class BootstrapProgressbarTest < ActionView::TestCase
70
70
  assert_equal "<div class='more progress-bar' role='progressbar' aria-valuenow='50' aria-valuemin='0' aria-valuemax='100' style='width: 50%'><span class='sr-only'>50%</span></div>", result
71
71
  end
72
72
 
73
+ test "support selecting an id for progress-bar" do
74
+ result = simple_progress_bar(0.5, id: 'this-progress-bar')
75
+ assert_equal "<div class='progress-bar' id='this-progress-bar' role='progressbar' aria-valuenow='50' aria-valuemin='0' aria-valuemax='100' style='width: 50%'><span class='sr-only'>50%</span></div>", result
76
+ end
77
+
78
+ test "support selecting an id for progress" do
79
+ result = progress_bar(0.5, id: 'this-progress')
80
+ assert_equal "<div class='progress' id='this-progress' ><div class='progress-bar' role='progressbar' aria-valuenow='50' aria-valuemin='0' aria-valuemax='100' style='width: 50%'><span class='sr-only'>50%</span></div></div>", result
81
+ end
82
+
83
+ test "support defining style for progress" do
84
+ result = progress_bar(0.5, style: 'min-width: 20px;')
85
+ assert_equal "<div class='progress' style='min-width: 20px;' ><div class='progress-bar' role='progressbar' aria-valuenow='50' aria-valuemin='0' aria-valuemax='100' style='width: 50%'><span class='sr-only'>50%</span></div></div>", result
86
+ end
87
+
73
88
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_progressbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - spacewander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.3.9
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.3.9
41
41
  description: bootstrap_progressbar makes it super easy to create beautiful-looking
42
42
  progress bar in rails using Bootstrap 3
43
43
  email: