trailblazer-loader 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/call_sheet-notes.md +22 -0
- data/lib/trailblazer/loader.rb +33 -26
- data/lib/trailblazer/loader/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3156c8edcfa6d906d4aa3c00451d7cf97ac64818
|
4
|
+
data.tar.gz: cf6e6648d5572126e3bf3c948b6b4171f8845e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d5059d6810255673f9a76d92ca9e34b1dae89b61c9a0372e788399475ce7ba46d6e99018f168a2b63392d1598694334ecc1d4c069380572b863b03e555d18c2
|
7
|
+
data.tar.gz: 34c735b25591d197789a438d771550a0eed3edf51e60c34b91480eb0524133a3df6ee86e5e6c6b3daf6f9cbb95881ff8eb100d1c68aa9dd00fafd3269add703a
|
data/CHANGES.md
CHANGED
data/call_sheet-notes.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
```ruby
|
3
|
+
container = {
|
4
|
+
find_concepts: FindConcepts,
|
5
|
+
sort_concepts: SortConcepts,
|
6
|
+
set_name: ConceptName,
|
7
|
+
concept_files: ConceptFiles,
|
8
|
+
}
|
9
|
+
|
10
|
+
require "call_sheet"
|
11
|
+
sheet = CallSheet(container: container) do
|
12
|
+
map :find_concepts
|
13
|
+
map :sort_concepts
|
14
|
+
end
|
15
|
+
|
16
|
+
require "pp"
|
17
|
+
options[:files] = []
|
18
|
+
pp sheet.(options, all: [1])
|
19
|
+
```
|
20
|
+
|
21
|
+
* how to include step at certain position? e.g. from trailblazer-rails
|
22
|
+
* pass options to all steps
|
data/lib/trailblazer/loader.rb
CHANGED
@@ -1,41 +1,48 @@
|
|
1
1
|
require "trailblazer/loader/version"
|
2
|
+
require "representable/pipeline"
|
2
3
|
|
3
4
|
module Trailblazer
|
4
5
|
class Loader
|
5
6
|
# Please note that this is subject to change - we're still finding out the best way
|
6
7
|
# to explicitly load files.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
#
|
9
|
+
# NOTE: i will most probably use call_sheet and dry-container here soon.
|
10
|
+
def call(options={}, &block)
|
11
|
+
options[:concepts_root] ||= "app/concepts/"
|
12
|
+
|
13
|
+
pipeline = options[:pipeline] || Representable::Pipeline[
|
14
|
+
FindConcepts,
|
15
|
+
SortConcepts,
|
16
|
+
Representable::Collect[ConceptName, ConceptFiles] # per concept.
|
17
|
+
]
|
18
|
+
|
19
|
+
if args = options[:insert] # FIXME: this only implements a sub-set.
|
20
|
+
# pipeline = Representable::Pipeline::Insert.(pipeline, *args) # FIXME: implement :before in Pipeline.
|
21
|
+
pipeline[2].insert(pipeline[2].index(args.last[:before]), args.first)
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
+
files = pipeline.([], options).flatten
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
# require "pp"
|
27
|
+
# pp files
|
27
28
|
|
29
|
+
load_files(files, &block)
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
FindConcepts = ->(input, options) { Dir.glob("#{options[:concepts_root]}**/") }
|
33
|
+
# lame heuristic, but works for me: sort by nested levels.
|
34
|
+
# app/concepts/comment
|
35
|
+
# app/concepts/api/v1/comment
|
36
|
+
SortConcepts = ->(input, options) { input.sort { |a, b| a.split("/").size <=> b.split("/").size } }
|
37
|
+
# Extract concept name from path, e.g. /api/v1/comment.
|
38
|
+
ConceptName = ->(input, options) { options[:name] = input.sub(options[:concepts_root], "").chomp("/"); [] }
|
39
|
+
# Find all .rb files in one particular concept directory, e.g. as in /concepts/comment/*.rb.
|
40
|
+
ConceptFiles = ->(input, options) { input += Dir.glob("#{options[:concepts_root]}#{options[:name]}/*.rb") }
|
34
41
|
|
42
|
+
private
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
44
|
+
def load_files(files)
|
45
|
+
files.each { |file| yield file }
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- Gemfile
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
|
+
- call_sheet-notes.md
|
68
69
|
- lib/trailblazer-loader.rb
|
69
70
|
- lib/trailblazer/loader.rb
|
70
71
|
- lib/trailblazer/loader/version.rb
|