tabs_for 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5e88929bd1f6434c1dda24591e39aa8abce256f
4
- data.tar.gz: 310b909b1f575c8121b515b6b73e2b62a37b8986
3
+ metadata.gz: ee0b5e67d43ceb27a8ebdfc278c901226e67dfbd
4
+ data.tar.gz: 71ccc58a76c40480818abeb1c28f11b2bff13c56
5
5
  SHA512:
6
- metadata.gz: eb50966d68b7b228daa1f786a378ad197314d0fb5613a5f9028e0b8564ea91afe44bd35d767b63cb517a1df8fb62b813cf3b4a477a0c28550a9ee7d6b5e832ca
7
- data.tar.gz: 6f2325ea924dd037bb804e29b000e862999d7f20f3740eddf95038816bee7c71a2d99c3c769d65283e746552efef59dcd8871b25d558fa96b43149fe4cc86ad1
6
+ metadata.gz: e7ddaf6e5b9462a5600f95427f51a0f2867f9dbd199fa34cef5d59cc16f1929d79d441b7459e1208044cc5c33d8b7de23f73018c359b8ecd95c50981becdebbf
7
+ data.tar.gz: bdc99ab34263cf353a6849e7e04f6b978a3d830b98685a0a9dbc67e3726cdea85d08d3f743e65770b5bd2919c6fe8f9d8be147df9245e94ec612d7eb610f10c6
data/.gitignore CHANGED
@@ -1,10 +1,10 @@
1
1
  *.gem
2
- /.bundle/
3
- /.yardoc
4
- /Gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
2
+ .bundle/
3
+ coverage/
4
+ log/*.log
5
+ pkg/
6
+ test/dummy/db/*.sqlite3
7
+ test/dummy/db/*.sqlite3-journal
8
+ test/dummy/log/*.log
9
+ test/dummy/tmp/
10
+ test/dummy/.sass-cache
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.1] 2015-09-05
4
+ ## Changed
5
+ - Use minitest instead of rspec
6
+
3
7
  ## [0.1.0] 2015-08-12
4
8
  ### Added
5
9
  - Initial release. Handles tabs with panes. Supported options are
data/Gemfile CHANGED
@@ -1,4 +1,15 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in tabs_for.gemspec
3
+ # Declare your gem's dependencies in tabs_for.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
4
6
  gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ # gem 'byebug', group: [:development, :test]
15
+
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tabs_for (0.1.1)
5
+ railties (>= 3.2, < 5.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (4.2.4)
11
+ actionview (= 4.2.4)
12
+ activesupport (= 4.2.4)
13
+ rack (~> 1.6)
14
+ rack-test (~> 0.6.2)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (4.2.4)
18
+ activesupport (= 4.2.4)
19
+ builder (~> 3.1)
20
+ erubis (~> 2.7.0)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ activesupport (4.2.4)
24
+ i18n (~> 0.7)
25
+ json (~> 1.7, >= 1.7.7)
26
+ minitest (~> 5.1)
27
+ thread_safe (~> 0.3, >= 0.3.4)
28
+ tzinfo (~> 1.1)
29
+ builder (3.2.2)
30
+ coveralls (0.8.2)
31
+ json (~> 1.8)
32
+ rest-client (>= 1.6.8, < 2)
33
+ simplecov (~> 0.10.0)
34
+ term-ansicolor (~> 1.3)
35
+ thor (~> 0.19.1)
36
+ docile (1.1.5)
37
+ domain_name (0.5.24)
38
+ unf (>= 0.0.5, < 1.0.0)
39
+ erubis (2.7.0)
40
+ http-cookie (1.0.2)
41
+ domain_name (~> 0.5)
42
+ i18n (0.7.0)
43
+ json (1.8.3)
44
+ loofah (2.0.3)
45
+ nokogiri (>= 1.5.9)
46
+ mime-types (2.6.1)
47
+ mini_portile (0.6.2)
48
+ minitest (5.8.0)
49
+ netrc (0.10.3)
50
+ nokogiri (1.6.6.2)
51
+ mini_portile (~> 0.6.0)
52
+ rack (1.6.4)
53
+ rack-test (0.6.3)
54
+ rack (>= 1.0)
55
+ rails-deprecated_sanitizer (1.0.3)
56
+ activesupport (>= 4.2.0.alpha)
57
+ rails-dom-testing (1.0.7)
58
+ activesupport (>= 4.2.0.beta, < 5.0)
59
+ nokogiri (~> 1.6.0)
60
+ rails-deprecated_sanitizer (>= 1.0.1)
61
+ rails-html-sanitizer (1.0.2)
62
+ loofah (~> 2.0)
63
+ railties (4.2.4)
64
+ actionpack (= 4.2.4)
65
+ activesupport (= 4.2.4)
66
+ rake (>= 0.8.7)
67
+ thor (>= 0.18.1, < 2.0)
68
+ rake (10.4.2)
69
+ rest-client (1.8.0)
70
+ http-cookie (>= 1.0.2, < 2.0)
71
+ mime-types (>= 1.16, < 3.0)
72
+ netrc (~> 0.7)
73
+ simplecov (0.10.0)
74
+ docile (~> 1.1.0)
75
+ json (~> 1.8)
76
+ simplecov-html (~> 0.10.0)
77
+ simplecov-html (0.10.0)
78
+ term-ansicolor (1.3.2)
79
+ tins (~> 1.0)
80
+ thor (0.19.1)
81
+ thread_safe (0.3.5)
82
+ tins (1.6.0)
83
+ tzinfo (1.2.2)
84
+ thread_safe (~> 0.1)
85
+ unf (0.1.4)
86
+ unf_ext
87
+ unf_ext (0.0.7.1)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ coveralls
94
+ tabs_for!
95
+
96
+ BUNDLED WITH
97
+ 1.10.3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Ole J. Rosendahl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
  [codeclimate]: https://codeclimate.com/github/blacktangent/tabs_for
3
3
  [fontawesome]: https://fortawesome.github.io/Font-Awesome
4
4
  [fontawesomerails]: https://github.com/bokmann/font-awesome-rails
5
+ [coveralls]: https://coveralls.io/r/blacktangent/tabs_for
5
6
 
6
7
  # TabsFor
7
8
 
8
9
  [![Build Status](https://travis-ci.org/blacktangent/tabs_for.svg?branch=master)][travis]
9
10
  [![Code Climate](https://codeclimate.com/github/blacktangent/tabs_for/badges/gpa.svg)][codeclimate]
10
- [![Test Coverage](https://codeclimate.com/github/blacktangent/tabs_for/badges/coverage.svg)][codeclimate]
11
+ [![Test Coverage](http://img.shields.io/coveralls/blacktangent/tabs_for/master.svg)][coveralls]
11
12
 
12
13
  ActiveView Helper for creating tabs with Bootstrap.
13
14
 
@@ -31,8 +32,7 @@ The gem depends on [Bootstrap 3](http://getbootstrap.com/) to create the tabs. B
31
32
  your project by using [Bootstrap for Sass](https://github.com/twbs/bootstrap-sass) or you preferred method.
32
33
 
33
34
  Preferred icon and CSS framework is [Font Awesome][fontawesome] and the `help` option uses
34
- [Font Awesome][fontawesome] to display the help icon. This dependency
35
- could easily be removed in the future.
35
+ [Font Awesome][fontawesome] to display the help icon.
36
36
  Bring [Font Awesome][fontawesome] into your project by using
37
37
  [font-awesome-rails][fontawesomerails] or your preferred method.
38
38
 
data/Rakefile CHANGED
@@ -1,6 +1,34 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
3
6
 
4
- RSpec::Core::RakeTask.new(:spec)
7
+ require 'rdoc/task'
5
8
 
6
- task :default => :spec
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'TabsFor'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,111 @@
1
+ module TabsFor
2
+ module Rails
3
+ module TabsForHelper
4
+
5
+ def tabs_for(object, &block)
6
+ content_tag(:ul, :class => "nav nav-tabs", :role => "tablist") do
7
+ capture TabBuilder.new(object, self), &block
8
+ end + content_tag(:div, :class => "tab-content") do
9
+ capture PaneBuilder.new(object, self), &block
10
+ end
11
+ end
12
+
13
+ class ViewBuilder
14
+ include ActionView::Helpers
15
+
16
+ attr_accessor :object, :template, :output_buffer
17
+
18
+ def initialize(object, template)
19
+ @object, @template = object, template
20
+ end
21
+
22
+ private
23
+
24
+ def identifier(attribute)
25
+ attribute.to_s.downcase
26
+ end
27
+
28
+ end
29
+
30
+ class TabBuilder < ViewBuilder
31
+
32
+ def tab(attribute, options = {})
33
+ content = if options[:label]
34
+ options.delete(:label)
35
+ elsif object.respond_to? attribute
36
+ human_name attribute
37
+ else
38
+ attribute.to_s.titleize
39
+ end
40
+
41
+ options[:id] ||= identifier(attribute)
42
+
43
+ if options[:size]
44
+ content += " " + content_tag(:span, options[:size], :class => "badge")
45
+ end
46
+
47
+ content_tag(:li, apply_options(attribute, options)) do
48
+ link_to "#" + identifier(attribute), apply_link_options(attribute, options) do
49
+ options[:icon] ? wrap_with_icon(content.html_safe, options) : content.html_safe
50
+ end
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def apply_link_options(attribute, options)
57
+ {
58
+ "aria-controls" => identifier(attribute),
59
+ "data-toggle" => "tab",
60
+ :role => "tab",
61
+ }
62
+ end
63
+
64
+ def apply_options(attribute, options)
65
+ {
66
+ :role => "presentation",
67
+ :class => options[:active] ? "active" : nil,
68
+ }
69
+ end
70
+
71
+ def human_name(attribute_name)
72
+ object.class.human_attribute_name attribute_name
73
+ end
74
+
75
+ def wrap_with_icon(content, options = {})
76
+ content_tag(:i, " ".html_safe + content, :class => options[:icon])
77
+ end
78
+
79
+ end
80
+
81
+ class PaneBuilder < ViewBuilder
82
+
83
+ def tab(attribute, options = {}, &block)
84
+ content = "".html_safe
85
+
86
+ if options[:help]
87
+ content += tag(:br)
88
+ content += content_tag(:p) do
89
+ content_tag(:i, " #{options[:help]}".html_safe, class: "fa fa-info-circle")
90
+ end
91
+ end
92
+
93
+ content += template.capture(&block)
94
+
95
+ content_tag(:div, content, apply_options(attribute, options))
96
+ end
97
+
98
+ private
99
+
100
+ def apply_options(attribute, options)
101
+ {
102
+ :role => "tabpanel",
103
+ :class => "tab-pane" + (options[:active] ? " active" : ""),
104
+ :id => options[:id] ? options[:id] : identifier(attribute),
105
+ }
106
+ end
107
+
108
+ end
109
+ end
110
+ end
111
+ end
@@ -1,3 +1,3 @@
1
1
  module TabsFor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/tabs_for.rb CHANGED
@@ -1,9 +1,2 @@
1
1
  require "tabs_for/version"
2
- require "rails/engine"
3
2
  require "tabs_for/engine"
4
- require "action_view"
5
- require "helpers/tabs_for/tabs_for_helper"
6
-
7
- module TabsFor
8
- # Your code goes here...
9
- end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :tabs_for do
3
+ # # Task goes here
4
+ # end
data/tabs_for.gemspec CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.bindir = "exe"
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib", "app"]
19
+ spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "rails", "~> 4.0"
21
+ spec.required_ruby_version = '>= 1.9.3'
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 2.3"
23
+ spec.add_dependency "railties", ">= 3.2", "< 5.0"
24
+
25
+ spec.add_development_dependency "coveralls"
26
26
  end
metadata CHANGED
@@ -1,71 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabs_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ole J. Rosendahl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '3.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '4.0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
27
+ - - ">="
32
28
  - !ruby/object:Gem::Version
33
- version: '1.10'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
29
+ version: '3.2'
30
+ - - "<"
39
31
  - !ruby/object:Gem::Version
40
- version: '1.10'
32
+ version: '5.0'
41
33
  - !ruby/object:Gem::Dependency
42
- name: rake
34
+ name: coveralls
43
35
  requirement: !ruby/object:Gem::Requirement
44
36
  requirements:
45
- - - "~>"
37
+ - - ">="
46
38
  - !ruby/object:Gem::Version
47
- version: '10.0'
39
+ version: '0'
48
40
  type: :development
49
41
  prerelease: false
50
42
  version_requirements: !ruby/object:Gem::Requirement
51
43
  requirements:
52
- - - "~>"
44
+ - - ">="
53
45
  - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '2.3'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '2.3'
46
+ version: '0'
69
47
  description: ActiveView Helper for creating tabs with Bootstrap.
70
48
  email:
71
49
  - ole.johnny.rosendahl@gmail.com
@@ -79,15 +57,18 @@ files:
79
57
  - CHANGELOG.md
80
58
  - CODE_OF_CONDUCT.md
81
59
  - Gemfile
60
+ - Gemfile.lock
82
61
  - LICENSE.txt
62
+ - MIT-LICENSE
83
63
  - README.md
84
64
  - Rakefile
85
- - app/helpers/tabs_for/tabs_for_helper.rb
65
+ - app/helpers/tabs_for/rails/tabs_for_helper.rb
86
66
  - bin/console
87
67
  - bin/setup
88
68
  - lib/tabs_for.rb
89
69
  - lib/tabs_for/engine.rb
90
70
  - lib/tabs_for/version.rb
71
+ - lib/tasks/tabs_for_tasks.rake
91
72
  - tabs_for.gemspec
92
73
  homepage: https://github.com/blacktangent/tabs_for
93
74
  licenses:
@@ -97,12 +78,11 @@ post_install_message:
97
78
  rdoc_options: []
98
79
  require_paths:
99
80
  - lib
100
- - app
101
81
  required_ruby_version: !ruby/object:Gem::Requirement
102
82
  requirements:
103
83
  - - ">="
104
84
  - !ruby/object:Gem::Version
105
- version: '0'
85
+ version: 1.9.3
106
86
  required_rubygems_version: !ruby/object:Gem::Requirement
107
87
  requirements:
108
88
  - - ">="
@@ -1,110 +0,0 @@
1
- module TabsFor
2
- module TabsForHelper
3
-
4
- def tabs_for(object, &block)
5
- content_tag(:ul, :class => "nav nav-tabs", :role => "tablist") do
6
- capture TabBuilder.new(object, self), &block
7
- end + content_tag(:div, :class => "tab-content") do
8
- capture PaneBuilder.new(object, self), &block
9
- end
10
- end
11
-
12
- class ViewBuilder
13
- include ActionView::Helpers
14
-
15
- attr_accessor :object, :template, :output_buffer
16
-
17
- def initialize(object, template)
18
- @object, @template = object, template
19
- end
20
-
21
- private
22
-
23
- def identifier(attribute)
24
- attribute.to_s.downcase
25
- end
26
-
27
- end
28
-
29
- class TabBuilder < ViewBuilder
30
-
31
- def tab(attribute, options = {})
32
- content = if options[:label]
33
- options.delete(:label)
34
- elsif object.respond_to? attribute
35
- human_name attribute
36
- else
37
- attribute.to_s.titleize
38
- end
39
-
40
- options[:id] ||= identifier(attribute)
41
-
42
- if options[:size]
43
- content += " " + content_tag(:span, options[:size], :class => "badge")
44
- end
45
-
46
- content_tag(:li, apply_options(attribute, options)) do
47
- link_to "#" + identifier(attribute), apply_link_options(attribute, options) do
48
- options[:icon] ? wrap_with_icon(content.html_safe, options) : content.html_safe
49
- end
50
- end
51
- end
52
-
53
- private
54
-
55
- def apply_link_options(attribute, options)
56
- {
57
- "aria-controls" => identifier(attribute),
58
- "data-toggle" => "tab",
59
- :role => "tab",
60
- }
61
- end
62
-
63
- def apply_options(attribute, options)
64
- {
65
- :role => "presentation",
66
- :class => options[:active] ? "active" : nil,
67
- }
68
- end
69
-
70
- def human_name(attribute_name)
71
- object.class.human_attribute_name attribute_name
72
- end
73
-
74
- def wrap_with_icon(content, options = {})
75
- content_tag(:i, " ".html_safe + content, :class => options[:icon])
76
- end
77
-
78
- end
79
-
80
- class PaneBuilder < ViewBuilder
81
-
82
- def tab(attribute, options = {}, &block)
83
- content = "".html_safe
84
-
85
- if options[:help]
86
- content += tag(:br)
87
- content += content_tag(:p) do
88
- content_tag(:i, " #{options[:help]}".html_safe, class: "fa fa-info-circle")
89
- end
90
- end
91
-
92
- content += template.capture(&block)
93
-
94
- content_tag(:div, content, apply_options(attribute, options))
95
- end
96
-
97
- private
98
-
99
- def apply_options(attribute, options)
100
- {
101
- :role => "tabpanel",
102
- :class => "tab-pane" + (options[:active] ? " active" : ""),
103
- :id => options[:id] ? options[:id] : identifier(attribute),
104
- }
105
- end
106
-
107
- end
108
-
109
- end
110
- end