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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3744424b54f954240aaa62309073e1c3b1b199d
4
- data.tar.gz: 7fe8fc18700ad36f47bd3489f34250600d4602a2
3
+ metadata.gz: 25058789a37a673f937a832820bd19ecd6d1743a
4
+ data.tar.gz: b2c2759331232f67607a82fe217c2050dcc24538
5
5
  SHA512:
6
- metadata.gz: 43cbcb4cd5a1d24144243c334e94525b955c7bda1b9e632161a59f44262d144985589aac97d46ce21145d93f58b3110a5398fd39f3d6bd7f99d696566bb6afe1
7
- data.tar.gz: 72633af064166cc450d98c71501549e2c7f925b87c111ea895bf7f6d04a22d399dc55421485d16d1f846112693e288aadd4ea0526d70196683b1336d4d242909
6
+ metadata.gz: 585998f17594b47c9d69ca711f061e0585669acea9c1193ec0455e1f0c97797ccf39eda8b21acd7983aea724a5d43e274eaa263586cf3e3dce4845cb4fed5329
7
+ data.tar.gz: 261cabf1f7d542734669154989e2c2ac451345957eca4ab57a54594ad1b186f06a199f0323db5ac0f0ff267293d7bb26d81b9e2a88df17ad2911fa8e99eb5bc4
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /vendor/cache
11
11
  /vendor/bundle
12
+ /spec/internal/db/*.sqlite
@@ -1,3 +1,8 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ bundler_args: --without production
4
+ gemfile:
5
+ - gemfiles/rails4_2.gemfile
2
6
  rvm:
3
7
  - 2.2.0
8
+ env: CODECLIMATE_REPO_TOKEN=ae1bcbe525ec96db3dc63561ba41749adf03973e618c4cab16556e4e8c7adab6
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
- TODO: Write usage instructions here
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`. 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).
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/[my-github-username]/activetrail/fork )
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
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ task :default => [:spec]
4
+
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
@@ -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 "bundler", "~> 1.8"
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.2"
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
@@ -0,0 +1,8 @@
1
+ # Combustion stuff
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ require 'combustion'
6
+
7
+ Combustion.initialize! :all
8
+ run Combustion::Application
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+ gem 'rails', '~> 4.2.0'
5
+ gem 'activeadmin', github: 'activeadmin'
6
+ gem 'trailblazer', github: 'fernandes/trailblazer', branch: 'master'
@@ -1,5 +1,5 @@
1
1
  require "active_trail/version"
2
+ require "active_trail/controller"
2
3
 
3
4
  module ActiveTrail
4
- # Your code goes here...
5
5
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ActiveTrail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
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.1
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-22 00:00:00.000000000 Z
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.8'
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.8'
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: '3.2'
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: '3.2'
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