classnames-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3a31fb801d8899bf3af2f88f410b6721a86c43df
4
+ data.tar.gz: 4342cadaab9e699ad82be18c63c6a65475ca49f9
5
+ SHA512:
6
+ metadata.gz: 17f1c4c296c3482c24316a456b8bd4b8a807f37c956d18e5d7f6f7d533d917e3d263fc4d812bea88c9a83f906ab6c621761d2002461426ba6dc6036fce9b8502
7
+ data.tar.gz: c6d0d4a1767d36de756b6120de860378647d3705c2bc779797361ce47eafaf851ec610214cff77dd3643c7e24ee9430fdd404d790703919d39c99c15c4d37adf
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in classnames-rails.gemspec
4
+ gemspec
@@ -0,0 +1,71 @@
1
+ # classnames-rails
2
+ Classnames for Rails - a gem package fork from [classnames](https://github.com/JedWatson/classnames).
3
+ A simple javascript utility for conditionally joining classNames together.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'classnames-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install classnames-rails
20
+
21
+
22
+ Remember!! Add the line below in your `application.js`
23
+
24
+ //= require classnames
25
+
26
+ If you need to use dedupe version(option)
27
+
28
+ //= require classnames-dedupe
29
+
30
+ But notice it slow(10x) than original version.
31
+
32
+ That's it and you can use `classNames` in Rails now.
33
+
34
+ ## Usage
35
+
36
+ In javascript file you can establish complexity class names together for example:
37
+
38
+ ```js
39
+ var navClass = classNames("navbar", "navbar-default");
40
+ // "navbar navbar-default"
41
+
42
+ var navClass = classNames({
43
+ "navbar": true,
44
+ "navbar-default": false
45
+ "hidden": false
46
+ });
47
+ // "navbar"
48
+
49
+ // More examples...
50
+ classNames('foo', 'bar'); // => 'foo bar'
51
+ classNames('foo', { bar: true }); // => 'foo bar'
52
+ classNames({ foo: true }, { bar: true }); // => 'foo bar'
53
+ classNames({ foo: true, bar: true }); // => 'foo bar'
54
+
55
+ // lots of arguments of various types
56
+ classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }) // => 'foo bar baz quux'
57
+
58
+ // other falsy values are just ignored
59
+ classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
60
+ ```
61
+
62
+ For more information please reference [classNames](https://github.com/JedWatson/classnames)
63
+
64
+ ## Development
65
+
66
+ 2015-05-29 The classnames v2.1.2
67
+
68
+ ## Contributing
69
+
70
+ Feel free to open an issue ticket if you find something that could be improved.
71
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "classnames/rails"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # 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 'classnames/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "classnames-rails"
8
+ spec.version = Classnames::Rails::VERSION
9
+ spec.authors = ["andyyou"]
10
+ spec.email = ["andyyu0920@gmail.com"]
11
+
12
+ spec.summary = %q{Gem package from classnames of javascript}
13
+ spec.description = %q{A simple utility for conditionally joining classNames together. Fork from classnames of javascript}
14
+ spec.homepage = "https://github.com/andyyou/classnames-rails"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+ spec.license = "MIT"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1 @@
1
+ require 'classnames/rails'
@@ -0,0 +1,8 @@
1
+ require "classnames/rails/engine"
2
+ require "classnames/rails/version"
3
+
4
+ module Classnames
5
+ module Rails
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Classnames
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Classnames
2
+ module Rails
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,95 @@
1
+ /*!
2
+ Copyright (c) 2015 Jed Watson.
3
+ Licensed under the MIT License (MIT), see
4
+ http://jedwatson.github.io/classnames
5
+ */
6
+
7
+ (function () {
8
+ 'use strict';
9
+
10
+ var classNames = (function () {
11
+ function _parseArray (resultSet, array) {
12
+ var length = array.length;
13
+
14
+ for (var i = 0; i < length; ++i) {
15
+ _parse(resultSet, array[i]);
16
+ }
17
+ }
18
+
19
+ function _parseNumber (resultSet, num) {
20
+ resultSet[num] = true;
21
+ }
22
+
23
+ function _parseObject (resultSet, object) {
24
+ for (var k in object) {
25
+ if (object.hasOwnProperty(k)) {
26
+ if (object[k]) {
27
+ resultSet[k] = true;
28
+
29
+ } else {
30
+ delete resultSet[k];
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ var SPACE = /\s+/;
37
+ function _parseString (resultSet, str) {
38
+ var array = str.split(SPACE);
39
+ var length = array.length;
40
+
41
+ for (var i = 0; i < length; ++i) {
42
+ resultSet[array[i]] = true;
43
+ }
44
+ }
45
+
46
+ function _parse (resultSet, arg) {
47
+ if (!arg) return;
48
+ var argType = typeof arg;
49
+
50
+ // 'foo bar'
51
+ if ('string' === argType) {
52
+ _parseString(resultSet, arg);
53
+
54
+ // ['foo', 'bar', ...]
55
+ } else if (Array.isArray(arg)) {
56
+ _parseArray(resultSet, arg);
57
+
58
+ // { 'foo': true, ... }
59
+ } else if ('object' === argType) {
60
+ _parseObject(resultSet, arg);
61
+
62
+ // '130'
63
+ } else if ('number' === argType) {
64
+ _parseNumber(resultSet, arg);
65
+ }
66
+ }
67
+
68
+ function _classNames () {
69
+ var classSet = {};
70
+ _parseArray(classSet, arguments);
71
+
72
+ var classes = '';
73
+ for (var k in classSet) {
74
+ classes += ' ' + k;
75
+ }
76
+
77
+ return classes.substr(1);
78
+ }
79
+
80
+ return _classNames;
81
+
82
+ })();
83
+
84
+ if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
85
+ // AMD. Register as an anonymous module.
86
+ define(function () {
87
+ return classNames;
88
+ });
89
+ } else if (typeof module !== 'undefined' && module.exports) {
90
+ module.exports = classNames;
91
+ } else {
92
+ window.classNames = classNames;
93
+ }
94
+
95
+ }());
@@ -0,0 +1,49 @@
1
+ /*!
2
+ Copyright (c) 2015 Jed Watson.
3
+ Licensed under the MIT License (MIT), see
4
+ http://jedwatson.github.io/classnames
5
+ */
6
+
7
+ (function () {
8
+ 'use strict';
9
+
10
+ function classNames () {
11
+
12
+ var classes = '';
13
+
14
+ for (var i = 0; i < arguments.length; i++) {
15
+ var arg = arguments[i];
16
+ if (!arg) continue;
17
+
18
+ var argType = typeof arg;
19
+
20
+ if ('string' === argType || 'number' === argType) {
21
+ classes += ' ' + arg;
22
+
23
+ } else if (Array.isArray(arg)) {
24
+ classes += ' ' + classNames.apply(null, arg);
25
+
26
+ } else if ('object' === argType) {
27
+ for (var key in arg) {
28
+ if (arg.hasOwnProperty(key) && arg[key]) {
29
+ classes += ' ' + key;
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ return classes.substr(1);
36
+ }
37
+
38
+ if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
39
+ // AMD. Register as an anonymous module.
40
+ define(function () {
41
+ return classNames;
42
+ });
43
+ } else if (typeof module !== 'undefined' && module.exports) {
44
+ module.exports = classNames;
45
+ } else {
46
+ window.classNames = classNames;
47
+ }
48
+
49
+ }());
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: classnames-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - andyyou
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A simple utility for conditionally joining classNames together. Fork
42
+ from classnames of javascript
43
+ email:
44
+ - andyyu0920@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - classnames-rails.gemspec
56
+ - lib/classnames-rails.rb
57
+ - lib/classnames/rails.rb
58
+ - lib/classnames/rails/engine.rb
59
+ - lib/classnames/rails/version.rb
60
+ - vendor/assets/javascripts/classnames-dedupe.js
61
+ - vendor/assets/javascripts/classnames.js
62
+ homepage: https://github.com/andyyou/classnames-rails
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Gem package from classnames of javascript
86
+ test_files: []