jekyll-roman 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/jekyll-roman.gemspec +26 -0
- data/lib/jekyll-roman.rb +45 -0
- data/lib/jekyll-roman/version.rb +5 -0
- data/script/bootstrap +3 -0
- data/script/cibuild +3 -0
- data/script/console +34 -0
- data/script/release +7 -0
- data/spec/fixtures/.jekyll-metadata +0 -0
- data/spec/fixtures/_config.yml +9 -0
- data/spec/fixtures/_layouts/some_default.html +5 -0
- data/spec/fixtures/index.html +25 -0
- data/spec/jekyll-roman_spec.rb +123 -0
- data/spec/spec_helper.rb +21 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7239151d50e2f62059563c02f09a84cf9afe6fb
|
4
|
+
data.tar.gz: 2dabc99b11d2588e242c2186e46885a64ca0851f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc19fd5af2ddea5b7b4da0485d57b607d44fdabfff01aeb0eb0103bdc1edb7233404a989c4c331d3f96469fd1894e32ca232b3b25da0588674adf8ac9243c7c7
|
7
|
+
data.tar.gz: 334b81e7ebc712c7fbd2301a0111174675ee776410e060ca2104e6192dd3729a8ae2765362c76ef1888d0232a8d49ad68564c22bf8fb8152aa980a3f136dbfc3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Paul Robert Lloyd
|
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
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# jekyll-roman
|
2
|
+
|
3
|
+
*A liquid filter for Jekyll that converts numbers into Roman numerals.*
|
4
|
+
|
5
|
+
[![Gem Version](https://img.shields.io/gem/v/jekyll-roman.svg)](https://rubygems.org/gems/jekyll-roman)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
1. Add `gem 'jekyll-roman'` to your site’s Gemfile and run bundle
|
10
|
+
2. Add the following to your site’s `_config.yml`:
|
11
|
+
|
12
|
+
```yml
|
13
|
+
gems:
|
14
|
+
- jekyll-roman
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
This filter takes any given whole number, and converts it. Any other types of string are ignored. For example, if you wish to display the year in your site’s copyright statement as roman numerals, you would write the following:
|
20
|
+
|
21
|
+
```html
|
22
|
+
<h1>© {{ site.time | date:"%Y" | roman }}</h1>
|
23
|
+
````
|
24
|
+
|
25
|
+
## Testing
|
26
|
+
|
27
|
+
1. `script/bootstrap`
|
28
|
+
2. `script/cibuild`
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork the project
|
33
|
+
2. Create a descriptively named feature branch
|
34
|
+
3. Add your feature
|
35
|
+
4. Submit a pull request
|
36
|
+
|
37
|
+
## Acknowledgements
|
38
|
+
|
39
|
+
Code based on that found in [this discussion on Stack Overflow](http://stackoverflow.com/questions/26092510/roman-numerals-in-ruby). If you know of a better way of achieving the same result, please let me know!
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-roman/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-roman"
|
8
|
+
spec.version = Jekyll::Roman::VERSION
|
9
|
+
spec.summary = "Jekyll plugin that converts numbers into Roman numerals."
|
10
|
+
spec.description = "A liquid filter for Jekyll that converts numbers into Roman numerals."
|
11
|
+
spec.authors = ["Paul Robert Lloyd"]
|
12
|
+
spec.email = "me+rubygems@paulrobertlloyd.com"
|
13
|
+
spec.files = Dir.glob("lib/**/*.rb")
|
14
|
+
spec.homepage = "https://github.com/paulrobertlloyd/jekyll-roman"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "jekyll", [">= 2.0", "< 4.0"]
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency 'rake', '~> 0'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
26
|
+
end
|
data/lib/jekyll-roman.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Roman
|
3
|
+
|
4
|
+
class Integer
|
5
|
+
def initialize(number)
|
6
|
+
@number = number.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_roman
|
10
|
+
roman_arr = {
|
11
|
+
1000 => "M",
|
12
|
+
900 => "CM",
|
13
|
+
500 => "D",
|
14
|
+
400 => "CD",
|
15
|
+
100 => "C",
|
16
|
+
90 => "XC",
|
17
|
+
50 => "L",
|
18
|
+
40 => "XL",
|
19
|
+
10 => "X",
|
20
|
+
9 => "IX",
|
21
|
+
5 => "V",
|
22
|
+
4 => "IV",
|
23
|
+
1 => "I"
|
24
|
+
}
|
25
|
+
num = @number
|
26
|
+
|
27
|
+
roman_arr.reduce("") do |res, (arab, roman)|
|
28
|
+
whole_part, num = num.divmod(arab)
|
29
|
+
res << roman * whole_part
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def roman(input)
|
35
|
+
if /\A\d+\z/.match(input.to_s) # input is a positive number
|
36
|
+
Integer.new(input).to_roman
|
37
|
+
else
|
38
|
+
return input
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Liquid::Template.register_filter(Jekyll::Roman)
|
data/script/bootstrap
ADDED
data/script/cibuild
ADDED
data/script/console
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
def relative_to_root(path)
|
4
|
+
File.expand_path(path, File.dirname(File.dirname(__FILE__)))
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'jekyll'
|
8
|
+
require relative_to_root('lib/jekyll-smartify.rb')
|
9
|
+
require 'pry-debugger'
|
10
|
+
|
11
|
+
SOURCE_DIR = relative_to_root('spec/fixtures')
|
12
|
+
DEST_DIR = relative_to_root('spec/dest')
|
13
|
+
|
14
|
+
def source_dir(*files)
|
15
|
+
File.join(SOURCE_DIR, *files)
|
16
|
+
end
|
17
|
+
|
18
|
+
def dest_dir(*files)
|
19
|
+
File.join(DEST_DIR, *files)
|
20
|
+
end
|
21
|
+
|
22
|
+
def config(overrides = {})
|
23
|
+
Jekyll.configuration({
|
24
|
+
"source" => source_dir,
|
25
|
+
"destination" => dest_dir,
|
26
|
+
"url" => "http://example.org"
|
27
|
+
}).merge(overrides)
|
28
|
+
end
|
29
|
+
|
30
|
+
def site(configuration = config)
|
31
|
+
Jekyll::Site.new(configuration)
|
32
|
+
end
|
33
|
+
|
34
|
+
binding.pry
|
data/script/release
ADDED
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
test:
|
3
|
+
- 1
|
4
|
+
- 4
|
5
|
+
- 5
|
6
|
+
- 9
|
7
|
+
- 10
|
8
|
+
- 40
|
9
|
+
- 50
|
10
|
+
- 90
|
11
|
+
- 100
|
12
|
+
- 400
|
13
|
+
- 500
|
14
|
+
- 900
|
15
|
+
- 1000
|
16
|
+
- 2
|
17
|
+
- 13
|
18
|
+
- 94
|
19
|
+
- 496
|
20
|
+
- 998
|
21
|
+
- 1066
|
22
|
+
- 1998
|
23
|
+
- word
|
24
|
+
---
|
25
|
+
Each test should be an item in `page.test`
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe(Jekyll) do
|
4
|
+
let(:overrides) do
|
5
|
+
{
|
6
|
+
"source" => source_dir,
|
7
|
+
"destination" => dest_dir,
|
8
|
+
"url" => "http://example.org",
|
9
|
+
}
|
10
|
+
end
|
11
|
+
let(:config) do
|
12
|
+
Jekyll.configuration(overrides)
|
13
|
+
end
|
14
|
+
let(:site) { Jekyll::Site.new(config) }
|
15
|
+
let(:contents) { File.read(dest_dir("index.html")) }
|
16
|
+
before(:each) do
|
17
|
+
site.process
|
18
|
+
end
|
19
|
+
|
20
|
+
it "converts 1 into roman numeral" do
|
21
|
+
expect(contents).to match /I/
|
22
|
+
expect(contents).to_not match /1/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "converts 4 into roman numeral" do
|
26
|
+
expect(contents).to match /IV/
|
27
|
+
expect(contents).to_not match /4/
|
28
|
+
end
|
29
|
+
|
30
|
+
it "converts 5 into roman numeral" do
|
31
|
+
expect(contents).to match /V/
|
32
|
+
expect(contents).to_not match /5/
|
33
|
+
end
|
34
|
+
|
35
|
+
it "converts 9 into roman numeral" do
|
36
|
+
expect(contents).to match /IV/
|
37
|
+
expect(contents).to_not match /9/
|
38
|
+
end
|
39
|
+
|
40
|
+
it "converts 10 into roman numeral" do
|
41
|
+
expect(contents).to match /X/
|
42
|
+
expect(contents).to_not match /10/
|
43
|
+
end
|
44
|
+
|
45
|
+
it "converts 40 into roman numeral" do
|
46
|
+
expect(contents).to match /XL/
|
47
|
+
expect(contents).to_not match /40/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "converts 50 into roman numeral" do
|
51
|
+
expect(contents).to match /L/
|
52
|
+
expect(contents).to_not match /50/
|
53
|
+
end
|
54
|
+
|
55
|
+
it "converts 90 into roman numeral" do
|
56
|
+
expect(contents).to match /L/
|
57
|
+
expect(contents).to_not match /90/
|
58
|
+
end
|
59
|
+
|
60
|
+
it "converts 100 into roman numeral" do
|
61
|
+
expect(contents).to match /C/
|
62
|
+
expect(contents).to_not match /100/
|
63
|
+
end
|
64
|
+
|
65
|
+
it "converts 400 into roman numeral" do
|
66
|
+
expect(contents).to match /CD/
|
67
|
+
expect(contents).to_not match /400/
|
68
|
+
end
|
69
|
+
|
70
|
+
it "converts 500 into roman numeral" do
|
71
|
+
expect(contents).to match /D/
|
72
|
+
expect(contents).to_not match /500/
|
73
|
+
end
|
74
|
+
|
75
|
+
it "converts 900 into roman numeral" do
|
76
|
+
expect(contents).to match /CM/
|
77
|
+
expect(contents).to_not match /900/
|
78
|
+
end
|
79
|
+
|
80
|
+
it "converts 1000 into roman numeral" do
|
81
|
+
expect(contents).to match /M/
|
82
|
+
expect(contents).to_not match /1000/
|
83
|
+
end
|
84
|
+
|
85
|
+
it "converts 2 into roman numeral" do
|
86
|
+
expect(contents).to match /II/
|
87
|
+
expect(contents).to_not match /2/
|
88
|
+
end
|
89
|
+
|
90
|
+
it "converts 13 into roman numeral" do
|
91
|
+
expect(contents).to match /XIII/
|
92
|
+
expect(contents).to_not match /13/
|
93
|
+
end
|
94
|
+
|
95
|
+
it "converts 94 into roman numeral" do
|
96
|
+
expect(contents).to match /XCIV/
|
97
|
+
expect(contents).to_not match /94/
|
98
|
+
end
|
99
|
+
|
100
|
+
it "converts 496 into roman numeral" do
|
101
|
+
expect(contents).to match /CDXCVI/
|
102
|
+
expect(contents).to_not match /496/
|
103
|
+
end
|
104
|
+
|
105
|
+
it "converts 998 into roman numeral" do
|
106
|
+
expect(contents).to match /CMXCVIII/
|
107
|
+
expect(contents).to_not match /998/
|
108
|
+
end
|
109
|
+
|
110
|
+
it "converts 1066 into roman numeral" do
|
111
|
+
expect(contents).to match /MLXVI/
|
112
|
+
expect(contents).to_not match /1066/
|
113
|
+
end
|
114
|
+
|
115
|
+
it "converts 1998 into roman numeral" do
|
116
|
+
expect(contents).to match /MCMXCVIII/
|
117
|
+
expect(contents).to_not match /2015/
|
118
|
+
end
|
119
|
+
|
120
|
+
it "does not convert word to roman numeral" do
|
121
|
+
expect(contents).to match /word/
|
122
|
+
end
|
123
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require File.expand_path('../lib/jekyll-roman', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
Jekyll.logger.log_level = :error
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.run_all_when_everything_filtered = true
|
8
|
+
config.filter_run :focus
|
9
|
+
config.order = 'random'
|
10
|
+
|
11
|
+
SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
|
12
|
+
DEST_DIR = File.expand_path("../dest", __FILE__)
|
13
|
+
|
14
|
+
def source_dir(*files)
|
15
|
+
File.join(SOURCE_DIR, *files)
|
16
|
+
end
|
17
|
+
|
18
|
+
def dest_dir(*files)
|
19
|
+
File.join(DEST_DIR, *files)
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-roman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Robert Lloyd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4.0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.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: bundler
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.6'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.6'
|
75
|
+
description: A liquid filter for Jekyll that converts numbers into Roman numerals.
|
76
|
+
email: me+rubygems@paulrobertlloyd.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- ".gitignore"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- jekyll-roman.gemspec
|
87
|
+
- lib/jekyll-roman.rb
|
88
|
+
- lib/jekyll-roman/version.rb
|
89
|
+
- script/bootstrap
|
90
|
+
- script/cibuild
|
91
|
+
- script/console
|
92
|
+
- script/release
|
93
|
+
- spec/fixtures/.jekyll-metadata
|
94
|
+
- spec/fixtures/_config.yml
|
95
|
+
- spec/fixtures/_layouts/some_default.html
|
96
|
+
- spec/fixtures/index.html
|
97
|
+
- spec/jekyll-roman_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
homepage: https://github.com/paulrobertlloyd/jekyll-roman
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.4.6
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Jekyll plugin that converts numbers into Roman numerals.
|
123
|
+
test_files:
|
124
|
+
- spec/fixtures/.jekyll-metadata
|
125
|
+
- spec/fixtures/_config.yml
|
126
|
+
- spec/fixtures/_layouts/some_default.html
|
127
|
+
- spec/fixtures/index.html
|
128
|
+
- spec/jekyll-roman_spec.rb
|
129
|
+
- spec/spec_helper.rb
|