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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1136862e570043432fd2d7de7ac2fbafaa62094
4
- data.tar.gz: 18adf119e492348a4661ad4aaf2ed40c9f7e6931
3
+ metadata.gz: 222ca8f8dffc3a73359f8676c8ec6818e410166e
4
+ data.tar.gz: 7d31e42a287ebd8226bb647c982f755fcad11ecf
5
5
  SHA512:
6
- metadata.gz: b9e5877c91693e1372bf6d30ce0a7bfea2fdf271f55231fda302e2aa7e80c2e7baff03b1738656649090f72e027c9748835b13d2136935d5fe0ab047f108f906
7
- data.tar.gz: 469e480f850f30dde9a8efe018b335bb34a43cc1d4adfdf9add1859633caf8ff014cbeb477c49586d702ba73daa1162dd7a37780d9b7bb97c4df0238b521f4ca
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, :DEFAULT)
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["md"] = FixerUpperCmark.new
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.call(memo)
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
 
@@ -1,3 +1,3 @@
1
1
  class FixerUpper
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
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
- @renovation = Renovation.new(@engine_registry)
8
+ @options_registry = {}
9
+ @renovation = Renovation.new(@engine_registry, @options_registry)
9
10
  end
10
11
 
11
- def []=(*keys, engine)
12
+ def register(*keys, to:, **options)
12
13
  keys.each do |key|
13
- @engine_registry[key] = engine
14
+ @engine_registry[key] = to
14
15
  end
16
+
17
+ @options_registry[to] = options
15
18
  end
16
19
 
17
- def [](key)
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.1.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-21 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler