activetrail 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/README.md +29 -5
- data/Rakefile +4 -0
- data/activetrail.gemspec +7 -2
- data/config.ru +8 -0
- data/gemfiles/rails4_2.gemfile +6 -0
- data/lib/active_trail.rb +1 -1
- data/lib/active_trail/controller.rb +81 -0
- data/lib/active_trail/version.rb +1 -1
- metadata +80 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25058789a37a673f937a832820bd19ecd6d1743a
|
4
|
+
data.tar.gz: b2c2759331232f67607a82fe217c2050dcc24538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 585998f17594b47c9d69ca711f061e0585669acea9c1193ec0455e1f0c97797ccf39eda8b21acd7983aea724a5d43e274eaa263586cf3e3dce4845cb4fed5329
|
7
|
+
data.tar.gz: 261cabf1f7d542734669154989e2c2ac451345957eca4ab57a54594ad1b186f06a199f0323db5ac0f0ff267293d7bb26d81b9e2a88df17ad2911fa8e99eb5bc4
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in activetrail.gemspec
|
4
|
+
gem 'activeadmin', github: 'activeadmin'
|
5
|
+
# Using fernandes' branch till some PRs got merged into trb upstream
|
6
|
+
gem 'trailblazer', github: 'fernandes/trailblazer', branch: 'master'
|
4
7
|
gemspec
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# ActiveTrail
|
2
|
+
[![Build Status](https://travis-ci.org/fernandes/activetrail.svg?branch=master)](https://travis-ci.org/fernandes/activetrail)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/fernandes/activetrail/badges/gpa.svg)](https://codeclimate.com/github/fernandes/activetrail)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/fernandes/activetrail/badges/coverage.svg)](https://codeclimate.com/github/fernandes/activetrail)
|
2
5
|
|
3
6
|
Provides integration between ActiveAdmin and Trailblazer, cool hun?!
|
4
7
|
|
@@ -20,18 +23,39 @@ Or install it yourself as:
|
|
20
23
|
|
21
24
|
## Usage
|
22
25
|
|
23
|
-
|
26
|
+
In your `app/admin/book.rb` you need to customize your controller to make ActiveAdmin use Trailblazer, and ActiveTrail provides an easy way to make this integration happen! Just edit your resource like this:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
ActiveAdmin.register Book do
|
30
|
+
# everything happens here :D
|
31
|
+
controller do
|
32
|
+
include ActiveTrail::Controller
|
33
|
+
end
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
You need to implement Book::(__Create|Update|Index|Show__) in your operation so everything works fine. If you need an example, check ActiveTrail's [Book Operation](https://github.com/fernandes/activetrail/blob/7a5adf4241ff2299dcf4be2336765723a27a488a/spec/internal/app/models/book.rb) used on its test suite
|
38
|
+
|
39
|
+
## Known Issues
|
40
|
+
|
41
|
+
1. Just works with single Models. (Maybe works, maybe not with releationship, but we still do not support).
|
42
|
+
2. Do not support batch operations.
|
24
43
|
|
25
44
|
## Development
|
26
45
|
|
27
46
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
47
|
|
29
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
49
|
+
|
50
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
51
|
+
|
30
52
|
|
31
53
|
## Contributing
|
32
54
|
|
33
|
-
1. Fork it ( https://github.com/
|
34
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
1. Fork it ( https://github.com/fernandes/activetrail/fork )
|
56
|
+
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
35
57
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
4. Push to the branch (`git push origin feature/my-new-feature`)
|
37
59
|
5. Create a new Pull Request
|
60
|
+
|
61
|
+
Always test against ActiveAdmin and Trailblazer latest release and master branch.
|
data/Rakefile
CHANGED
data/activetrail.gemspec
CHANGED
@@ -19,7 +19,12 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "
|
22
|
+
spec.add_development_dependency "codeclimate-test-reporter", '~> 0.4'
|
23
|
+
spec.add_development_dependency "combustion", "~> 0.5.3"
|
24
|
+
spec.add_development_dependency "database_cleaner", "~> 1.4"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.
|
27
|
+
spec.add_development_dependency "rspec-rails", "~> 3.0"
|
28
|
+
spec.add_development_dependency "sqlite3", "~> 1.3"
|
29
|
+
spec.add_development_dependency "trailblazer", "~> 0.2"
|
25
30
|
end
|
data/config.ru
ADDED
data/lib/active_trail.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
module ActiveTrail
|
2
|
+
module Controller
|
3
|
+
def self.included(base)
|
4
|
+
if base.instance_methods.include?(:collection)
|
5
|
+
Trailblazer::Operation::Controller.instance_eval do
|
6
|
+
# As activeadmin has a collection controller method we remove it
|
7
|
+
# so we don't override original method and use `trb_collection`
|
8
|
+
alias_method :trb_collection, :collection
|
9
|
+
remove_method :collection
|
10
|
+
end
|
11
|
+
base.include Trailblazer::Operation::Controller
|
12
|
+
end
|
13
|
+
require 'trailblazer/operation/controller/active_record'
|
14
|
+
base.include Trailblazer::Operation::Controller::ActiveRecord # named instance variables.
|
15
|
+
end
|
16
|
+
|
17
|
+
def scoped_collection
|
18
|
+
trb_collection "#{trailblazer_operation_name}::Index".constantize do |op|
|
19
|
+
return @collection
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_collection
|
24
|
+
trb_collection "#{trailblazer_operation_name}::Index".constantize do |op|
|
25
|
+
return @collection
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_resource
|
30
|
+
if params.has_key?(:id)
|
31
|
+
run "#{trailblazer_operation_name}::Show".constantize do |op|
|
32
|
+
return op.model
|
33
|
+
end
|
34
|
+
else
|
35
|
+
form "#{trailblazer_operation_name}::Create".constantize do |op|
|
36
|
+
return op.contract
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_new_resource
|
42
|
+
if params[:action] == 'create'
|
43
|
+
run "#{trailblazer_operation_name}::Create".constantize do |op|
|
44
|
+
return op.model
|
45
|
+
end.else do |op|
|
46
|
+
return op.contract
|
47
|
+
end
|
48
|
+
else
|
49
|
+
form "#{trailblazer_operation_name}::Create".constantize do |op|
|
50
|
+
return @contract
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_resource(object)
|
56
|
+
run_create_callbacks object do
|
57
|
+
return object
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def update(options={}, &block)
|
62
|
+
object = resource
|
63
|
+
run "#{trailblazer_operation_name}::Update".constantize do |op|
|
64
|
+
options[:location] ||= smart_resource_url
|
65
|
+
respond_with(op.model, options)
|
66
|
+
end.else do |op|
|
67
|
+
instance_variable_set("@#{trailblazer_model_name}".to_sym, op.contract)
|
68
|
+
respond_with(op, options)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
def trailblazer_operation_name
|
74
|
+
resource_class.to_s
|
75
|
+
end
|
76
|
+
|
77
|
+
def trailblazer_model_name
|
78
|
+
resource_class.model_name.element
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/active_trail/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activetrail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Celso Fernandes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: codeclimate-test-reporter
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: combustion
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: database_cleaner
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: bundler
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
16
58
|
requirements:
|
17
59
|
- - "~>"
|
18
60
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
61
|
+
version: '1.7'
|
20
62
|
type: :development
|
21
63
|
prerelease: false
|
22
64
|
version_requirements: !ruby/object:Gem::Requirement
|
23
65
|
requirements:
|
24
66
|
- - "~>"
|
25
67
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
68
|
+
version: '1.7'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: rake
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +81,47 @@ dependencies:
|
|
39
81
|
- !ruby/object:Gem::Version
|
40
82
|
version: '10.0'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: trailblazer
|
43
113
|
requirement: !ruby/object:Gem::Requirement
|
44
114
|
requirements:
|
45
115
|
- - "~>"
|
46
116
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
117
|
+
version: '0.2'
|
48
118
|
type: :development
|
49
119
|
prerelease: false
|
50
120
|
version_requirements: !ruby/object:Gem::Requirement
|
51
121
|
requirements:
|
52
122
|
- - "~>"
|
53
123
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
124
|
+
version: '0.2'
|
55
125
|
description: Provide a cool, and seamless, integration between ActiveAdmin and Trailblazer,
|
56
126
|
so you can you your operations inside ActiveAdmin
|
57
127
|
email:
|
@@ -70,7 +140,10 @@ files:
|
|
70
140
|
- activetrail.gemspec
|
71
141
|
- bin/console
|
72
142
|
- bin/setup
|
143
|
+
- config.ru
|
144
|
+
- gemfiles/rails4_2.gemfile
|
73
145
|
- lib/active_trail.rb
|
146
|
+
- lib/active_trail/controller.rb
|
74
147
|
- lib/active_trail/version.rb
|
75
148
|
- lib/activetrail.rb
|
76
149
|
homepage: https://github.com/fernandes/activetrail
|