jekyll-money2 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd56b6e9dc5de8b1aafec4d30ad03e777f18616b8f2d7ada8692356398db8e2a
4
+ data.tar.gz: 64cccee830be3c7d6d3ff991de982e7e4afa5476b33fe8eaaa724cbe8f931473
5
+ SHA512:
6
+ metadata.gz: 12cef6ded972f723e4bc756b9422f8a062877c22b72c65b0a3f8478d9b8e4b842ad5c8f83ad30ed0b2ac5696b9ba1e3d687805a07323b264d3dc725eaa2d3bcb
7
+ data.tar.gz: 287dbff620df8932ee7a3a033b0b9f3f8b58877a95767f7b314710279debf6a07eeabc1036ea824d1715ead6c71b675d08f9a75f3afd9886104520f911535be2
@@ -0,0 +1,11 @@
1
+ *.gem
2
+
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-money.gemspec
4
+ gemspec
5
+
6
+ gem "jekyll", "~> 4.0"
7
+ gem "money", "~> 6.8"
8
+ gem "bigdecimal", '~> 1.3'
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 John Pitchko
4
+ Copyright (c) 2017 Josh Habdas
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,92 @@
1
+ # Jekyll Money2
2
+
3
+ A Jekyll plugin for dealing with money. Because we all have to at some point.
4
+
5
+ Works by extending the functionality of the popular [money](https://rubygems.org/gems/money) RubyGem. Intends to become a full-featured way to work with money in Jekyll. It starts with a simple filter to enable the common use case of formatting of international currencies. In time the plugin should be extended to create a [Tag](jekyllrb.com/docs/plugins/#tags) enabling arithmetic, comparisons and currency conversion.
6
+
7
+ ## Notice on forked repo
8
+
9
+ The original repository for this gem can be found at https://git.habd.as/jhabdas/jekyll-money. The author stated that he is not actively working on the repo. This version was forked from that private Git server, moderately modified, and now lives on Github.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'jekyll-money2'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install jekyll-money2
26
+
27
+ Then, in your `_config.yml` file, add to or make a new array with the key `plugins` and the values of the gem names of the plugins you'd like to use. In this case:
28
+
29
+ ```yaml
30
+ plugins:
31
+ - jekyll-money2
32
+ ```
33
+ Note: If using a version of Jekyll below `3.5.0`, use `gems:` in place of `plugins:`.
34
+
35
+ ## Usage
36
+
37
+ By default, the `money` helper formats a value as a USD currency amount using a Liquid filter.
38
+
39
+ ```liquid
40
+ {{ 5000 | money }}
41
+ ```
42
+ Outputs `$50.00`
43
+
44
+ ```liquid
45
+ {{ 5000 | money: "GBP" }}
46
+ ```
47
+ Outputs `£50.00`
48
+
49
+ ```liquid
50
+ {{ 100000000 | money: "IDR" }}
51
+ ```
52
+ Outputs `Rp1.000.000,00`
53
+
54
+ ## Alternative Usage
55
+
56
+ The standard behaviour in the money gem treats all input values as in the base unit of currency. For example, cents for US Dollars.
57
+
58
+ ```liquid
59
+ {{ 1000.00 | money }}
60
+ ```
61
+ Outputs `$10.00` and **NOT** `$1000.00` as one might expect.
62
+
63
+ Use the `money_from_amount` to parse a value that includes cents/decimal.
64
+ ```liquid
65
+ {{ 1000.00 | money_from_amount }}
66
+ ```
67
+ Outputs `$1,000.00`
68
+
69
+ ## Development
70
+
71
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
72
+
73
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests welcome at https://github.com/johnpitchko/jekyll-money.
78
+
79
+ ## Credits
80
+
81
+ This plugin wouldn't be possible without the fine work of:
82
+
83
+ - https://github.com/markets/jekyll-timeago
84
+ - https://github.com/jekyll/jekyll-seo-tag
85
+ - https://github.com/jekyll/jekyll-feed
86
+
87
+ ## License
88
+
89
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
90
+
91
+ Copyright (c) 2020 John Pitchko
92
+ Copyright (c) 2017 Josh Habdas
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/test_*.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/money"
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,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,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-money2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jekyll-money2'
8
+ spec.version = JekyllMoney2::VERSION
9
+ spec.authors = ['John Pitchko', "Josh Habdas"]
10
+ spec.email = ['john.pitchko@icloud.com', "jhabdas@protonmail.com"]
11
+
12
+ spec.summary = "A Jekyll plugin for dealing with money. Enhanced from the original jekyll-money gem."
13
+ spec.homepage = 'https://github.com/johnpitchko/jekyll-money2'
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "jekyll", "~> 4.0"
30
+ spec.add_dependency "money", "~> 6.8"
31
+ spec.add_dependency "bigdecimal", "~> 1.3"
32
+ spec.add_development_dependency "bundler", "~> 1.12"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
@@ -0,0 +1,5 @@
1
+ require "jekyll-money2/version"
2
+ require 'jekyll-money2/core'
3
+ require "jekyll-money2/filter"
4
+
5
+ Liquid::Template.register_filter(JekyllMoney2::Filter)
@@ -0,0 +1,54 @@
1
+ require "money"
2
+
3
+ # Implemement 'per currency' localization to keep life simple
4
+ # Also suppresses deprecation warnings
5
+ # https://github.com/RubyMoney/money#localization
6
+ Money.locale_backend = :currency
7
+ # Explicitly state rounding method; also suppresses warning
8
+ Money.rounding_mode = BigDecimal::ROUND_HALF_UP
9
+ Money.default_currency = 'USD'
10
+
11
+ module JekyllMoney2
12
+ module Core
13
+ extend self
14
+
15
+ def money(value, currency = "USD", options = {})
16
+ @defaults = defaults unless defined?(@defaults)
17
+ @options = @defaults.merge(options)
18
+
19
+ value = validate_money!(value, currency)
20
+ format_money(value, currency, options)
21
+ end
22
+
23
+ def money_from_amount(value, currency = 'USD', options = {})
24
+ @defaults = defaults unless defined?(@defaults)
25
+ @options = @defaults.merge(options)
26
+
27
+ value = Money.from_amount(value.to_f, currency)
28
+ format_money(value, currency, options)
29
+ end
30
+
31
+ private
32
+
33
+ def validate_money!(value, currency)
34
+ Money.new(value, currency)
35
+ end
36
+
37
+ def format_money(value, currency = "USD", options = {})
38
+ Money.new(value, currency).format
39
+ end
40
+
41
+ # @see http://www.rubydoc.info/gems/money/
42
+ def defaults
43
+ {
44
+ "conversion_precision" => Money.conversion_precision,
45
+ "default_bank" => Money.default_bank,
46
+ "default_currency" => Money.default_currency,
47
+ "default_formatting_rules" => Money.default_formatting_rules,
48
+ "infinite_precision" => Money.infinite_precision,
49
+ "rounding_mode" => Money.rounding_mode,
50
+ "use_i18n" => Money.use_i18n
51
+ }
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,12 @@
1
+ module JekyllMoney2
2
+ module Filter
3
+ def money(value, currency = "USD")
4
+ config = @context.registers[:site].config.fetch('jekyll_money2', {})
5
+ JekyllMoney2::Core.money(value, currency, config)
6
+ end
7
+
8
+ def money_from_amount(value)
9
+ JekyllMoney2::Core.money_from_amount(value)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module JekyllMoney2
2
+ VERSION = "0.2.2"
3
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-money2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - John Pitchko
8
+ - Josh Habdas
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2020-11-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jekyll
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: money
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '6.8'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '6.8'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bigdecimal
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.3'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: bundler
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.12'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.12'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '10.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '10.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '3.0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.0'
98
+ description:
99
+ email:
100
+ - john.pitchko@icloud.com
101
+ - jhabdas@protonmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - jekyll-money2.gemspec
116
+ - lib/jekyll-money2.rb
117
+ - lib/jekyll-money2/core.rb
118
+ - lib/jekyll-money2/filter.rb
119
+ - lib/jekyll-money2/version.rb
120
+ homepage: https://github.com/johnpitchko/jekyll-money2
121
+ licenses:
122
+ - MIT
123
+ metadata:
124
+ allowed_push_host: https://rubygems.org
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubygems_version: 3.1.4
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A Jekyll plugin for dealing with money. Enhanced from the original jekyll-money
144
+ gem.
145
+ test_files: []