jekyll-truthyfalsy 1.0.1 → 1.0.3

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: 18c8a4f46fc5fb38b342d4397c15f69fcbffda7c93e07510ceedd398b297ffd4
4
- data.tar.gz: 6d358291c9f05de551756ec8a2aaecd4f5839bcef21fe0b479bb9b3b07a80d1c
3
+ metadata.gz: aa207eb1ef7dbdc09f08b451c03c91c11007a91ef58eb710fb30e37d62517121
4
+ data.tar.gz: 26b9f35c431081eba50d4ce4d633c41e4b3bafcf585e20cbb9fc4fee7bf91955
5
5
  SHA512:
6
- metadata.gz: 422f80f7cadd2e72343de2eb1db3d3c9b8412ab2fa44f83eb929558b96fbef81d8b623df8ae547a9902c681692ab9cb65e7a97a97023c552fe6ae3a7f513f27c
7
- data.tar.gz: d7131b7e0704ce8094f192527804c2d3cb80af7a3517571d8ee0877d9d9cf12930f59198f1269e7711cf0610b965e3ae19e35d83a9944376d86ae10f8488d640
6
+ metadata.gz: 2bf2e22e7787779465d2c0dc74c25cb0b11896f07fc9b3be4d58f878e7a58e3bf4dbdfee3ff7c42f7b9798a14658aeb7c7f8317c11fa7f62a779df61481be82f
7
+ data.tar.gz: ae8f37bfac4d7e3361185285bdf977c1d78e3a39e3cb5dba0be80ecc7da96fdf86bf9d55a82b5760fb76a10f2a0aebc2ec213171da67b7d8e5b414ac7066b026
data/README.md CHANGED
@@ -18,30 +18,25 @@
18
18
  <img src="https://img.shields.io/github/last-commit/itw-creative-works/jekyll-truthyfalsy.svg">
19
19
  <br>
20
20
  <br>
21
- <a href="https://itwcreativeworks.com">Site</a> | <a href="https://www.npmjs.com/package/jekyll-truthyfalsy">NPM Module</a> | <a href="https://github.com/itw-creative-works/jekyll-truthyfalsy">GitHub Repo</a>
21
+ <a href="https://itwcreativeworks.com">Site</a> | <a href="https://rubygems.org/gems/jekyll-truthyfalsy">Gem Page</a> | <a href="https://github.com/itw-creative-works/jekyll-truthyfalsy">GitHub Repo</a>
22
22
  <br>
23
23
  <br>
24
24
  Meet <strong>jekyll-truthyfalsy</strong>, the Sherlock Holmes of truthy and falsy values in Liquid.
25
25
  </p>
26
26
 
