mascot 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mascot/version.rb +1 -1
  3. data/lib/mascot.rb +14 -16
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 343ff35dc45cb328c96b03d009e1d5363af15596
4
- data.tar.gz: 3790e946be54e8797e486254c4c1abd34eaacc89
3
+ metadata.gz: 3076800f4b6e26c015d5ebd26ef066554c791740
4
+ data.tar.gz: 623e0ab9c640f0176f1358b318252ece1d14cae2
5
5
  SHA512:
6
- metadata.gz: c7d62cff29add7de74381c8b7fbdbdcdbd3adf69cac04f5202d9e29d4cb0d46fa37073cb61d2b2afd3414e97b991e834dd47cfb2ef11c204f76f9d8fd482fa0b
7
- data.tar.gz: 21d6e1e972cc405b0c0178b1abf445ee7f341ee89b191ec6ea744eb020ad4dc90053054d8afaa7a1add49aa07fcf460369e9724e8eec550bff1a94c445f90143
6
+ metadata.gz: ff1773ff6586b2f6f3da6158abe7177b0208db6235ed6bcdb2f2c6f050e0ec24a05e44001565365a262a7816dd68c4c0564ee93a39a58925ea7ac43c02aa9d31
7
+ data.tar.gz: 62826327d9c4b2605f1348053b9abce0d80384e7caa3acee6c36ef4dbfcf8f51a78f2ab572231f088bc3a89a5f58b13ce5004894adec50550dc928132e5b38eb
@@ -1,3 +1,3 @@
1
1
  module Mascot
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/mascot.rb CHANGED
@@ -34,13 +34,6 @@ module Mascot
34
34
  # the resource and figure out what to do with it.
35
35
  DEFAULT_MIME_TYPE = MIME::Types["application/octet-stream"].first
36
36
 
37
- # TODO: I don't like the Binding, locals, and frontmatter
38
- # being in the Resource. That should be moved to a page
39
- # object and be delegated to that. Or perhaps the page body?
40
- # I'm moving forward with this now though to keep the objects simpler.
41
- # We'll see how it evolves.
42
- Binding = Struct.new(:data)
43
-
44
37
  attr_reader :request_path, :file_path
45
38
 
46
39
  extend Forwardable
@@ -53,11 +46,6 @@ module Mascot
53
46
  @mime_types = Array(mime_type) if mime_type
54
47
  end
55
48
 
56
- # Locals that should be merged into or given to the rendering context.
57
- def locals
58
- { current_page: Binding.new(data) }
59
- end
60
-
61
49
  # List of all file extensions.
62
50
  def extensions
63
51
  @file_path.basename.to_s.split(".").drop(1)
@@ -94,21 +82,31 @@ module Mascot
94
82
  # Default root request path
95
83
  DEFAULT_ROOT_REQUEST_PATH = Pathname.new("/").freeze
96
84
 
85
+ attr_reader :file_path, :request_path
86
+
97
87
  def initialize(file_path: DEFAULT_ROOT_DIR, request_path: DEFAULT_ROOT_REQUEST_PATH)
98
- @file_path = Pathname.new(file_path)
99
- @request_path = Pathname.new(request_path)
88
+ self.file_path = file_path
89
+ self.request_path = request_path
100
90
  end
101
91
 
102
92
  # Lazy stream of resources.
103
93
  def resources(glob = DEFAULT_GLOB)
104
- Dir[@file_path.join(glob)].lazy.map do |path|
94
+ Dir[@file_path.join(glob)].select(&File.method(:file?)).lazy.map do |path|
105
95
  Resource.new request_path: request_path(path), file_path: path
106
96
  end
107
97
  end
108
98
 
109
99
  # Find the page with a path.
110
100
  def find_by_request_path(request_path)
111
- resources.find { |r| r.request_path == request_path }
101
+ resources.find { |r| r.request_path == File.join("/", request_path) }
102
+ end
103
+
104
+ def file_path=(path)
105
+ @file_path = Pathname.new(path)
106
+ end
107
+
108
+ def request_path=(path)
109
+ @request_path = Pathname.new(path)
112
110
  end
113
111
 
114
112
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mascot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-21 00:00:00.000000000 Z
11
+ date: 2016-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler