trailblazer-loader 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 18a5ed1bc354d6f61c381c4526eedda3c29004e6
4
+ data.tar.gz: 2f6983c10777f74d8a9db79a96408110a924f91b
5
+ SHA512:
6
+ metadata.gz: fc7fd466bfe948e912e790c1b3a8e90816b35130a5150c78bd7f6808289bfa77e2333352f7256a98a698445adf9704868c3ce2415fdbef0548220197e306378d
7
+ data.tar.gz: 0be790b9775f054e80c617002d23cf915d2247a322ac732d2e5fc1871dd409e08ef9d0be31ca64c8d6d84bcb7aaffccee53a313dc8a59cb77c6e4f03e1d24cd3
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,3 @@
1
+ # 0.0.1
2
+
3
+ * Obviously, the first version ever. This implements the "lexical-width" strategy, only.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trailblazer-loader.gemspec
4
+ gemspec
@@ -0,0 +1,89 @@
1
+ # Trailblazer::Loader
2
+
3
+ ## Experimental!
4
+
5
+ Note that this is not the finalized version of `trailblazer-loader`. We still need more input from you.
6
+
7
+ Expect many minor version bumps.
8
+
9
+ ## Loading order
10
+
11
+ Per concept. Lexically sorted. Then, sorted by depths, as follows.
12
+
13
+ ```
14
+ app/concepts/blog/operation.rb
15
+ app/concepts/comment/operation.rb
16
+ app/concepts/post/operation.rb
17
+ app/concepts/api/v1/comment/operation.rb
18
+ app/concepts/api/v1/post/operation.rb
19
+ ```
20
+
21
+ 1. Model. The model does not have dependencies to other layers. If it does, you're doing it wrong.
22
+ 2. Policy
23
+ 3. Representer
24
+ 4. Form
25
+ 5. Callbacks, etc.
26
+ 6. Operation. As an orchestrating object, this needs to be loaded last. It is very common for operations to reference form classes, etc. on the class level.
27
+ first create.rb
28
+ then operations.rb {configurable, could also be crud.rb}
29
+
30
+ ## Installation
31
+
32
+ Add this line to your application's Gemfile:
33
+
34
+ ```ruby
35
+ gem 'trailblazer-loader'
36
+ ```
37
+
38
+ ## API
39
+
40
+ ```ruby
41
+ Trailblazer::Loader.new.(Rails.app.root) { |file| require_dependency(file) }
42
+ ```
43
+
44
+
45
+ ## File Layout
46
+
47
+ ```
48
+ app
49
+ ├── concepts
50
+ │ ├── comment
51
+ │ │ ├── cell.rb [optional]
52
+ │ │ ├── contract.rb [optional]
53
+ │ │ ├── operation.rb
54
+ │ │ ├── policy.rb [optional]
55
+ │ │ ├── representer.rb [optional]
56
+ │ │ ├── views
57
+ │ │ │ ├── show.haml
58
+ │ │ │ ├── list.haml
59
+ │ │ │ ├── comment.css.sass
60
+ ```
61
+
62
+ ### Alternative "explicit" layout
63
+
64
+ This works for cell, contract, operation, policy, representer and twin.
65
+
66
+ ```
67
+ app
68
+ ├── concepts
69
+ │ ├── comment
70
+ │ │ ├── operation
71
+ │ │ │ ├── create.rb
72
+ │ │ │ ├── update.rb
73
+ ```
74
+
75
+ ### Nested
76
+
77
+ ```
78
+ app
79
+ ├── concepts
80
+ │ ├── comment
81
+ │ │ ├── cell
82
+ │ │ │ ├── single
83
+ │ │ │ │ ├── homepage.rb
84
+ │ │ │ │ ├── search.rb
85
+ │ │ │ │ ├── views
86
+ │ │ │ │ │ ├── homepage.haml
87
+ │ │ │ │ │ ├── search.haml
88
+ │ │ │ ├── collection
89
+ ```
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1 @@
1
+ require "trailblazer/loader"
@@ -0,0 +1,41 @@
1
+ require "trailblazer/loader/version"
2
+
3
+ module Trailblazer
4
+ class Loader
5
+ # Please note that this is subject to change - we're still finding out the best way
6
+ # to explicitly load files.
7
+ def call(app_root)
8
+ operations = Dir.glob("app/concepts/**/operation.rb").sort { |a, b| a.split("/").size <=> b.split("/").size }
9
+ # lame heuristic, but works for me: sort by nested levels.
10
+ # app/concepts/comment
11
+ # app/concepts/api/v1/comment
12
+
13
+
14
+
15
+ operations.each do |f|
16
+ path = f.sub("app/concepts/", "")
17
+ model = path.sub("/operation.rb", "")
18
+
19
+ concept = model # comment, api/v1/comment, ...
20
+
21
+ puts "digging through #{concept}"
22
+
23
+ puts "@@@@@---> #{app_root}/app/models/#{model}" unless File.exist?("#{app_root}/app/models/#{model}.rb")
24
+
25
+ # app/models/ # FIXME: where's the namespace here?
26
+ yield "#{app_root}/app/models/#{model}" if File.exist?("#{app_root}/app/models/#{model}.rb") # load the model file, first (thing.rb).
27
+
28
+
29
+ [:contract, :representer, :callback, :cell, :policy].each do |asset|
30
+ file = "#{app_root}/app/concepts/#{concept}/#{asset}"
31
+ puts "loading extension... #{file.inspect}"
32
+ yield file if File.exist?("#{file}.rb") # load the model file, first (thing.rb).
33
+ end
34
+
35
+
36
+ # concepts/:namespace/operation.rb
37
+ yield "#{app_root}/#{f}" # load app/concepts/{concept}/crud.rb (Thing::Create, Thing::Update, and so on).
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Trailblazer
2
+ class Loader
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trailblazer/loader/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trailblazer-loader"
8
+ spec.version = Trailblazer::Loader::VERSION
9
+ spec.authors = ["Nick Sutterer"]
10
+ spec.email = ["apotonick@gmail.com"]
11
+
12
+ spec.summary = %q{bla}
13
+ spec.description = %q{TOD: Write a longer description or delete this line.}
14
+ spec.homepage = "http://trailblazer.to/"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trailblazer-loader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Sutterer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: 'TOD: Write a longer description or delete this line.'
56
+ email:
57
+ - apotonick@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - CHANGES.md
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - lib/trailblazer-loader.rb
69
+ - lib/trailblazer/loader.rb
70
+ - lib/trailblazer/loader/version.rb
71
+ - trailblazer-loader.gemspec
72
+ homepage: http://trailblazer.to/
73
+ licenses: []
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.8
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: bla
95
+ test_files: []