27
- ## jekyll-truthyfalsy Works in Node AND browser environments
28
- Yes, this module works in both Node and browser environments, including compatibility with [Webpack](https://www.npmjs.com/package/webpack) and [Browserify](https://www.npmjs.com/package/browserify)!
29
-
30
27
  ## Features
31
28
  * Check whether a value is **truthy** or **falsy** in a manner similar to JavaScript
32
29
  * Exposes a `istruthy` function
33
30
  * Exposes a `isfalsy` function
34
31
 
35
32
  # Jekyll::truthyfalsy
33
+ Meet `jekyll-truthyfalsy`, the whimsical gem dedicated to turning the grey areas of truthiness and falsiness into black and white.
36
34
 
37
- Meet `jekyll-truthyfalsy`, the whimsical gem dedicated to turning the grey areas of truthiness and falsiness into black and white.
38
-
39
- 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.
35
+ 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.
40
36
 
41
37
  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
38
 
43
39
  ## Installation
44
-
45
40
  Install the gem and add to the application's Gemfile by executing:
46
41
  ```shell
47
42
  bundle add jekyll-truthyfalsy
@@ -53,38 +48,67 @@ gem install jekyll-truthyfalsy
53
48
  ```
54
49
 
55
50
  ## Usage
56
- Now you can use the istruthy and isfalsy filters in your Jekyll site's templates:
51
+ Now you can use the `istruthy` and `isfalsy` filters in your Jekyll site's templates:
57
52
 
58
53
  ```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 %}
54
+ {%- assign test_true = true | istruthy -%}
55
+ {%- if test_true -%}
56
+ This will print because `true` is truthy
57
+ {%- endif -%}
58
+
59
+ {%- assign test_false = false | istruthy -%}
60
+ {%- if test_false -%}
61
+ This will NOT print because `false` is falsy
62
+ {%- endif -%}
63
+
64
+ {%- assign test_string = 'hi' | istruthy -%}
65
+ {%- if test_string -%}
66
+ This will print because `'hi'` is truthy
67
+ {%- endif -%}
68
+
69
+ {%- assign test_empty_string = '' | istruthy -%}
70
+ {%- if test_empty_string -%}
71
+ This will NOT print because `''` is falsy
72
+ {%- endif -%}
73
+
74
+ {%- assign test_null = null | istruthy -%}
75
+ {%- if test_null -%}
76
+ This will NOT print because `null` is falsy
77
+ {%- endif -%}
78
+
79
+ {%- assign test_zero = 0 | istruthy -%}
80
+ {%- if test_zero -%}
81
+ This will NOT print because `0` is falsy
82
+ {%- endif -%}
83
+
84
+ {%- assign test_one = 1 | istruthy -%}
85
+ {%- if test_one -%}
86
+ This will print because `1` is truthy
87
+ {%- endif -%}
70
88
  ```
71
89
 
72
90
  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
91
 
74
- No more long, confusing, multi-condition 'if' statements - just simple, readable code!
92
+ No more long, confusing, multi-condition `if` statements - just simple, readable code!
75
93
 
76
94
  ## Development
77
-
78
95
  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
96
 
80
97
  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
98
 
82
99
  ### Building and pushing
100
+ Run the tests
101
+ ```shell
102
+ bundle install
103
+ bundle exec rspec
104
+ ```
105
+
106
+ Publish the Gem
83
107
  ```shell
84
108
  gem build jekyll-truthyfalsy.gemspec
85
- gem push jekyll-istruthyfalsy-1.0.0.gem
109
+
110
+ gem push jekyll-truthyfalsy-1.0.0.gem
86
111
  ```
87
112
 
88
113
  ## Contributing
89
-
90
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-truthyfalsy.
114
+ Bug reports and pull requests are welcome on GitHub at https://github.com/itw-creative-works/jekyll-truthyfalsy.
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module TruthyFalsy
3
- VERSION = "1.0.1"
4
- end # module TruthyFalsy
5
- end # module Jekyll
3
+ VERSION = "1.0.3"
4
+ end
5
+ end
@@ -3,11 +3,11 @@ require "jekyll"
3
3
  module Jekyll
4
4
  module TruthyFalsy
5
5
  def istruthy(input)
6
- !(input.nil? || input == '' || input == false)
6
+ !(input.nil? || input == '' || input == false || input == 0)
7
7
  end
8
8
 
9
9
  def isfalsy(input)
10
- input.nil? || input == '' || input == false
10
+ input.nil? || input == '' || input == false || input == 0
11
11
  end
12
12
  end
13
13
  end
@@ -8,6 +8,7 @@ RSpec.describe Jekyll::TruthyFalsy do
8
8
 
9
9
  let(:dummy) { DummyClass.new }
10
10
 
11
+ # Truthy values
11
12
  describe '.istruthy' do
12
13
  it 'returns true for non-empty string' do
13
14
  expect(dummy.istruthy('hello')).to be(true)
@@ -28,8 +29,17 @@ RSpec.describe Jekyll::TruthyFalsy do
28
29
  it 'returns false for nil' do
29
30
  expect(dummy.istruthy(nil)).to be(false)
30
31
  end
31
- end
32
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
33
43
  describe '.isfalsy' do
34
44
  it 'returns false for non-empty string' do
35
45
  expect(dummy.isfalsy('hello')).to be(false)
@@ -50,5 +60,13 @@ RSpec.describe Jekyll::TruthyFalsy do
50
60
  it 'returns true for nil' do
51
61
  expect(dummy.isfalsy(nil)).to be(true)
52
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
53
71
  end
54
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-truthyfalsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-16 00:00:00.000000000 Z
11
+ date: 2024-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll