trailblazer-rails 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +30 -0
- data/Rakefile +10 -0
- data/lib/trailblazer/operation/model/active_model.rb +11 -0
- data/lib/trailblazer/rails.rb +16 -0
- data/lib/trailblazer/rails/railtie.rb +36 -0
- data/lib/trailblazer/rails/version.rb +5 -0
- data/trailblazer-rails.gemspec +26 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c0d4830a30173aac89597b022e250099c73a4df7
|
4
|
+
data.tar.gz: c2c5eaf0fec7595f0ca30a6f7748d86f851b04de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0df8dae649a7f02607399e3f5bd3358edb8a4d7f2d7ad16ee3e6f84d938aac0a7662b993ff44bf81245833b2d8a1731b37d17bce50b8ea5ad27ee395cfcb10a2
|
7
|
+
data.tar.gz: 4e802dc7d231ee6a010ef9f715b42213da99a97c43fc39f073240bbd921104631e9743213e51660f3c5847b705ce26956c9b8a8d93397d1ddeb9947079a10def
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Nick Sutterer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Trailblazer::Rails
|
2
|
+
|
3
|
+
## Railtie
|
4
|
+
|
5
|
+
|
6
|
+
This will go through `app/concepts/`, find all the `crud.rb` files, autoload their corresponding namespace (e.g. `Thing`, which is a model) and then load the `crud.rb` file.
|
7
|
+
|
8
|
+
## Form::model_name
|
9
|
+
|
10
|
+
Automatically sets `model` on operation's contract when `Operation::Model` is included in operation.
|
11
|
+
|
12
|
+
|
13
|
+
## Planned
|
14
|
+
|
15
|
+
* Adds autoloading, etc.
|
16
|
+
* Automatic rendering of a controller cell instead of primitive view.
|
17
|
+
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'trailblazer-rails'
|
25
|
+
```
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Trailblazer
|
2
|
+
module Operation::Model
|
3
|
+
# Automatically set model_name on operation's contract.
|
4
|
+
module ActiveModel
|
5
|
+
def contract(&block)
|
6
|
+
super
|
7
|
+
contract_class.model(model_class) # this assumes that Form::ActiveModel is mixed in.
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "trailblazer/rails/version"
|
2
|
+
|
3
|
+
module Trailblazer
|
4
|
+
module Rails
|
5
|
+
# Your code goes here...
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require "trailblazer/rails/railtie"
|
10
|
+
|
11
|
+
# Automatically set model_name on operation's contract when `Op::Model` is included.
|
12
|
+
require "trailblazer/operation/model"
|
13
|
+
require "trailblazer/operation/model/active_model"
|
14
|
+
Trailblazer::Operation::Model::DSL.module_eval do
|
15
|
+
include Trailblazer::Operation::Model::ActiveModel # ::contract.
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rails/railtie"
|
2
|
+
|
3
|
+
module Trailblazer
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
def self.autoload_operations(app)
|
6
|
+
Dir.glob("app/concepts/**/crud.rb") do |f|
|
7
|
+
path = f.sub("app/concepts/", "")
|
8
|
+
model = path.sub("/crud.rb", "")
|
9
|
+
|
10
|
+
require_dependency "#{app.root}/app/models/#{model}" # load the model file, first (thing.rb).
|
11
|
+
require_dependency "#{app.root}/#{f}" # load app/concepts/{concept}/crud.rb (Thing::Create, Thing::Update, and so on).
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.autoload_cells(app)
|
16
|
+
Dir.glob("app/concepts/**/*cell.rb") do |f|
|
17
|
+
require_dependency "#{app.root}/#{f}" # load app/concepts/{concept}/cell.rb.
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
|
22
|
+
initializer "trailblazer.library_autoloading" do
|
23
|
+
require "trailblazer/autoloading"
|
24
|
+
end
|
25
|
+
|
26
|
+
# thank you, http://stackoverflow.com/a/17573888/465070
|
27
|
+
initializer 'trailblazer.install', after: :load_config_initializers do |app|
|
28
|
+
# the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in
|
29
|
+
# initializers.
|
30
|
+
ActionDispatch::Reloader.to_prepare do
|
31
|
+
Trailblazer::Railtie.autoload_operations(app)
|
32
|
+
Trailblazer::Railtie.autoload_cells(app)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trailblazer/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "trailblazer-rails"
|
8
|
+
spec.version = Trailblazer::Rails::VERSION
|
9
|
+
spec.authors = ["Nick Sutterer"]
|
10
|
+
spec.email = ["apotonick@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Convenient Rails support for Trailblazer.}
|
13
|
+
spec.homepage = "http://trailblazerb.org"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "trailblazer", ">= 1.0.0.rc1"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "rails"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trailblazer-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Sutterer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: trailblazer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0.rc1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0.rc1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- apotonick@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/trailblazer/operation/model/active_model.rb
|
97
|
+
- lib/trailblazer/rails.rb
|
98
|
+
- lib/trailblazer/rails/railtie.rb
|
99
|
+
- lib/trailblazer/rails/version.rb
|
100
|
+
- trailblazer-rails.gemspec
|
101
|
+
homepage: http://trailblazerb.org
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.4.8
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Convenient Rails support for Trailblazer.
|
125
|
+
test_files: []
|
126
|
+
has_rdoc:
|