klassnames 1.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: 1cf6875d871df52001c7161f5d64411390c1697e
4
+ data.tar.gz: 7f3e7abc612263e386e9b3566eab175ffe3d6390
5
+ SHA512:
6
+ metadata.gz: 8b560cafa1df449521b1e2b362dd0036f7e52e808b3b5606724b57e8ca24adea5010e2969c55446189460b1521e74a75201dd03ad0e5b012f8d3669a31a30022
7
+ data.tar.gz: 72f220b5a036680f417fc69faa1d108b6bcce0dc2196786d510c288cca820add64c84f302f3f6cad153ff16d5af2cf04d31b69a85020dca70ad7385672197de9
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require rails_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.15.4
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Florent Ferry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Klassnames
2
+
3
+ View helper to simplify conditional class in view.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'klassnames'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ div(class=classnames("one", "two", three: true))
17
+ => <div class="one two three"></div>
18
+ ```
19
+
20
+ ## License
21
+
22
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "klassnames"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "klassnames/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "klassnames"
8
+ spec.version = Klassnames::VERSION
9
+ spec.authors = ["Komposable"]
10
+ spec.email = ["contact@komposable.io"]
11
+
12
+ spec.summary = "View helper to simplify conditional class in view"
13
+ spec.description = "View helper to simplify conditional class in view"
14
+ spec.homepage = "https://github.com/komposable/klassnames"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "rspec-rails", "~> 3.6"
24
+ end
data/lib/klassnames.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "klassnames/version"
2
+
3
+ module Klassnames
4
+ require 'klassnames/railtie' if defined?(Rails)
5
+ end
@@ -0,0 +1,20 @@
1
+ module ClassnamesHelper
2
+ def classnames(*args)
3
+ classes = []
4
+
5
+ args.each do |arg|
6
+ case arg
7
+ when String
8
+ classes.push(arg) if arg.strip.size > 0
9
+ when Hash
10
+ arg.each do |k, v|
11
+ classes.push(k.to_s) if v == true
12
+ end
13
+ when Array
14
+ classes.push(classnames(*arg))
15
+ end
16
+ end
17
+
18
+ classes.join(" ")
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ require 'klassnames/classnames_helper'
2
+
3
+ module Klassnames
4
+ class Railtie < Rails::Railtie
5
+ initializer "classnames.helper" do |app|
6
+ ActionView::Base.send :include, ClassnamesHelper
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Klassnames
2
+ VERSION = "1.0.2"
3
+ end
data/log/test.log ADDED
File without changes
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: klassnames
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Komposable
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.6'
27
+ description: View helper to simplify conditional class in view
28
+ email:
29
+ - contact@komposable.io
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - bin/console
42
+ - bin/setup
43
+ - klassnames.gemspec
44
+ - lib/klassnames.rb
45
+ - lib/klassnames/classnames_helper.rb
46
+ - lib/klassnames/railtie.rb
47
+ - lib/klassnames/version.rb
48
+ - log/test.log
49
+ homepage: https://github.com/komposable/klassnames
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.6.13
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: View helper to simplify conditional class in view
73
+ test_files: []