jekyll-truthyfalsy 1.0.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce20b2ad4b91bbcae45e649b66cb31506e7c9f2b9ca1d1bd3fd29b7132a54980
4
- data.tar.gz: 5b9c9746e46603ea6393f026b9f2eb5da1114bd49f341d816b178b5bf90c44ac
3
+ metadata.gz: dfea5b16fc9b87be39842ea2b737d73f12704d15f9494af8fb5e9c6369349536
4
+ data.tar.gz: 675fc5000ab5ac2fb897067fb5ed6d2baf116f67208274947011b7ee80cb819d
5
5
  SHA512:
6
- metadata.gz: 16c6dc347856c809dee82994c644a5bd55b1558fa8a280ae89458ca9d9675fe1405c2122f103c31e3ae9f0afb9c362293cf96e38af5f424cfcfc82644219819b
7
- data.tar.gz: 607519dad1b36fc87a045b83684c9abc84e2d3512366d980618869d6908a22f159589d7bb96730dbafffe9896e3d10d2f0433b2b27a2719e278ca57f93eb446a
6
+ metadata.gz: 44880789333e1af31f786e9b8bac5c298b91371f16d1195ed24f8e34928072f2a117a13b13b1d5db4555907435598dd8708ca9f8cdf51f03fc40249eabbd14d7
7
+ data.tar.gz: d9cbb6c6c2652a4e924ce4899d8ac709db058b026320fa15855cf05f0fc5094d08959cb62cfaf645f1e05646731e8f989e121efa17cefdc34202a76dc256a220
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in jekyll-truthyfalsy.gemspec
6
+ gemspec
7
+
8
+ if ENV["JEKYLL_VERSION"]
9
+ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 ITW Creative Works
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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
data/README.md CHANGED
@@ -33,7 +33,6 @@ Yes, this module works in both Node and browser environments, including compatib
33
33
  * Exposes a `isfalsy` function
34
34
 
35
35
  # Jekyll::truthyfalsy
36
-
37
36
  Meet `jekyll-truthyfalsy`, the whimsical gem dedicated to turning the grey areas of truthiness and falsiness into black and white.
38
37
 
39
38
  It doesn't just settle for mere booleans; oh no, it goes above and beyond, scrutinizing empty strings and null values too! Like a tenacious detective, it leaves no stone unturned, and no value unverified. Banish the verbose 'if' statements and welcome a new era of compact, expressive checks.
@@ -41,44 +40,77 @@ It doesn't just settle for mere booleans; oh no, it goes above and beyond, scrut
41
40
  Because life is too short for ambiguity, embrace the certainty that comes with `jekyll-truthyfalsy`. Truthiness and falsiness: not just a philosophical quandary, but a .gem installation away!
42
41
 
43
42
  ## Installation
44
-
45
43
  Install the gem and add to the application's Gemfile by executing:
46
44
  ```shell
47
- $ bundle add jekyll-truthyfalsy
45
+ bundle add jekyll-truthyfalsy
48
46
  ```
49
47
 
50
48
  If bundler is not being used to manage dependencies, install the gem by executing:
51
49
  ```shell
52
- $ gem install jekyll-truthyfalsy
50
+ gem install jekyll-truthyfalsy
53
51
  ```
54
52
 
55
53
  ## Usage
56
- Now you can use the istruthy and isfalsy filters in your Jekyll site's templates:
54
+ Now you can use the `istruthy` and `isfalsy` filters in your Jekyll site's templates:
57
55
 
58
56
  ```liquid
59
- {% if page.title | istruthy %}
60
- <h1>{{ page.title }}</h1>
61
- {% else %}
62
- <h1>Untitled</h1>
63
- {% endif %}
64
-
65
- {% if page.description | isfalsy %}
66
- <p>No description available</p>
67
- {% else %}
68
- <p>{{ page.description }}</p>
69
- {% endif %}
57
+ {%- assign test_true = true | istruthy -%}
58
+ {%- if test_true -%}
59
+ This will print because `true` is truthy
60
+ {%- endif -%}
61
+
62
+ {%- assign test_false = false | istruthy -%}
63
+ {%- if test_false -%}
64
+ This will NOT print because `false` is falsy
65
+ {%- endif -%}
66
+
67
+ {%- assign test_string = 'hi' | istruthy -%}
68
+ {%- if test_string -%}
69
+ This will print because `'hi'` is truthy
70
+ {%- endif -%}
71
+
72
+ {%- assign test_empty_string = '' | istruthy -%}
73
+ {%- if test_empty_string -%}
74
+ This will NOT print because `''` is falsy
75
+ {%- endif -%}
76
+
77
+ {%- assign test_null = null | istruthy -%}
78
+ {%- if test_null -%}
79
+ This will NOT print because `null` is falsy
80
+ {%- endif -%}
81
+
82
+ {%- assign test_zero = 0 | istruthy -%}
83
+ {%- if test_zero -%}
84
+ This will NOT print because `0` is falsy
85
+ {%- endif -%}
86
+
87
+ {%- assign test_one = 1 | istruthy -%}
88
+ {%- if test_one -%}
89
+ This will print because `1` is truthy
90
+ {%- endif -%}
70
91
  ```
71
92
 
72
93
  These examples show how you can use `istruthy` and `isfalsy` to easily check if a variable is "truthy" (not null, not an empty string, and not false) or "falsy" (null, an empty string, or false), respectively.
73
94
 
74
- No more long, confusing, multi-condition 'if' statements - just simple, readable code!
95
+ No more long, confusing, multi-condition `if` statements - just simple, readable code!
75
96
 
76
97
  ## Development
77
-
78
98
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
79
99
 
80
100
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
81
101
 
82
- ## Contributing
102
+ ### Building and pushing
103
+ Run the tests
104
+ ```shell
105
+ bundle exec rspec
106
+ ```
83
107
 
84
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-truthyfalsy.
108
+ Publish the Gem
109
+ ```shell
110
+ gem build jekyll-truthyfalsy.gemspec
111
+
112
+ gem push jekyll-truthyfalsy-1.0.0.gem
113
+ ```
114
+
115
+ ## Contributing
116
+ Bug reports and pull requests are welcome on GitHub at https://github.com/itw-creative-works/jekyll-truthyfalsy.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-truthyfalsy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ # Gem info
8
+ spec.name = "jekyll-truthyfalsy"
9
+ spec.version = Jekyll::TruthyFalsy::VERSION
10
+
11
+ # Author info
12
+ spec.authors = ["ITW Creative Works"]
13
+ spec.email = ["hello@itwcreativeworks.com"]
14
+
15
+ # Gem details
16
+ spec.summary = "A Jekyll plugin that adds JavaScript-like truthy and falsy checks"
17
+ spec.description = "A simple Jekyll plugin that adds JavaScript-like istruthy and isfalsy filters to Liquid"
18
+ spec.homepage = "https://github.com/itw-creative-works/jekyll-truthyfalsy"
19
+ spec.license = "MIT"
20
+
21
+ # Files
22
+ spec.files = Dir["CODE_OF_CONDUCT.md", "README*.md", "LICENSE", "Rakefile", "*.gemspec", "Gemfile", "lib/**/*", "spec/**/*"]
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ # Gem requires Jekyll to work
28
+ spec.add_runtime_dependency "jekyll", ">= 3.0", "< 5.0"
29
+
30
+ # Development requires more
31
+ spec.add_development_dependency "bundler"
32
+ spec.add_development_dependency "rake"
33
+ spec.add_development_dependency "rspec"
34
+
35
+ # Ruby version
36
+ spec.required_ruby_version = ">= 2.0.0"
37
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module TruthyFalsy
3
+ VERSION = "1.0.2"
4
+ end # module TruthyFalsy
5
+ end # module Jekyll
@@ -0,0 +1,15 @@
1
+ require "jekyll"
2
+
3
+ module Jekyll
4
+ module TruthyFalsy
5
+ def istruthy(input)
6
+ !(input.nil? || input == '' || input == false || input == 0)
7
+ end
8
+
9
+ def isfalsy(input)
10
+ input.nil? || input == '' || input == false || input == 0
11
+ end
12
+ end
13
+ end
14
+
15
+ Liquid::Template.register_filter(Jekyll::TruthyFalsy)
@@ -0,0 +1,72 @@
1
+ require 'jekyll-truthyfalsy'
2
+
3
+ RSpec.describe Jekyll::TruthyFalsy do
4
+ # Dummy class to include the filter methods
5
+ class DummyClass
6
+ include Jekyll::TruthyFalsy
7
+ end
8
+
9
+ let(:dummy) { DummyClass.new }
10
+
11
+ # Truthy values
12
+ describe '.istruthy' do
13
+ it 'returns true for non-empty string' do
14
+ expect(dummy.istruthy('hello')).to be(true)
15
+ end
16
+
17
+ it 'returns false for empty string' do
18
+ expect(dummy.istruthy('')).to be(false)
19
+ end
20
+
21
+ it 'returns true for true boolean' do
22
+ expect(dummy.istruthy(true)).to be(true)
23
+ end
24
+
25
+ it 'returns false for false boolean' do
26
+ expect(dummy.istruthy(false)).to be(false)
27
+ end
28
+
29
+ it 'returns false for nil' do
30
+ expect(dummy.istruthy(nil)).to be(false)
31
+ end
32
+
33
+ it 'returns true for integer 1' do
34
+ expect(dummy.istruthy(1)).to be(true)
35
+ end
36
+
37
+ it 'returns false for integer 0' do
38
+ expect(dummy.istruthy(0)).to be(false)
39
+ end
40
+ end
41
+
42
+ # Falsy values
43
+ describe '.isfalsy' do
44
+ it 'returns false for non-empty string' do
45
+ expect(dummy.isfalsy('hello')).to be(false)
46
+ end
47
+
48
+ it 'returns true for empty string' do
49
+ expect(dummy.isfalsy('')).to be(true)
50
+ end
51
+
52
+ it 'returns false for true boolean' do
53
+ expect(dummy.isfalsy(true)).to be(false)
54
+ end
55
+
56
+ it 'returns true for false boolean' do
57
+ expect(dummy.isfalsy(false)).to be(true)
58
+ end
59
+
60
+ it 'returns true for nil' do
61
+ expect(dummy.isfalsy(nil)).to be(true)
62
+ end
63
+
64
+ it 'returns false for integer 1' do
65
+ expect(dummy.isfalsy(1)).to be(false)
66
+ end
67
+
68
+ it 'returns true for integer 0' do
69
+ expect(dummy.isfalsy(0)).to be(true)
70
+ end
71
+ end
72
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-truthyfalsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works
@@ -30,6 +30,48 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
33
75
  description: A simple Jekyll plugin that adds JavaScript-like istruthy and isfalsy
