markdown_record 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/markdown_record/file_sorting/date_sorter.rb +2 -0
- data/lib/markdown_record/file_sorting/sem_ver_sorter.rb +2 -0
- data/lib/markdown_record/models/association.rb +13 -48
- data/lib/markdown_record/rendering/nodes/html_base.rb +10 -0
- data/lib/markdown_record/version.rb +1 -1
- data/templates/demo/content/2_installation.md.erb +3 -1
- data/templates/demo/content/6_model_basics.md.erb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28719266b418efe6379df27d13947fe87112a92a2752c2ba255794a0e988879f
|
4
|
+
data.tar.gz: 1e65d9b00a6aeea4f1153853430a2ed7b0f5f0c3b910f226ea56aff07b3eb49d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e06ee088c3d506b7fbf056d41a5383478065b41977a31b5653b007c18a6f09141f1912540e14121da17121f3a6b8227843243bb8357009fa1476071569e81c8
|
7
|
+
data.tar.gz: a4b62f1449034d362141f4efc9147bc18add91116a39b9da06296e5c3e42c5ddfce7e4c2d3929c424eed3e961f070396e84fb7716f8da1a8c007a55f6b0cf312
|
data/README.md
CHANGED
@@ -239,7 +239,6 @@ To test a local version of this gem in a local app, simply add the `path` parame
|
|
239
239
|
|
240
240
|
- Make the Content DSL extensible
|
241
241
|
- Add support for raw JSON files as source content
|
242
|
-
- Support semantic versioning in numeric filename prefixes
|
243
242
|
|
244
243
|
## License
|
245
244
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -77,56 +77,21 @@ module MarkdownRecord
|
|
77
77
|
self
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
execute unless fulfilled
|
88
|
-
execute
|
89
|
-
@data.map(...)
|
90
|
-
end
|
91
|
-
|
92
|
-
def count(...)
|
93
|
-
execute unless fulfilled
|
94
|
-
@data.count(...)
|
95
|
-
end
|
96
|
-
|
97
|
-
def any?(...)
|
98
|
-
execute unless fulfilled
|
99
|
-
@data.any?(...)
|
100
|
-
end
|
101
|
-
|
102
|
-
def empty?(...)
|
103
|
-
execute unless fulfilled
|
104
|
-
@data.empty?(...)
|
105
|
-
end
|
106
|
-
|
107
|
-
def first(...)
|
108
|
-
execute unless fulfilled
|
109
|
-
@data.first(...)
|
110
|
-
end
|
111
|
-
|
112
|
-
def last(...)
|
113
|
-
execute unless fulfilled
|
114
|
-
@data.first(...)
|
115
|
-
end
|
116
|
-
|
117
|
-
def second(...)
|
118
|
-
execute unless fulfilled
|
119
|
-
@data.second(...)
|
120
|
-
end
|
121
|
-
|
122
|
-
def third(...)
|
123
|
-
execute unless fulfilled
|
124
|
-
@data.third(...)
|
80
|
+
def method_missing(method, *args, &block)
|
81
|
+
if @data.respond_to?(method)
|
82
|
+
execute unless fulfilled
|
83
|
+
@data.send(method, *args, &block)
|
84
|
+
else
|
85
|
+
super
|
86
|
+
end
|
125
87
|
end
|
126
88
|
|
127
|
-
def
|
128
|
-
|
129
|
-
|
89
|
+
def respond_to?(method)
|
90
|
+
if @data.respond_to?(method)
|
91
|
+
true
|
92
|
+
else
|
93
|
+
super
|
94
|
+
end
|
130
95
|
end
|
131
96
|
|
132
97
|
def __find__(id, scope = nil)
|
@@ -14,6 +14,10 @@ module MarkdownRecord
|
|
14
14
|
/<!---/ => "<!--"
|
15
15
|
}
|
16
16
|
|
17
|
+
HTML_MACROS = {
|
18
|
+
/<code(?:.*?)>((?:.|\s)*?)<\/code>/ => lambda { |match, first| match.gsub(first, CGI.unescapeHTML(CGI.escapeHTML(first))) }
|
19
|
+
}
|
20
|
+
|
17
21
|
def initialize(pathname, markdown, options)
|
18
22
|
@markdown = markdown
|
19
23
|
@pathname = pathname
|
@@ -44,6 +48,12 @@ module MarkdownRecord
|
|
44
48
|
final_html = final_html.gsub(find, replace)
|
45
49
|
end
|
46
50
|
|
51
|
+
HTML_MACROS.each do |regex, macro|
|
52
|
+
final_html = final_html.gsub(regex) do |match|
|
53
|
+
macro.call(match, $1).html_safe
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
47
57
|
final_html = final_html.squeeze("\n")
|
48
58
|
@final_html = HtmlBeautifier.beautify(final_html)
|
49
59
|
end
|
@@ -141,4 +141,6 @@ rendered: /markdown_record/rendered/content/custom_models_and_associations.html
|
|
141
141
|
51 files saved.
|
142
142
|
```
|
143
143
|
|
144
|
-
Congratulations! You have installed MarkdownRecord. If you are not viewing this from the host application already, go ahead and start your Rails server and navigate to your <%= link_to("local host demo", "http://localhost:3000/mdr/content/home") %> to continue following this guide.
|
144
|
+
Congratulations! You have installed MarkdownRecord. If you are not viewing this from the host application already, go ahead and start your Rails server and navigate to your <%= link_to("local host demo", "http://localhost:3000/mdr/content/home") %> to continue following this guide.
|
145
|
+
|
146
|
+
Alternatively, you can find the complete usage guide [here](https://markdown-record-docs.herokuapp.com/).
|
@@ -51,7 +51,7 @@ The `where` query method takes an optional hash of filters and returns a `Markdo
|
|
51
51
|
- `to_fragments`: this method queries for MarkdownRecord models but returns their corresponding content fragments instead. This will often result in duplicates due to models being defined in the same file.
|
52
52
|
- `all`: this method simply returns an Array of models, filtered according to whatever filters have been provided to the association object.
|
53
53
|
|
54
|
-
`MarkdownRecord::Association`
|
54
|
+
`MarkdownRecord::Association` supports any method you can call on the underlying array that contains the query results.
|
55
55
|
|
56
56
|
## Filters
|
57
57
|
|