fixer_upper 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/fixer_upper/renovation.rb +9 -2
- data/lib/fixer_upper/version.rb +1 -1
- data/lib/fixer_upper.rb +7 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 222ca8f8dffc3a73359f8676c8ec6818e410166e
|
4
|
+
data.tar.gz: 7d31e42a287ebd8226bb647c982f755fcad11ecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6146fa503db14d781810be48d71511ddab8f1ccf96e6729dbe81936e5ab02ccb728180dcc7a03bd48fd02a9cecd9a4f46f80fb816b282f913d21d02a88d4d65
|
7
|
+
data.tar.gz: bb463a18b1bfd1e6a04fe9ccd49b462af80882380515c6c5d495c84b64de4001414c9c70fad851045556d589b84fcbb8c737e4ee0fc3810574bdc3b7a3621fdd
|
data/README.md
CHANGED
@@ -22,14 +22,17 @@ And then execute:
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
```ruby
|
25
|
+
require "commonmarker"
|
26
|
+
|
25
27
|
class FixerUpperCmark
|
26
|
-
def call(text)
|
27
|
-
CommonMarker.render_html(text,
|
28
|
+
def call(text, parse_option: :DEFAULT)
|
29
|
+
CommonMarker.render_html(text, parse_option)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
fixer_upper = FixerUpper.new
|
32
|
-
fixer_upper
|
34
|
+
fixer_upper.register("md", "markdown", to: FixerUpperCmark.new, \
|
35
|
+
parse_option: :HARDBREAKS)
|
33
36
|
|
34
37
|
fixer_upper.renovate("file.md")
|
35
38
|
# OR
|
@@ -1,7 +1,8 @@
|
|
1
1
|
class FixerUpper
|
2
2
|
class Renovation
|
3
|
-
def initialize(registry)
|
3
|
+
def initialize(registry, options)
|
4
4
|
@registry = registry
|
5
|
+
@options = options
|
5
6
|
end
|
6
7
|
|
7
8
|
def renovate(filepath, contents, bang:)
|
@@ -14,7 +15,13 @@ class FixerUpper
|
|
14
15
|
mapped_engines = map_engines(engines, bang: bang).compact
|
15
16
|
|
16
17
|
mapped_engines.reduce(text) do |memo, engine|
|
17
|
-
engine
|
18
|
+
default_options = @options[engine]
|
19
|
+
|
20
|
+
if default_options && engine.method(:call).parameters.count >= 2
|
21
|
+
engine.call(memo, **default_options)
|
22
|
+
else
|
23
|
+
engine.call(memo)
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
data/lib/fixer_upper/version.rb
CHANGED
data/lib/fixer_upper.rb
CHANGED
@@ -5,16 +5,19 @@ require "fixer_upper/version"
|
|
5
5
|
class FixerUpper
|
6
6
|
def initialize
|
7
7
|
@engine_registry = {}
|
8
|
-
@
|
8
|
+
@options_registry = {}
|
9
|
+
@renovation = Renovation.new(@engine_registry, @options_registry)
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
+
def register(*keys, to:, **options)
|
12
13
|
keys.each do |key|
|
13
|
-
@engine_registry[key] =
|
14
|
+
@engine_registry[key] = to
|
14
15
|
end
|
16
|
+
|
17
|
+
@options_registry[to] = options
|
15
18
|
end
|
16
19
|
|
17
|
-
def
|
20
|
+
def for(key)
|
18
21
|
@engine_registry[key]
|
19
22
|
end
|
20
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixer_upper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Ahn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|