34
76
  filters to Liquid
35
77
  email:
@@ -38,8 +80,14 @@ executables: []
38
80
  extensions: []
39
81
  extra_rdoc_files: []
40
82
  files:
83
+ - Gemfile
84
+ - LICENSE
41
85
  - README.md
42
- - lib/jekyll/filters/truthyfalsy.rb
86
+ - Rakefile
87
+ - jekyll-truthyfalsy.gemspec
88
+ - lib/jekyll-truthyfalsy.rb
89
+ - lib/jekyll-truthyfalsy/version.rb
90
+ - spec/jekyll-truthyfalsy_spec.rb
43
91
  homepage: https://github.com/itw-creative-works/jekyll-truthyfalsy
44
92
  licenses:
45
93
  - MIT
@@ -52,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
100
  requirements:
53
101
  - - ">="
54
102
  - !ruby/object:Gem::Version
55
- version: 2.6.0
103
+ version: 2.0.0
56
104
  required_rubygems_version: !ruby/object:Gem::Requirement
57
105
  requirements:
58
106
  - - ">="
@@ -63,4 +111,5 @@ rubygems_version: 3.2.3
63
111
  signing_key:
64
112
  specification_version: 4
65
113
  summary: A Jekyll plugin that adds JavaScript-like truthy and falsy checks
66
- test_files: []
114
+ test_files:
115
+ - spec/jekyll-truthyfalsy_spec.rb
@@ -1,13 +0,0 @@
1
- module Jekyll
2
- module IstruthyFalsyFilter
3
- def istruthy(input)
4
- !(input.nil? || input == '' || input == false)
5
- end
6
-
7
- def isfalsy(input)
8
- input.nil? || input == '' || input == false
9
- end
10
- end
11
- end
12
-
13
- Liquid::Template.register_filter(Jekyll::IstruthyFalsyFilter)