bootstrap_haml_helpers 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dc8b968fe6c95572bb117b884f6a46e457232ca0
4
+ data.tar.gz: 22d253e9dda7202fea56ee64000bfbe832d4c27d
5
+ SHA512:
6
+ metadata.gz: 5a3b3a758d2db12661a500caff6d26097d3a3d254a8de9044238ae74bab3fb5bc379a534f81bc5acc3bb00311a4617d9c512e04ae5c3246c81b319631002a2fb
7
+ data.tar.gz: a711f259f59eddfc99c82c38e423f705c0baa31ecd5b39a711d28b67708766b556cd556084eb1d62bee6f7623a107891d55a6f11fa2bcae8abaebeb9a2a5ecd8
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
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 ADDED
@@ -0,0 +1,21 @@
1
+ lumoslabs/bootstrap_haml_helpers
2
+ ====
3
+
4
+ HAML wrappers for [Twitter Bootstrap](http://getbootstrap.com/2.3.2) components.
5
+
6
+ Integration
7
+ ----
8
+ To integrate our gem into your application, follow these steps:
9
+
10
+ 1. Add it to your gemfile, gem 'bootstrap_haml_helpers'
11
+ 2. bundle
12
+ 3. Add the following line to your main SASS file (typically application.css.sass): `//= require bootstrap_haml_helpers`
13
+ 4. Add the following to your main JS file (typically application.js): `//= require bootstrap_haml_helpers`
14
+
15
+ CI
16
+ ----
17
+ bootstrap_haml_helpers runs on [Travis CI](https://magnum.travis-ci.com/lumoslabs/bootstrap_haml_helpers)
18
+
19
+ Versioning
20
+ ----
21
+ We follow the same version as Twitter Bootstrap (currently 2.3.2). Any patches will fall as a sub-version of the existing patch number (e.g. 2.3.2.1).
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'BootstrapHamlHelpers'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1 @@
1
+ //= require bootstrap
@@ -0,0 +1 @@
1
+ @import 'bootstrap'
@@ -0,0 +1,8 @@
1
+ module BootstrapHamlHelpers
2
+ module ApplicationHelper
3
+
4
+ def container(*args, &block)
5
+ BootstrapHamlHelpers::Scaffolding::Container.build(*args, &block)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,84 @@
1
+ module BootstrapHamlHelpers
2
+ module Component
3
+ class Base
4
+
5
+ include InheritableTraits
6
+ traits :tag_name, :default_css_class, :partial_path
7
+
8
+ cattr_accessor :view_context
9
+ attr_accessor :attributes, :component_options, :content, :content_block, :content_string,
10
+ :controller, :output_buffer
11
+
12
+ def initialize(*args, &block)
13
+ self.component_options = args.extract_options!.symbolize_keys
14
+ self.attributes = component_options.delete(:html).try(:symbolize_keys) || {}
15
+ add_attribute(:class, default_css_class) if default_css_class
16
+ self.content_block = block
17
+ self.content_string = args.first
18
+ end
19
+
20
+ class << self
21
+ def build(*args, &block)
22
+ new(*args, &block).build
23
+ end
24
+
25
+ def init_context(view_context)
26
+ self.view_context = view_context
27
+ self.view_context.extend(Haml::Helpers)
28
+ self.view_context.init_haml_helpers
29
+ end
30
+
31
+ def teardown_context
32
+ self.view_context = nil
33
+ end
34
+ end
35
+
36
+ def content_type
37
+ :html
38
+ end
39
+
40
+ def add_attribute(name, value)
41
+ self.attributes[name] ||= ''
42
+ self.attributes[name] += " #{value}"
43
+ self.attributes[name].squish!
44
+ self
45
+ end
46
+
47
+ def add_attributes(attrs = {})
48
+ attrs.each { |k,v| add_attribute(k.to_sym, v) }
49
+ self
50
+ end
51
+
52
+ def build
53
+ resolve_content
54
+ view_context.content_tag(tag_name, content, attributes)
55
+ end
56
+
57
+ # Useful when building a component with a partial that encapsulates the block/string content
58
+ def block_or_string_content
59
+ content_block ? view_context.capture(self, &content_block) : content_string
60
+ end
61
+
62
+ private
63
+
64
+ # def full_partial_path
65
+ # File.join('/lux/components/', partial_path)
66
+ # end
67
+
68
+ def fluid?
69
+ false # Lux::Engine.config.fluid
70
+ end
71
+
72
+ def resolve_content
73
+ case
74
+ when partial_path
75
+ self.content = view_context.render(:partial => full_partial_path, :locals => {obj: self})
76
+ when content_block
77
+ self.content = view_context.capture(self, &content_block)
78
+ when content_string
79
+ self.content = content_string
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,36 @@
1
+ module BootstrapHamlHelpers::Component
2
+ module InheritableTraits
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def traits(*attrs)
9
+ @traits ||= []
10
+ @traits += attrs
11
+ attrs.each do |attr|
12
+ class_eval %{
13
+ def self.#{attr}(string = nil)
14
+ @#{attr} = string || @#{attr}
15
+ end
16
+ def self.#{attr}=(string = nil)
17
+ #{attr}(string)
18
+ end
19
+ def #{attr}
20
+ self.class.instance_variable_get('@#{attr}')
21
+ end
22
+ }
23
+ end
24
+ @traits
25
+ end
26
+
27
+ def inherited(subclass)
28
+ (["traits"] + traits).each do |t|
29
+ ivar = "@#{t}"
30
+ subclass.instance_variable_set(ivar, instance_variable_get(ivar))
31
+ end
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ module BootstrapHamlHelpers
2
+ module Scaffolding
3
+ class Container < BootstrapHamlHelpers::Component::Base
4
+ tag_name :div
5
+ default_css_class 'container'
6
+
7
+ def default_css_class
8
+ fluid? ? 'container-fluid' : 'container'
9
+ end
10
+
11
+ private
12
+
13
+ def fluid?
14
+ super || component_options[:fluid]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ require 'rails'
2
+ require 'bootstrap_haml_helpers/engine'
3
+
4
+ require "compass-rails"
5
+ require "compass"
6
+ require 'haml'
7
+ require 'sass-rails'
8
+ require 'bootstrap-sass'
9
+
10
+ module BootstrapHamlHelpers
11
+ end
@@ -0,0 +1,16 @@
1
+ module BootstrapHamlHelpers
2
+ module ControllerHelpers
3
+
4
+ def self.included(base)
5
+ base.around_filter :init_bhh_context
6
+ # base.prepend_before_filter :init_page_metadata
7
+ end
8
+
9
+ def init_bhh_context
10
+ BootstrapHamlHelpers::Component::Base.init_context(view_context)
11
+ yield
12
+ ensure
13
+ BootstrapHamlHelpers::Component::Base.teardown_context
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+ require 'bootstrap_haml_helpers/controller_helpers'
3
+
4
+ module BootstrapHamlHelpers
5
+ class Engine < Rails::Engine
6
+ initializer 'bootstrap_haml_helpers.load_helpers' do
7
+ ActiveSupport.on_load(:action_controller) do
8
+ Rails.logger.info "in on_load :action_controller"
9
+ include BootstrapHamlHelpers::ControllerHelpers
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module BootstrapHamlHelpers
2
+ module SpecViewHelpers
3
+ def self.included(base)
4
+ base.class_eval do
5
+ helper BootstrapHamlHelpers::ApplicationHelper if respond_to?(:helper)
6
+
7
+ before do
8
+ if respond_to?(:view)
9
+ BootstrapHamlHelpers::Component::Base.init_context(view)
10
+ view.stub(:set_page_title)
11
+ view.stub(:add_metatag)
12
+ end
13
+ end
14
+
15
+ after do
16
+ BootstrapHamlHelpers::Component::Base.teardown_context if respond_to?(:view)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module BootstrapHamlHelpers
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bootstrap_haml_helpers do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootstrap_haml_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Seung-Hyo Choi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.12
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.12
27
+ - !ruby/object:Gem::Dependency
28
+ name: bootstrap-sass
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: compass-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: compass
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.12.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.12.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: haml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.7
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.1.7
83
+ - !ruby/object:Gem::Dependency
84
+ name: sass-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 3.2.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 3.2.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.14'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '2.14'
125
+ description: Convenient, clean wrappers for Twitter Bootstrap components and scaffolding.
126
+ email:
127
+ - seunghyo@lumoslabs.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - app/assets/javascripts/bootstrap_haml_helpers/index.js
133
+ - app/assets/stylesheets/bootstrap_haml_helpers/index.css.sass
134
+ - app/helpers/bootstrap_haml_helpers/application_helper.rb
135
+ - app/models/bootstrap_haml_helpers/component/base.rb
136
+ - app/models/bootstrap_haml_helpers/component/inheritable_traits.rb
137
+ - app/models/bootstrap_haml_helpers/scaffolding/container.rb
138
+ - lib/bootstrap_haml_helpers/controller_helpers.rb
139
+ - lib/bootstrap_haml_helpers/engine.rb
140
+ - lib/bootstrap_haml_helpers/spec_view_helpers.rb
141
+ - lib/bootstrap_haml_helpers/version.rb
142
+ - lib/bootstrap_haml_helpers.rb
143
+ - lib/tasks/bootstrap_haml_helpers_tasks.rake
144
+ - MIT-LICENSE
145
+ - Rakefile
146
+ - README.md
147
+ homepage: http://www.lumosity.com
148
+ licenses: []
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.0.14
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Convenient, clean wrappers for Twitter Bootstrap components and scaffolding.
170
+ test_files: []
171
+ has_rdoc: