munge 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/lib/munge.rb +32 -31
  3. data/lib/munge/application.rb +7 -7
  4. data/lib/munge/bootloader.rb +0 -11
  5. data/lib/munge/cli.rb +3 -3
  6. data/lib/munge/cli/commands/build.rb +17 -21
  7. data/lib/munge/cli/commands/clean.rb +28 -33
  8. data/lib/munge/cli/commands/init.rb +1 -1
  9. data/lib/munge/cli/commands/server.rb +3 -3
  10. data/lib/munge/cli/dispatch.rb +56 -13
  11. data/lib/munge/config.rb +2 -2
  12. data/lib/munge/{system.rb → conglomerate.rb} +21 -14
  13. data/lib/munge/{system → conglomerate}/collection.rb +5 -26
  14. data/lib/munge/{system → conglomerate}/item_factory.rb +1 -1
  15. data/lib/munge/{system → conglomerate}/item_factory/content_parser.rb +1 -1
  16. data/lib/munge/{system → conglomerate}/item_factory/item_identifier.rb +1 -1
  17. data/lib/munge/conglomerate/processor.rb +138 -0
  18. data/lib/munge/conglomerate/reader.rb +33 -0
  19. data/lib/munge/{system → conglomerate}/router.rb +3 -3
  20. data/lib/munge/{system → conglomerate}/router/itemish.rb +1 -1
  21. data/lib/munge/{errors.rb → error.rb} +1 -25
  22. data/lib/munge/{extras → extra}/livereload.rb +5 -5
  23. data/lib/munge/{extras → extra}/livereload/messaging.rb +1 -1
  24. data/lib/munge/{extras → extra}/livereload/server.rb +1 -1
  25. data/lib/munge/{extras → extra}/livereload/update_client.rb +1 -1
  26. data/lib/munge/{extras → extra}/livereload/update_server.rb +1 -1
  27. data/lib/munge/{extras → extra}/livereload/vendor/livereload.js +0 -0
  28. data/lib/munge/{formatters → formatter}/default.rb +1 -1
  29. data/lib/munge/{formatters → formatter}/dots.rb +1 -1
  30. data/lib/munge/{formatters → formatter}/silent.rb +1 -1
  31. data/lib/munge/function/clean.rb +18 -0
  32. data/lib/munge/function/write.rb +68 -0
  33. data/lib/munge/go/sass.rb +5 -5
  34. data/lib/munge/go/sass/asset_urls.rb +2 -2
  35. data/lib/munge/{helpers → helper}/asset_paths.rb +1 -1
  36. data/lib/munge/{helpers → helper}/asset_tags.rb +1 -1
  37. data/lib/munge/{helpers → helper}/capture.rb +1 -1
  38. data/lib/munge/helper/data.rb +21 -0
  39. data/lib/munge/helper/define_module.rb +13 -0
  40. data/lib/munge/{helpers → helper}/find.rb +3 -3
  41. data/lib/munge/{helpers → helper}/link.rb +3 -3
  42. data/lib/munge/{helpers → helper}/livereload.rb +1 -1
  43. data/lib/munge/helper/rendering.rb +51 -0
  44. data/lib/munge/{helpers → helper}/tag.rb +4 -8
  45. data/lib/munge/item.rb +4 -5
  46. data/lib/munge/load.rb +60 -0
  47. data/lib/munge/pre_init.rb +10 -7
  48. data/lib/munge/{routers → router}/add_directory_index.rb +1 -1
  49. data/lib/munge/{routers → router}/auto_add_extension.rb +1 -1
  50. data/lib/munge/{routers → router}/fingerprint.rb +1 -1
  51. data/lib/munge/{routers → router}/remove_index_basename.rb +1 -1
  52. data/lib/munge/version.rb +1 -1
  53. data/lib/munge/vfs/dry_run.rb +28 -0
  54. data/lib/munge/vfs/filesystem.rb +44 -0
  55. data/lib/munge/vfs/memory.rb +33 -0
  56. data/lib/munge/write_manager/all.rb +11 -11
  57. data/lib/munge/write_manager/only_needed.rb +9 -9
  58. data/munge.gemspec +25 -17
  59. data/seeds/boot.rb +21 -0
  60. data/seeds/boot.yml +10 -0
  61. data/seeds/config.rb +7 -0
  62. data/seeds/layouts/blog_archives.html.erb +1 -1
  63. data/seeds/layouts/blog_index.html.erb +1 -1
  64. data/seeds/layouts/default.html.erb +1 -1
  65. data/seeds/lib/routing.rb +8 -8
  66. data/seeds/lib/sass.rb +1 -1
  67. data/seeds/lib/view_helpers.rb +3 -11
  68. data/seeds/rules.rb +1 -1
  69. data/seeds/src/home/index.html.erb +1 -1
  70. metadata +64 -46
  71. data/lib/munge/cleaner.rb +0 -31
  72. data/lib/munge/helpers/rendering.rb +0 -100
  73. data/lib/munge/init.rb +0 -45
  74. data/lib/munge/io/dry_run.rb +0 -31
  75. data/lib/munge/io/filesystem.rb +0 -38
  76. data/lib/munge/io/noop.rb +0 -27
  77. data/lib/munge/runner.rb +0 -68
  78. data/lib/munge/system/processor.rb +0 -52
  79. data/lib/munge/system/readers/filesystem.rb +0 -52
  80. data/lib/munge/transformers/tilt_transformer.rb +0 -40
  81. data/lib/munge/util/import.rb +0 -15
  82. data/seeds/setup.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6789b26f5adfbb4e63f7765b893eb1e76d9b2cb4
4
- data.tar.gz: 2b3aa5cdebf2d78b0bb5af87c17cbe198438b04f
3
+ metadata.gz: 182b8b1edb4fd48e071f740629c0ba64819ea1b1
4
+ data.tar.gz: 92fe60dcdfa3db9d725ce3d4c771608b8b06605a
5
5
  SHA512:
6
- metadata.gz: fd0195d991650cc4d4fc0b149db88b5f844a15e77f19b948accf22fb8f4bd23d2f97cb8a145d776395d6df46595442f1cafb015c242ca872159addf165ccfd17
7
- data.tar.gz: 78d5a5efdc0e9b2b97ad70daf23689855b8d04389e7c82bcbd0211a79e08e812d8e03a3fc12eef50b4cfcdb2beb2903868b7f3adb6a8611d588c6a4fa113f02b
6
+ metadata.gz: 8bffbbecdb7b150ff5fb63ece5254cf2fdbb931399fe38a85c8025804db5ae081ad53c6e3ff9ae910b1bb3190910dac61eb24dd2e3f079a627bad9c774593e31
7
+ data.tar.gz: 6e72c3ddb97d3f38ab1f9afb52979fe5bf7925b1b81e4a789f0e7560c72ec6f50f6803d52b5dc0e645ee15575c69f95eec8d5dbe14d78a560206d844876dfe9f
@@ -5,6 +5,7 @@ require "yaml"
5
5
  require "cgi"
6
6
 
7
7
  require "tilt"
8
+ require "fixer_upper"
8
9
 
9
10
  if Gem::Specification.find_all_by_name("pry-byebug").any?
10
11
  require "pry-byebug"
@@ -15,47 +16,47 @@ end
15
16
  # Core
16
17
  require "munge/version"
17
18
  require "munge/item"
18
- require "munge/errors"
19
+ require "munge/error"
19
20
  require "munge/util/path"
20
21
  require "munge/util/symbol_hash"
21
22
  require "munge/util/boolean_regex"
22
- require "munge/util/import"
23
- require "munge/system/router"
24
- require "munge/system/router/itemish"
25
- require "munge/system/item_factory"
26
- require "munge/system/item_factory/content_parser"
27
- require "munge/system/item_factory/item_identifier"
28
- require "munge/system/collection"
29
- require "munge/system/readers/filesystem"
30
- require "munge/system/processor"
31
- require "munge/system"
32
- require "munge/io/dry_run"
33
- require "munge/io/filesystem"
34
- require "munge/io/noop"
23
+ require "munge/conglomerate/router"
24
+ require "munge/conglomerate/router/itemish"
25
+ require "munge/conglomerate/item_factory"
26
+ require "munge/conglomerate/item_factory/content_parser"
27
+ require "munge/conglomerate/item_factory/item_identifier"
28
+ require "munge/conglomerate/collection"
29
+ require "munge/conglomerate/reader"
30
+ require "munge/conglomerate/processor"
31
+ require "munge/conglomerate"
32
+ require "munge/vfs/dry_run"
33
+ require "munge/vfs/filesystem"
34
+ require "munge/vfs/memory"
35
35
  require "munge/write_manager/all"
36
36
  require "munge/write_manager/only_needed"
37
+ require "munge/function/clean"
38
+ require "munge/function/write"
37
39
  require "munge/application"
38
40
  require "munge/config"
39
- require "munge/runner"
40
41
  require "munge/reporter"
41
- require "munge/cleaner"
42
42
  require "munge/pre_init"
43
- require "munge/init"
44
43
  require "munge/bootloader"
44
+ require "munge/load"
45
45
 
46
46
  # Extensions
47
- require "munge/helpers/asset_tags"
48
- require "munge/helpers/asset_paths"
49
- require "munge/helpers/capture"
50
- require "munge/helpers/find"
51
- require "munge/helpers/link"
52
- require "munge/helpers/rendering"
53
- require "munge/helpers/tag"
54
- require "munge/helpers/livereload"
55
- require "munge/routers/auto_add_extension"
56
- require "munge/routers/fingerprint"
57
- require "munge/routers/add_directory_index"
58
- require "munge/routers/remove_index_basename"
59
- require "munge/transformers/tilt_transformer"
47
+ require "munge/helper/asset_tags"
48
+ require "munge/helper/asset_paths"
49
+ require "munge/helper/capture"
50
+ require "munge/helper/data"
51
+ require "munge/helper/find"
52
+ require "munge/helper/link"
53
+ require "munge/helper/rendering"
54
+ require "munge/helper/tag"
55
+ require "munge/helper/livereload"
56
+ require "munge/helper/define_module"
57
+ require "munge/router/auto_add_extension"
58
+ require "munge/router/fingerprint"
59
+ require "munge/router/add_directory_index"
60
+ require "munge/router/remove_index_basename"
60
61
 
61
- require "munge/extras/livereload"
62
+ require "munge/extra/livereload"
@@ -2,13 +2,13 @@ module Munge
2
2
  # This class is one of the main interfaces users would interact with. This
3
3
  # provides methods to create and iterate through items.
4
4
  class Application
5
- def initialize(system)
6
- @system = system
5
+ def initialize(conglomerate)
6
+ @conglomerate = conglomerate
7
7
  end
8
8
 
9
9
  # @return [Array<Item>]
10
10
  def items
11
- @system.items
11
+ @conglomerate.items
12
12
  end
13
13
 
14
14
  # @return [Array<Item>]
@@ -25,7 +25,7 @@ module Munge
25
25
  #
26
26
  # @return [Item]
27
27
  def build_virtual_item(relpath, content, **frontmatter)
28
- @system.item_factory.build(relpath: relpath, content: content, frontmatter: frontmatter)
28
+ @conglomerate.item_factory.build(relpath: relpath, content: content, frontmatter: frontmatter)
29
29
  end
30
30
 
31
31
  # Creates an Item and inserts it into the registry of Items.
@@ -37,15 +37,15 @@ module Munge
37
37
  # @return [Array<Item>]
38
38
  def create(*args)
39
39
  item = build_virtual_item(*args)
40
- @system.items.push(item)
40
+ @conglomerate.items.push(item)
41
41
  [item]
42
42
  end
43
43
 
44
- # Returns parts of System
44
+ # Returns parts of Conglomerate
45
45
  #
46
46
  # @private
47
47
  def vomit(component_name)
48
- @system.public_send(component_name)
48
+ @conglomerate.public_send(component_name)
49
49
  end
50
50
  end
51
51
  end
@@ -11,17 +11,6 @@ module Munge
11
11
  @config = Munge::PreInit.new(config_path).config
12
12
  end
13
13
 
14
- # @return [Munge::Init]
15
- def init
16
- @init ||=
17
- Init.new(
18
- root_path: root_path,
19
- config: config,
20
- setup_path: setup_path,
21
- rules_path: rules_path
22
- )
23
- end
24
-
25
14
  attr_reader :root_path
26
15
  attr_reader :setup_path
27
16
  attr_reader :rules_path
@@ -9,6 +9,6 @@ require "munge/cli/commands/clean"
9
9
  require "munge/cli/commands/update"
10
10
  require "munge/cli/dispatch"
11
11
 
12
- require "munge/formatters/default"
13
- require "munge/formatters/dots"
14
- require "munge/formatters/silent"
12
+ require "munge/formatter/default"
13
+ require "munge/formatter/dots"
14
+ require "munge/formatter/silent"
@@ -10,46 +10,42 @@ module Munge
10
10
  def initialize(bootloader, dry_run:, reporter:, verbosity:, build_root: nil)
11
11
  destination_root = bootloader.root_path
12
12
  config = bootloader.config
13
- app = application(bootloader)
14
13
  destination = File.expand_path(build_root || config[:output_path], destination_root)
15
14
 
16
- io = new_io(dry_run)
15
+ vfs = new_vfs(dry_run, destination)
16
+
17
+ loader = Munge::Load.new(bootloader.root_path)
17
18
 
18
19
  @runner =
19
- Munge::Runner.new(
20
- items: app.vomit(:items),
21
- router: app.vomit(:router),
22
- processor: app.vomit(:processor),
23
- io: io,
24
- reporter: Munge::Reporter.new(formatter: new_formatter(reporter), verbosity: verbosity.to_sym),
25
- destination: destination,
26
- manager: Munge::WriteManager::OnlyNeeded.new(io)
27
- )
20
+ loader.app do |_application, conglomerate|
21
+ Munge::Function::Write.new(
22
+ conglomerate: conglomerate,
23
+ reporter: Munge::Reporter.new(formatter: new_formatter(reporter), verbosity: verbosity.to_sym),
24
+ manager: Munge::WriteManager::OnlyNeeded.new(vfs),
25
+ destination: vfs
26
+ )
27
+ end
28
28
  end
29
29
 
30
30
  # @return [Array<String>] list of updated items routes
31
31
  def call
32
- @runner.write
32
+ @runner.call
33
33
  end
34
34
 
35
35
  private
36
36
 
37
- def application(bootloader)
38
- bootstrap = bootloader.init
39
-
40
- bootstrap.app
41
- end
37
+ def new_vfs(dry_run, destination)
38
+ fs = Munge::Vfs::Filesystem.new(destination)
42
39
 
43
- def new_io(dry_run)
44
40
  if dry_run
45
- Munge::Io::DryRun.new(Munge::Io::Filesystem.new)
41
+ Munge::Vfs::DryRun.new(fs)
46
42
  else
47
- Munge::Io::Filesystem.new
43
+ fs
48
44
  end
49
45
  end
50
46
 
51
47
  def new_formatter(class_name)
52
- Munge::Formatters.const_get(class_name).new
48
+ Munge::Formatter.const_get(class_name).new
53
49
  end
54
50
  end
55
51
  end
@@ -6,54 +6,49 @@ module Munge
6
6
  def initialize(bootloader, dry_run:, reporter:, verbosity:, build_root: nil)
7
7
  destination_root = bootloader.root_path
8
8
  config = bootloader.config
9
- app = application(bootloader)
10
9
  destination = File.expand_path(build_root || config[:output_path], destination_root)
11
- @dry_run = dry_run
12
10
 
13
- io = Munge::Io::DryRun.new(Munge::Io::Filesystem.new)
11
+ memory = Munge::Vfs::Memory.new
12
+ vfs = new_vfs(dry_run, destination)
13
+
14
+ loader = Munge::Load.new(bootloader.root_path)
14
15
 
15
16
  @runner =
16
- Munge::Runner.new(
17
- items: app.vomit(:items),
18
- router: app.vomit(:router),
19
- processor: app.vomit(:processor),
20
- io: io,
21
- reporter: Munge::Reporter.new(formatter: formatter("Silent"), verbosity: :silent),
22
- destination: destination,
23
- manager: Munge::WriteManager::All.new(io)
24
- )
17
+ loader.app do |_application, conglomerate|
18
+ Munge::Function::Write.new(
19
+ conglomerate: conglomerate,
20
+ reporter: Munge::Reporter.new(formatter: formatter("Silent"), verbosity: :silent),
21
+ manager: Munge::WriteManager::All.new(memory),
22
+ destination: memory
23
+ ).call
24
+
25
+ Munge::Function::Clean.new(
26
+ memory: memory,
27
+ destination: vfs
28
+ )
29
+ end
25
30
 
26
31
  @output_path = File.expand_path(build_root || config[:output_path], destination_root)
27
32
  end
28
33
 
29
34
  def call
30
- io =
31
- if @dry_run
32
- Munge::Io::DryRun.new(Munge::Io::Filesystem.new)
33
- else
34
- Munge::Io::Filesystem.new
35
- end
36
-
37
- cleaner =
38
- Munge::Cleaner.new(
39
- path_to_clean: @output_path,
40
- paths_to_write: @runner.write,
41
- io: io
42
- )
43
-
44
- cleaner.delete
35
+ @runner.call
45
36
  end
46
37
 
47
38
  private
48
39
 
49
- def application(bootloader)
50
- bootstrap = bootloader.init
51
-
52
- bootstrap.app
40
+ def formatter(class_name)
41
+ Munge::Formatter.const_get(class_name).new
53
42
  end
54
43
 
55
- def formatter(class_name)
56
- Munge::Formatters.const_get(class_name).new
44
+ def new_vfs(dry_run, destination)
45
+ fs = Munge::Vfs::Filesystem.new(destination)
46
+
47
+ if dry_run
48
+ Munge::Vfs::DryRun.new(fs)
49
+ else
50
+ fs
51
+ end
57
52
  end
58
53
  end
59
54
  end
@@ -32,7 +32,7 @@ module Munge
32
32
  require "bundler"
33
33
 
34
34
  ::Bundler.with_clean_env do
35
- system("bundle #{command}")
35
+ Kernel.system("bundle #{command}")
36
36
  end
37
37
  end
38
38
  end
@@ -10,13 +10,13 @@ module Munge
10
10
  @livereload =
11
11
  if livereload
12
12
  if Gem.loaded_specs.key?("reel")
13
- Munge::Extras::Livereload::Main.new(true)
13
+ Munge::Extra::Livereload::Main.new(true)
14
14
  else
15
15
  STDERR.puts "Gem `reel` is not installed. Check that your Ruby version is compatible"
16
- Munge::Extras::Livereload::Main.new(false)
16
+ Munge::Extra::Livereload::Main.new(false)
17
17
  end
18
18
  else
19
- Munge::Extras::Livereload::Main.new(false)
19
+ Munge::Extra::Livereload::Main.new(false)
20
20
  end
21
21
  end
22
22
 
@@ -8,9 +8,20 @@ module Munge
8
8
  end
9
9
 
10
10
  desc "build", "Build site"
11
- method_option :reporter, desc: "Set reporting formatter", default: "Default", type: :string
12
- method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
13
- method_option :verbosity, aliases: "-v", desc: "Preferred amount of output", enum: %w(all written silent), default: "written", type: :string
11
+ method_option :reporter,
12
+ desc: "Set reporting formatter",
13
+ default: "Default",
14
+ type: :string
15
+ method_option :dry_run,
16
+ desc: "Run without writing files",
17
+ default: false,
18
+ type: :boolean
19
+ method_option :verbosity,
20
+ aliases: "-v",
21
+ desc: "Preferred amount of output",
22
+ enum: %w(all written silent),
23
+ default: "written",
24
+ type: :string
14
25
  def build
15
26
  production!
16
27
 
@@ -18,8 +29,16 @@ module Munge
18
29
  end
19
30
 
20
31
  desc "view", "View built files"
21
- method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
22
- method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
32
+ method_option :port,
33
+ aliases: "-p",
34
+ desc: "Set port",
35
+ default: 7000,
36
+ type: :numeric
37
+ method_option :host,
38
+ aliases: "-h",
39
+ desc: "Set host",
40
+ default: "0.0.0.0",
41
+ type: :string
23
42
  def view
24
43
  production!
25
44
 
@@ -27,9 +46,20 @@ module Munge
27
46
  end
28
47
 
29
48
  desc "server", "Run the development server"
30
- method_option :livereload, desc: "Reload browser on update", default: Gem.loaded_specs.key?("reel"), type: :boolean
31
- method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
32
- method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
49
+ method_option :livereload,
50
+ desc: "Reload browser on update",
51
+ default: Gem.loaded_specs.key?("reel"),
52
+ type: :boolean
53
+ method_option :port,
54
+ aliases: "-p",
55
+ desc: "Set port",
56
+ default: 7000,
57
+ type: :numeric
58
+ method_option :host,
59
+ aliases: "-h",
60
+ desc: "Set host",
61
+ default: "0.0.0.0",
62
+ type: :string
33
63
  def server
34
64
  development!
35
65
 
@@ -37,16 +67,29 @@ module Munge
37
67
  end
38
68
 
39
69
  desc "clean", "Remove old built files (generally unnecessary)"
40
- method_option :reporter, desc: "Set reporting formatter", default: "Default", type: :string
41
- method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
42
- method_option :verbosity, aliases: "-v", desc: "Preferred amount of output", enum: %w(all written silent), default: "written", type: :string
70
+ method_option :reporter,
71
+ desc: "Set reporting formatter",
72
+ default: "Default",
73
+ type: :string
74
+ method_option :dry_run,
75
+ desc: "Run without writing files",
76
+ default: false,
77
+ type: :boolean
78
+ method_option :verbosity,
79
+ aliases: "-v",
80
+ desc: "Preferred amount of output",
81
+ enum: %w(all written silent),
82
+ default: "written",
83
+ type: :string
43
84
  def clean
44
85
  production!
45
86
 
46
87
  Commands::Clean.new(bootloader, **symbolized_options, build_root: ENV["BUILD_ROOT"]).call
47
88
  end
48
89
 
49
- desc "update", "Use with caution: override local configs with pristine version (useful after bumping version in Gemfile)"
90
+ desc "update",
91
+ "Use with caution: override local configs with pristine version " \
92
+ "(useful after bumping version in Gemfile)"
50
93
  def update
51
94
  development!
52
95
 
@@ -67,7 +110,7 @@ module Munge
67
110
 
68
111
  def bootloader
69
112
  Munge::Bootloader.new(root_path: current_working_directory)
70
- rescue Munge::Errors::ConfigRbNotFound => e
113
+ rescue Munge::Error::ConfigRbNotFound => e
71
114
  puts e.message
72
115
  exit
73
116
  end