munge 0.7.0 → 0.7.1

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: e5afa7095e7748d33f0ed3eb2896c4c25d2fa5dd
4
- data.tar.gz: c772f9864ea064587b5d16f1445f6e6064780024
3
+ metadata.gz: 7fa33dfb3bfa3c6040f2b72dd3a5f382d52f1805
4
+ data.tar.gz: 7c053502ee9c5bf4f7571d80ae40ba5c87731c40
5
5
  SHA512:
6
- metadata.gz: 396bfa27c4b98d242674f24e9845b6161b45cadc94fa7bacb17565766d0b3a72528b0b26415682056af7f012529973be0e6b565712e0510a279c94591a5cbc50
7
- data.tar.gz: a4df269dd5dd9b109409427f603a9c44565156f88e5ffb9fd16bffa24a3727bc2afa4a70a812dc2ad94e81d954bc44ec370ba6277bd98f8ae624bfa22ef32788
6
+ metadata.gz: 8d3061ee4abaf367192b0afde561b912f0dee607b867bed033ce02baaaa58a69805f205a49aeb084d016581de59399f7a591fa26d48f8d74153d3dca11c98ad8
7
+ data.tar.gz: 5c2842c9a228b1a283fa587160eb5ad80e8ee97d716984675e9f7eacfd906f2e7022ebca728cedd7ff6a43271e03dfde447f5655fd250cffccec09d4e185775c
data/.rubocop.yml CHANGED
@@ -4,13 +4,17 @@ AllCops:
4
4
  - vendor/bundle/**/*
5
5
  - Gemfile
6
6
  - Rakefile
7
- - seeds/**/*
7
+ - munge.gemspec
8
8
 
9
9
  Metrics/AbcSize:
10
10
  Exclude:
11
11
  - test/**/*
12
12
 
13
+ Metrics/LineLength:
14
+ Max: 120
15
+
13
16
  Metrics/MethodLength:
17
+ Max: 15
14
18
  Exclude:
15
19
  - test/**/*
16
20
 
@@ -42,5 +46,9 @@ Style/MultilineOperationIndentation:
42
46
  Style/StringLiterals:
43
47
  EnforcedStyle: double_quotes
44
48
 
49
+ Style/SymbolProc:
50
+ Exclude:
51
+ - seeds/**/*
52
+
45
53
  Style/UnneededInterpolation:
46
54
  Enabled: false
data/lib/munge.rb CHANGED
@@ -19,7 +19,10 @@ require "munge/util/path"
19
19
  require "munge/util/symbol_hash"
20
20
  require "munge/util/config"
21
21
  require "munge/system/router"
22
+ require "munge/system/router/itemish"
22
23
  require "munge/system/item_factory"
24
+ require "munge/system/item_factory/content_parser"
25
+ require "munge/system/item_factory/item_identifier"
23
26
  require "munge/system/collection"
24
27
  require "munge/system/readers/filesystem"
25
28
  require "munge/system/alterant"
@@ -29,7 +32,8 @@ require "munge/writers/noop"
29
32
  require "munge/write_manager"
30
33
  require "munge/application"
31
34
  require "munge/runner"
32
- require "munge/bootstrap"
35
+ require "munge/init"
36
+ require "munge/bootloader"
33
37
 
34
38
  # Extensions
35
39
  require "munge/helpers/asset_tags"
@@ -0,0 +1,27 @@
1
+ module Munge
2
+ class Bootloader
3
+ def initialize(root_path:)
4
+ @root_path = root_path
5
+ @config_path = File.join(root_path, "config.yml")
6
+ @setup_path = File.join(root_path, "setup.rb")
7
+ @rules_path = File.join(root_path, "rules.rb")
8
+ @config = Munge::Util::Config.read(@config_path)
9
+ end
10
+
11
+ def init
12
+ @init ||=
13
+ Init.new(
14
+ root_path: @root_path,
15
+ config: @config,
16
+ setup_path: @setup_path,
17
+ rules_path: @rules_path
18
+ )
19
+ end
20
+
21
+ attr_reader :root_path
22
+ attr_reader :config_path
23
+ attr_reader :setup_path
24
+ attr_reader :rules_path
25
+ attr_reader :config
26
+ end
27
+ end
@@ -2,18 +2,18 @@ module Munge
2
2
  module Cli
3
3
  module Commands
4
4
  class Build
5
- def initialize(destination_root, config, options)
6
- @app = application(destination_root)
7
- @dry_run = options[:dry_run]
8
- reporter_class = Munge::Reporters.const_get(options[:reporter])
5
+ def initialize(bootloader, dry_run:, reporter:)
6
+ destination_root = bootloader.root_path
7
+ config = bootloader.config
8
+ @app = application(bootloader)
9
9
 
10
10
  runner =
11
11
  Munge::Runner.new(
12
12
  items: @app.vomit(:items),
13
13
  router: @app.vomit(:router),
14
14
  alterant: @app.vomit(:alterant),
15
- writer: writer,
16
- reporter: reporter_class.new,
15
+ writer: writer(dry_run),
16
+ reporter: reporter(reporter),
17
17
  destination: File.expand_path(config[:output], destination_root)
18
18
  )
19
19
 
@@ -22,19 +22,23 @@ module Munge
22
22
 
23
23
  private
24
24
 
25
- def application(root_path)
26
- bootstrap = Munge::Bootstrap.new_from_dir(root_path: root_path)
25
+ def application(bootloader)
26
+ bootstrap = bootloader.init
27
27
 
28
28
  bootstrap.app
29
29
  end
30
30
 
31
- def writer
32
- if @dry_run
31
+ def writer(dry_run)
32
+ if dry_run
33
33
  Munge::Writers::Noop.new
34
34
  else
35
35
  Munge::Writers::Filesystem.new
36
36
  end
37
37
  end
38
+
39
+ def reporter(class_name)
40
+ Munge::Reporters.const_get(class_name).new
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -28,9 +28,8 @@ module Munge
28
28
  module Cli
29
29
  module Commands
30
30
  class View
31
- def initialize(config_path, options)
32
- config = Munge::Util::Config.read(config_path)
33
- rack_opts = { Host: options[:host], Port: options[:port] }
31
+ def initialize(bootloader, host:, port:)
32
+ config = bootloader.config
34
33
 
35
34
  app =
36
35
  Rack::Builder.new do
@@ -40,7 +39,7 @@ module Munge
40
39
  run Rack::File.new(config[:output])
41
40
  end
42
41
 
43
- Rack::Handler::WEBrick.run(app, rack_opts)
42
+ Rack::Handler::WEBrick.run(app, Host: host, Port: port)
44
43
  end
45
44
  end
46
45
  end
@@ -18,14 +18,14 @@ module Munge
18
18
  method_option :reporter, desc: "Set reporter", default: "Default", type: :string
19
19
  method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
20
20
  def build
21
- Commands::Build.new(destination_root, loaded_config, options)
21
+ Commands::Build.new(bootloader, symbolized_options)
22
22
  end
23
23
 
24
24
  desc "view", "View built files"
25
25
  method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
26
26
  method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
27
27
  def view
28
- Commands::View.new(config_path, options)
28
+ Commands::View.new(bootloader, symbolized_options)
29
29
  end
30
30
 
31
31
  desc "version", "Print version"
@@ -36,16 +36,12 @@ module Munge
36
36
 
37
37
  private
38
38
 
39
- def loaded_config
40
- Munge::Util::Config.read(config_path)
39
+ def bootloader
40
+ Munge::Bootloader.new(root_path: destination_root)
41
41
  end
42
42
 
43
- def config_path
44
- File.join(destination_root, "config.yml")
45
- end
46
-
47
- def rules_path
48
- File.join(destination_root, "rules.rb")
43
+ def symbolized_options
44
+ Munge::Util::SymbolHash.deep_convert(options)
49
45
  end
50
46
  end
51
47
  end
data/lib/munge/go/sass.rb CHANGED
@@ -9,11 +9,13 @@ module Munge
9
9
  Sass.load_paths << File.join(*paths)
10
10
  end
11
11
 
12
+ # rubocop:disable Style/AccessorMethodName
12
13
  def set_sass_system!(system)
13
14
  Sass::Script::Functions.send(:define_method, :system) do
14
15
  system
15
16
  end
16
17
  end
18
+ # rubocop:enable Style/AccessorMethodName
17
19
 
18
20
  def add_sass_functions!(asset_roots)
19
21
  Sass::Script::Functions.send(:include, asset_roots)
@@ -4,7 +4,7 @@ module Munge
4
4
  def render(item, engines: nil, data: {}, content_override: nil)
5
5
  content = content_override || item.content
6
6
  renderers = tilt_renderer_list(item, engines)
7
- mdata = merged_data(item.frontmatter, data, { self_item: item })
7
+ mdata = merged_data(item.frontmatter, data, self_item: item)
8
8
 
9
9
  render_string(content, data: mdata, engines: renderers)
10
10
  end
@@ -12,7 +12,7 @@ module Munge
12
12
  def layout(item_or_string, data: {}, &block)
13
13
  layout_item = resolve_layout(item_or_string)
14
14
  renderers = tilt_renderer_list(layout_item, nil)
15
- mdata = merged_data(layout_item.frontmatter, data, { self_layout: layout_item })
15
+ mdata = merged_data(layout_item.frontmatter, data, self_layout: layout_item)
16
16
 
17
17
  render_string(layout_item.content, data: mdata, engines: renderers, &block)
18
18
  end
@@ -25,8 +25,8 @@ module Munge
25
25
 
26
26
  output =
27
27
  engines
28
- .inject(content) do |output, engine|
29
- template = engine.new { output }
28
+ .inject(content) do |memo, engine|
29
+ template = engine.new { memo }
30
30
 
31
31
  if inner
32
32
  template.render(self, data) { inner }
@@ -44,7 +44,7 @@ module Munge
44
44
 
45
45
  def render_with_layout(item, content_engines: nil, data: {}, content_override: nil)
46
46
  inner = render(item, engines: content_engines, data: data, content_override: content_override)
47
- mdata = merged_data(item.frontmatter, data, { self_item: item })
47
+ mdata = merged_data(item.frontmatter, data, self_item: item)
48
48
 
49
49
  if item.layout
50
50
  layout(item.layout, data: mdata) do
data/lib/munge/init.rb ADDED
@@ -0,0 +1,34 @@
1
+ module Munge
2
+ class Init
3
+ def initialize(root_path:,
4
+ config:,
5
+ setup_path:,
6
+ rules_path:)
7
+ @root_path = root_path
8
+ @setup_path = setup_path
9
+ @rules_path = rules_path
10
+ @binding = binding
11
+
12
+ system = Munge::System.new(root_path, config)
13
+
14
+ import(setup_path)
15
+
16
+ @app = Munge::Application.new(system)
17
+
18
+ import(rules_path)
19
+ end
20
+
21
+ def config_path
22
+ File.join(root_path, "config")
23
+ end
24
+
25
+ def import(file_path)
26
+ absolute_file_path = File.expand_path(file_path, root_path)
27
+ contents = File.read(absolute_file_path)
28
+ @binding.eval(contents, absolute_file_path)
29
+ end
30
+
31
+ attr_reader :app
32
+ attr_reader :root_path
33
+ end
34
+ end
@@ -11,7 +11,7 @@ module Munge
11
11
  when :identical
12
12
  puts "identical #{item.route}"
13
13
  when :double_write_error
14
- fail "attempted to write #{item.route} twice"
14
+ raise "attempted to write #{item.route} twice"
15
15
  end
16
16
  end
17
17
  end
data/lib/munge/runner.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module Munge
2
2
  class Runner
3
3
  def initialize(items:, router:, alterant:, writer:, reporter:, destination:)
4
- @items = items
5
- @router = router
6
- @alterant = alterant
7
- @writer = writer
8
- @reporter = reporter
4
+ @items = items
5
+ @router = router
6
+ @alterant = alterant
7
+ @writer = writer
8
+ @reporter = reporter
9
9
  @write_manager = Munge::WriteManager.new(driver: File)
10
10
  @destination = destination
11
11
  end
data/lib/munge/system.rb CHANGED
@@ -4,7 +4,6 @@ module Munge
4
4
  def initialize(root_path, config)
5
5
  source_path = File.expand_path(config[:source], root_path)
6
6
  layouts_path = File.expand_path(config[:layouts], root_path)
7
- output_path = File.expand_path(config[:output], root_path)
8
7
  data_path = File.expand_path(config[:data], root_path)
9
8
 
10
9
  @global_data = YAML.load_file(data_path) || {}
@@ -1,13 +1,10 @@
1
- require_relative "item_factory/content_parser"
2
- require_relative "item_factory/item_identifier"
3
-
4
1
  module Munge
5
2
  class System
6
3
  class ItemFactory
7
4
  def initialize(text_extensions:,
8
5
  ignore_extensions:)
9
6
  @text_extensions = Set.new(text_extensions)
10
- @item_identifier = Munge::System::ItemFactory::ItemIdentifier.new(remove_extensions: ignore_extensions)
7
+ @item_identifier = ItemIdentifier.new(remove_extensions: ignore_extensions)
11
8
  end
12
9
 
13
10
  def build(relpath:,
@@ -34,7 +31,7 @@ module Munge
34
31
  type = compute_file_type(relpath)
35
32
 
36
33
  if type == :text
37
- parsed = Munge::System::ItemFactory::ContentParser.new(content)
34
+ parsed = ContentParser.new(content)
38
35
 
39
36
  build(
40
37
  relpath: relpath,
@@ -1,5 +1,3 @@
1
- require_relative "router/itemish"
2
-
3
1
  module Munge
4
2
  class System
5
3
  class Router
data/lib/munge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Munge
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1".freeze
3
3
  end
@@ -15,5 +15,5 @@ system.router.register(
15
15
  ))
16
16
  system.router.register(
17
17
  Routers::AutoAddExtension.new(
18
- keep_extensions: config[:bin_extensions] + config[:bintext_extensions],
18
+ keep_extensions: config[:bin_extensions] + config[:bintext_extensions]
19
19
  ))
data/seeds/config/sass.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "munge/go/sass"
2
2
 
3
- Munge::Go::add_sass_load_path!(root_path, config[:source], AssetRoots.stylesheets_root)
3
+ Munge::Go.add_sass_load_path!(root_path, config[:source], AssetRoots.stylesheets_root)
4
4
 
5
- Munge::Go::set_sass_system!(system)
5
+ Munge::Go.set_sass_system!(system)
6
6
 
7
- Munge::Go::add_sass_functions!(AssetRoots)
7
+ Munge::Go.add_sass_functions!(AssetRoots)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: munge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2016-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '3.4'
195
- description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.7.0/README.md
195
+ description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.7.1/README.md
196
196
  email:
197
197
  - zach.ahn@gmail.com
198
198
  executables:
@@ -212,7 +212,7 @@ files:
212
212
  - exe/munge
213
213
  - lib/munge.rb
214
214
  - lib/munge/application.rb
215
- - lib/munge/bootstrap.rb
215
+ - lib/munge/bootloader.rb
216
216
  - lib/munge/cli.rb
217
217
  - lib/munge/cli/commands/build.rb
218
218
  - lib/munge/cli/commands/view.rb
@@ -226,6 +226,7 @@ files:
226
226
  - lib/munge/helpers/link.rb
227
227
  - lib/munge/helpers/rendering.rb
228
228
  - lib/munge/helpers/tag.rb
229
+ - lib/munge/init.rb
229
230
  - lib/munge/item.rb
230
231
  - lib/munge/reporters/default.rb
231
232
  - lib/munge/routers/add_index_html.rb
@@ -1,81 +0,0 @@
1
- module Munge
2
- class Bootstrap
3
- class << self
4
- def new_from_dir(root_path:)
5
- new_from_fs(
6
- root_path: root_path,
7
- config_path: config_path(root_path),
8
- setup_path: setup_path(root_path),
9
- rules_path: rules_path(root_path)
10
- )
11
- end
12
-
13
- def new_from_fs(root_path:,
14
- config_path:,
15
- setup_path:,
16
- rules_path:)
17
- new(
18
- root_path: root_path,
19
- config: read_config(config_path),
20
- setup_string: File.read(setup_path),
21
- setup_path: setup_path,
22
- rules_string: File.read(rules_path),
23
- rules_path: rules_path
24
- )
25
- end
26
-
27
- private
28
-
29
- def read_config(config_path)
30
- Munge::Util::Config.read(config_path)
31
- end
32
-
33
- def config_path(root_path)
34
- File.join(root_path, "config.yml")
35
- end
36
-
37
- def setup_path(root_path)
38
- File.join(root_path, "setup.rb")
39
- end
40
-
41
- def rules_path(root_path)
42
- File.join(root_path, "rules.rb")
43
- end
44
- end
45
-
46
- def initialize(root_path:,
47
- config:,
48
- setup_string:,
49
- rules_string:,
50
- setup_path:,
51
- rules_path:)
52
- @setup_path = setup_path
53
- @rules_path = rules_path
54
- @binding = binding
55
-
56
- system = Munge::System.new(root_path, config)
57
-
58
- import(setup_path, setup_string)
59
-
60
- @app = Munge::Application.new(system)
61
-
62
- import(rules_path, rules_string)
63
- end
64
-
65
- def root_path
66
- File.dirname(@setup_path)
67
- end
68
-
69
- def config_path
70
- File.join(root_path, "config")
71
- end
72
-
73
- def import(file_path, file_contents = nil)
74
- absolute_file_path = File.expand_path(file_path, root_path)
75
- contents = file_contents || File.read(absolute_file_path)
76
- @binding.eval(contents, absolute_file_path)
77
- end
78
-
79
- attr_reader :app
80
- end
81
- end