bh 0.0.2 → 0.0.3

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: e69edccfc681f4a4d24ba2d5212ab4f609b7f15e
4
- data.tar.gz: e9cb987e0b6d6dbf58342169d5cb37088167a93f
3
+ metadata.gz: fd20f354ba7792ddb18ca83618d77b0510bbc3c8
4
+ data.tar.gz: 447b0f2f6e06aaabbba876616a29db1d2a4e577f
5
5
  SHA512:
6
- metadata.gz: 4b20a81f7e2b445f9fc263b80c5a72f1f3a72caafaa562752129f72843bf67b0424d2ef6bfddee5c2d3abdb737bd926c70d31adcb50f2cd668fe85402b9c5c58
7
- data.tar.gz: 891b720e5fb99e30003fc13410956750d862c71089fc3eb19e2ebe3147ae099d402f47084a5324f342c5dd0169eab2d8abcb180a7b047688d876f36368a39232
6
+ metadata.gz: 0d18cd3d04c5d8f1af19bf3ead08f17e27045b4c592ba7e68ed72e9b1102ad9d922ae8f14036a69872aeceadedda75aebf3679704b03d1d6dcedb7762ee897dc
7
+ data.tar.gz: b0de752c4c5cd633e5683f1cf6bba061cc16eea865165b12d7e5f5adaee5a33233ea28248431d5b4108f07aa768a4912cd22b0e2aa1a8cbe1b0e1542b881c733
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ notifications:
3
+ email: true
4
+ matrix:
5
+ include:
6
+ - rvm: 1.9.3
7
+ gemfile: gemfiles/Gemfile.rails-3.x
8
+ - rvm: 2.0.0
9
+ gemfile: gemfiles/Gemfile.rails-4.x
@@ -6,6 +6,10 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.0.3 - 2014-08-15
10
+
11
+ * [FEATURE] Add `bootstrap_css`, `bootstrap_theme_css` and `bootstrap_js`
12
+
9
13
  ## 0.0.2 - 2014-08-15
10
14
 
11
15
  * [FEATURE] Add `alert_box` helper
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gem 'pry'
2
+
3
3
  # Specify your gem's dependencies in bh.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,9 +1,18 @@
1
1
  Bh - Bootstrap Helpers
2
2
  ======================
3
3
 
4
- Bh provides a set of powerful helpers that streamlines the use of
4
+ Bh provides a set of helpers that streamlines the use of
5
5
  [Bootstrap components](http://getbootstrap.com/components) in Rails views.
6
6
 
7
+ The **full documentation** is available at [rubydoc.info](http://rubydoc.info/github/Fullscreen/bh/master/frames).
8
+
9
+ [![Build Status](http://img.shields.io/travis/Fullscreen/bh/master.svg)](https://travis-ci.org/Fullscreen/bh)
10
+ [![Coverage Status](http://img.shields.io/coveralls/Fullscreen/bh/master.svg)](https://coveralls.io/r/Fullscreen/bh)
11
+ [![Dependency Status](http://img.shields.io/gemnasium/Fullscreen/bh.svg)](https://gemnasium.com/Fullscreen/bh)
12
+ [![Code Climate](http://img.shields.io/codeclimate/github/Fullscreen/bh.svg)](https://codeclimate.com/github/Fullscreen/bh)
13
+ [![Online docs](http://img.shields.io/badge/docs-✓-green.svg)](http://rubydoc.info/github/Fullscreen/bh/master/frames)
14
+ [![Gem Version](http://img.shields.io/gem/v/bh.svg)](http://rubygems.org/gems/bh)
15
+
7
16
  Bootstrap is a great framework, but requires to write many lines of HTML code
8
17
  even for simple components.
9
18
  For instance, you need to write the following HTML to show a _dismissible alert_:
@@ -22,7 +31,7 @@ Writing this for every _dismissible alert_ in a web site is cumbersome,
22
31
  repetitive, and prone to errors.
23
32
 
24
33
  Bh offers a solution to this problem by means of a set of helper methods.
25
- The example above can be with just one line of code:
34
+ The example above can be rewritten with just one line of code:
26
35
 
27
36
  ```erb
28
37
  <%= alert_box 'You accepted the Terms of service.', dismissible: true %>
@@ -37,7 +46,7 @@ How to install
37
46
 
38
47
  Bh is meant to be included in Rails apps by adding this line to the Gemfile:
39
48
 
40
- gem 'bh', '~> 0.0.2'
49
+ gem 'bh', '~> 0.0.3'
41
50
 
42
51
  Since the gem follows [Semantic Versioning](http://semver.org),
43
52
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -47,11 +56,11 @@ and a new version of Bh is released.
47
56
  Adding 'bh' to your Gemfile is all you need!
48
57
  From now on, you will be able to use any of the following Bh helpers in your Rails views.
49
58
 
50
- The `alert_box` helper
51
- ======================
59
+ AlertHelper
60
+ ===========
52
61
 
53
62
  To include [Boostrap alert boxes](http://getbootstrap.com/components/#alerts)
54
- in your Rails views, you can use the [alert_box](#doc) helper.
63
+ in your Rails views, you can use the [alert_box](http://rubydoc.info/github/Fullscreen/bh/master/Bh/AlertHelper) helper.
55
64
  Here are some examples.
56
65
 
57
66
  Basic alerts
@@ -155,6 +164,49 @@ highlighted text and appropriately styled links:
155
164
 
156
165
  ![alert-complex](https://cloud.githubusercontent.com/assets/7408595/3936903/7c1b70f0-24a7-11e4-95ee-11f6920ddd4d.png)
157
166
 
167
+ CdnHelper
168
+ =========
169
+
170
+ To load the CSS and JS files of Bootstrap from
171
+ [BootstrapCDN](http://getbootstrap.com/getting-started/#download), you can use
172
+ the [bootstrap_css](http://rubydoc.info/github/Fullscreen/bh/master/Bh/CdnHelper),
173
+ [bootstrap_theme_css](http://rubydoc.info/github/Fullscreen/bh/master/Bh/CdnHelper) and
174
+ [bootstrap_js](http://rubydoc.info/github/Fullscreen/bh/master/Bh/CdnHelper) helpers.
175
+ Here are some examples.
176
+
177
+ Load the latest Bootstrap assets
178
+ --------------------------------
179
+
180
+ ```erb
181
+ <%= stylesheet_link_tag bootstrap_css, bootstrap_theme_css, :application %>
182
+ <%= javascript_include_tag bootstrap_js, :application %>
183
+ ```
184
+
185
+ will generate the HTML to load the latest versions of Bootstrap CSS, Bootstrap
186
+ Theme CSS and Bootstrap JS from MaxCDN, before your application assets:
187
+
188
+ ```html
189
+ <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
190
+ <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" media="screen" rel="stylesheet" type="text/css" />
191
+ <link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" />
192
+
193
+ <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" type="text/javascript"></script>
194
+ <script src="/assets/application.js" type="text/javascript"></script>
195
+ ```
196
+
197
+ Load a specific version of a Bootstrap asset
198
+ --------------------------------------------
199
+
200
+ ```erb
201
+ <%= stylesheet_link_tag bootstrap_css(version: '3.1.0', minified: false, scheme: :http) %>
202
+ ```
203
+
204
+ will generate the HTML to load the non-minified 3.1.0 versions of Bootstrap CSS
205
+ over HTTP scheme:
206
+
207
+ ```html
208
+ <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
209
+ ```
158
210
 
159
211
  How to release new versions
160
212
  ===========================
@@ -178,7 +230,8 @@ Bh needs your support!
178
230
 
179
231
  If you find that a method is missing, fork the project, add the missing code,
180
232
  write the appropriate tests, then submit a pull request, and it will gladly
181
- be merged! If you need an inspiration, look at the TODO.md file.
233
+ be merged! If you need an inspiration, look at the
234
+ [TODO](https://github.com/Fullscreen/bh/blob/master/TODO.md).
182
235
 
183
236
  To run the tests, simply type `rspec` on the command line.
184
237
 
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'activesupport', '~> 3.0'
4
+ gem 'actionpack', '~> 3.0'
5
+ gemspec path: '../'
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'activesupport', '~> 4.0'
4
+ gem 'actionpack', '~> 4.0'
5
+ gemspec path: '../'
@@ -0,0 +1,50 @@
1
+ module Bh
2
+ # Provides methods to retrieve the URLs of Bootstrap stylesheets and
3
+ # Javascript files from Bootstrap CDN
4
+ # @see http://www.bootstrapcdn.com
5
+ module CdnHelper
6
+ # @return [String] the URL of the Bootstrap CSS file
7
+ # @param [Hash] options the options for which CSS file to retrieve.
8
+ # @option options [String] :version the version of Bootstrap.
9
+ # @option options [String] :scheme the URI scheme to use.
10
+ # @option options [Boolean] :minified whether to use the minified version.
11
+ def bootstrap_css(options = {})
12
+ bootstrap_asset options.merge(name: 'bootstrap', extension: 'css')
13
+ end
14
+
15
+ # @return [String] the URL of the Bootstrap Theme CSS file
16
+ # @param [Hash] options the options for which CSS file to retrieve.
17
+ # @option options [String] :version the version of Bootstrap.
18
+ # @option options [String] :scheme the URI scheme to use.
19
+ # @option options [Boolean] :minified whether to use the minified version.
20
+ def bootstrap_theme_css(options = {})
21
+ bootstrap_asset options.merge(name: 'bootstrap-theme', extension: 'css')
22
+ end
23
+
24
+ # @return [String] the URL of the Bootstrap JS file
25
+ # @param [Hash] options the options for which JS file to retrieve.
26
+ # @option options [String] :version the version of Bootstrap.
27
+ # @option options [String] :scheme the URI scheme to use.
28
+ # @option options [Boolean] :minified whether to use the minified version.
29
+ def bootstrap_js(options = {})
30
+ bootstrap_asset options.merge(name: 'bootstrap', extension: 'js')
31
+ end
32
+
33
+ private
34
+
35
+ # @return [String] the version of Bootstrap assets to use if unspecified.
36
+ def bootstrap_version
37
+ '3.2.0'
38
+ end
39
+
40
+ def bootstrap_asset(options = {})
41
+ version = options.fetch :version, bootstrap_version
42
+ extension = options[:extension]
43
+ name = options[:name]
44
+ name = "#{name}.min" if options.fetch(:minified, true)
45
+ scheme = "#{options[:scheme]}:" if options[:scheme]
46
+ host = '//netdna.bootstrapcdn.com'
47
+ "#{scheme}#{host}/bootstrap/#{version}/#{extension}/#{name}.#{extension}"
48
+ end
49
+ end
50
+ end
@@ -1,10 +1,12 @@
1
1
  require 'bh/helpers/alert_helper'
2
+ require 'bh/helpers/cdn_helper'
2
3
  require 'bh/helpers/url_helper'
3
4
 
4
5
  module Bh
5
6
  class Railtie < Rails::Railtie
6
7
  initializer 'bh.add_helpers' do
7
8
  ActionView::Base.send :include, AlertHelper
9
+ ActionView::Base.send :include, CdnHelper
8
10
  ActionView::Base.send :include, UrlHelper
9
11
  end
10
12
  end
@@ -1,3 +1,3 @@
1
1
  module Bh
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'bh/helpers/alert_helper'
3
5
  require 'bh/helpers/url_helper'
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+ require 'bh/helpers/cdn_helper'
3
+ require 'open-uri'
4
+ include Bh::CdnHelper
5
+
6
+ describe 'bootstrap_css' do
7
+ let(:file) { open bootstrap_css(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
8
+
9
+ describe 'with the HTTP scheme, links to an existing file' do
10
+ let(:options) { {scheme: :http} }
11
+ it{ expect(file).to be }
12
+ end
13
+
14
+ describe 'with the HTTPS scheme, links to an existing file' do
15
+ let(:options) { {scheme: :https} }
16
+ it{ expect(file).to be }
17
+ end
18
+
19
+ describe 'non-minified, links to an existing file' do
20
+ let(:options) { {scheme: :http, minified: false} }
21
+ it{ expect(file).to be }
22
+ end
23
+
24
+ describe 'given a legacy version, links to an existing file' do
25
+ let(:options) { {scheme: :https, version: '3.1.0'} }
26
+ it{ expect(file).to be }
27
+ end
28
+ end
29
+
30
+ describe 'bootstrap_theme_css' do
31
+ let(:file) { open bootstrap_theme_css(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
32
+
33
+ describe 'with the HTTP scheme, links to an existing file' do
34
+ let(:options) { {scheme: :http} }
35
+ it{ expect(file).to be }
36
+ end
37
+
38
+ describe 'with the HTTPS scheme, links to an existing file' do
39
+ let(:options) { {scheme: :https} }
40
+ it{ expect(file).to be }
41
+ end
42
+
43
+ describe 'non-minified, links to an existing file' do
44
+ let(:options) { {scheme: :http, minified: false} }
45
+ it{ expect(file).to be }
46
+ end
47
+
48
+ describe 'given a legacy version, links to an existing file' do
49
+ let(:options) { {scheme: :https, version: '3.1.0'} }
50
+ it{ expect(file).to be }
51
+ end
52
+ end
53
+
54
+ describe 'bootstrap_js' do
55
+ let(:file) { open bootstrap_js(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
56
+
57
+ describe 'with the HTTP scheme, links to an existing file' do
58
+ let(:options) { {scheme: :http} }
59
+ it{ expect(file).to be }
60
+ end
61
+
62
+ describe 'with the HTTPS scheme, links to an existing file' do
63
+ let(:options) { {scheme: :https} }
64
+ it{ expect(file).to be }
65
+ end
66
+
67
+ describe 'non-minified, links to an existing file' do
68
+ let(:options) { {scheme: :http, minified: false} }
69
+ it{ expect(file).to be }
70
+ end
71
+
72
+ describe 'given a legacy version, links to an existing file' do
73
+ let(:options) { {scheme: :https, version: '3.1.0'} }
74
+ it{ expect(file).to be }
75
+ end
76
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-15 00:00:00.000000000 Z
11
+ date: 2014-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -117,6 +117,7 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
+ - ".travis.yml"
120
121
  - CHANGELOG.md
121
122
  - Gemfile
122
123
  - MIT-LICENSE
@@ -124,12 +125,16 @@ files:
124
125
  - Rakefile
125
126
  - TODO.md
126
127
  - bh.gemspec
128
+ - gemfiles/Gemfile.rails-3.x
129
+ - gemfiles/Gemfile.rails-4.x
127
130
  - lib/bh.rb
128
131
  - lib/bh/helpers/alert_helper.rb
132
+ - lib/bh/helpers/cdn_helper.rb
129
133
  - lib/bh/helpers/url_helper.rb
130
134
  - lib/bh/railtie.rb
131
135
  - lib/bh/version.rb
132
136
  - spec/helpers/alert_helper_spec.rb
137
+ - spec/helpers/cdn_helper_spec.rb
133
138
  - spec/helpers/url_helper_spec.rb
134
139
  - spec/spec_helper.rb
135
140
  homepage: http://github.com/Fullscreen/bh
@@ -159,6 +164,7 @@ summary: Bh provides a set of powerful helpers that streamlines the use of Boots
159
164
  components in Rails views.
160
165
  test_files:
161
166
  - spec/helpers/alert_helper_spec.rb
167
+ - spec/helpers/cdn_helper_spec.rb
162
168
  - spec/helpers/url_helper_spec.rb
163
169
  - spec/spec_helper.rb
164
170
  has_rdoc: