zertico 0.1.3 → 0.2.0
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.
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/README.md +68 -3
- data/Rakefile +6 -0
- data/gemfiles/Gemfile.rails3.1 +5 -0
- data/gemfiles/Gemfile.rails3.2 +5 -0
- data/lib/zertico/service.rb +2 -2
- data/lib/zertico/version.rb +1 -1
- data/spec/fake_app/admin/user_controller.rb +4 -0
- data/spec/fake_app/admin/user_service.rb +8 -0
- data/spec/spec_helper.rb +5 -4
- data/spec/zertico/service_spec.rb +11 -0
- data/zertico.gemspec +1 -0
- metadata +27 -4
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Zertico
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/zertico) [](https://travis-ci.org/zertico/zertico) [](https://gemnasium.com/zertico/zertico) [](https://coveralls.io/r/zertico/zertico) [](https://codeclimate.com/github/zertico/zertico)
|
4
|
+
|
5
|
+
Easy Rails development using the Zertico Way.
|
6
|
+
Rails is a great framework, but is not a great idea to let your tests depend on any part of it.
|
7
|
+
Zertico let you develop what most important: your business logic. Also, your tests will not depend
|
8
|
+
of rails at all.
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -16,9 +21,69 @@ Or install it yourself as:
|
|
16
21
|
|
17
22
|
$ gem install zertico
|
18
23
|
|
19
|
-
## Usage
|
24
|
+
## Basic Usage
|
25
|
+
|
26
|
+
First, alter your ApplicationController and extend Zertico::Controller
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
class ApplicationController < Zertico::Controller
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
Now, define the routes you need as follow:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
resources :entries
|
37
|
+
```
|
38
|
+
|
39
|
+
And thats all. All the logic is already defined on the controller. Happy coding. =D
|
40
|
+
|
41
|
+
## Advanced Usage
|
42
|
+
|
43
|
+
The Zertico::Controller doesn't cover all cases. For those that are not covered you will have to
|
44
|
+
create a service with the same name of the controller, as follows:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
class UsersController < ApplicationController
|
48
|
+
```
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
module UserService
|
52
|
+
include Zertico::Service
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
Your service must be a module and include Zertico::Service to grant access to all the methods already defined.
|
57
|
+
Then you will have to redefine all the methods you need. Each action of the controller is mapped to a method.
|
58
|
+
The method has to return a hash. The key must be the name of the global variable you want to use on the views.
|
59
|
+
|
60
|
+
## Conventions
|
61
|
+
|
62
|
+
To work with the gem, you will need to follow some conventions. Your model ( called interface here ) need to
|
63
|
+
have the same name of your controller, without the 'Controller' substring. The Service need to replace the
|
64
|
+
'Controller' substring with 'Service' like:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
class UserController < Zertico::Controller
|
68
|
+
end
|
69
|
+
|
70
|
+
module UserService
|
71
|
+
include Zertico::Service
|
72
|
+
end
|
73
|
+
|
74
|
+
class User < ActiveRecord::Base
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
It is good to put the services on a separate folder called services.
|
79
|
+
|
80
|
+
## Mantainers
|
81
|
+
|
82
|
+
[@plribeiro3000](https://github.com/plribeiro3000)
|
83
|
+
|
84
|
+
[@mfbmina](https://github.com/mfbmina)
|
20
85
|
|
21
|
-
|
86
|
+
[@silviolrjunio](https://github.com/silviolrjunior)
|
22
87
|
|
23
88
|
## Contributing
|
24
89
|
|
data/Rakefile
CHANGED
data/lib/zertico/service.rb
CHANGED
@@ -31,11 +31,11 @@ module Zertico
|
|
31
31
|
protected
|
32
32
|
|
33
33
|
def interface_name
|
34
|
-
self.class.name.chomp("Controller").singularize.underscore
|
34
|
+
self.class.name.chomp("Controller").split("::").last.singularize.underscore
|
35
35
|
end
|
36
36
|
|
37
37
|
def interface_class
|
38
38
|
self.interface_name.camelize.constantize
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
data/lib/zertico/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "rspec"
|
2
|
+
require "coveralls"
|
2
3
|
|
3
|
-
|
4
|
+
Coveralls.wear!
|
4
5
|
|
5
|
-
require File.dirname(__FILE__)
|
6
|
-
|
7
|
-
|
6
|
+
require "#{File.dirname(__FILE__)}/../lib/zertico"
|
7
|
+
|
8
|
+
Dir["#{File.dirname(__FILE__)}/fake_app/**/*.rb"].sort.each { |f| require f }
|
@@ -2,8 +2,19 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Zertico::Service do
|
4
4
|
let(:controller) { UserController.new }
|
5
|
+
let(:admin_controller) { Admin::UserController.new }
|
5
6
|
let(:object) { Object.new }
|
6
7
|
|
8
|
+
context "should find the interface class" do
|
9
|
+
it "on a non namespaced controller" do
|
10
|
+
controller.send(:interface_class).should == User
|
11
|
+
end
|
12
|
+
|
13
|
+
it "on a namespaced controller" do
|
14
|
+
admin_controller.send(:interface_class).should == User
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
context "#all" do
|
8
19
|
before :each do
|
9
20
|
controller.stub_chain(:interface_name, :pluralize, :to_sym).and_return(:users)
|
data/zertico.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zertico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: coveralls
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
description: Easy Rails development using the Zertico Way
|
47
63
|
email:
|
48
64
|
- plribeiro3000@gmail.com
|
@@ -54,14 +70,19 @@ files:
|
|
54
70
|
- .rspec
|
55
71
|
- .ruby-gemset
|
56
72
|
- .ruby-version
|
73
|
+
- .travis.yml
|
57
74
|
- Gemfile
|
58
75
|
- LICENSE.txt
|
59
76
|
- README.md
|
60
77
|
- Rakefile
|
78
|
+
- gemfiles/Gemfile.rails3.1
|
79
|
+
- gemfiles/Gemfile.rails3.2
|
61
80
|
- lib/zertico.rb
|
62
81
|
- lib/zertico/controller.rb
|
63
82
|
- lib/zertico/service.rb
|
64
83
|
- lib/zertico/version.rb
|
84
|
+
- spec/fake_app/admin/user_controller.rb
|
85
|
+
- spec/fake_app/admin/user_service.rb
|
65
86
|
- spec/fake_app/user.rb
|
66
87
|
- spec/fake_app/user_controller.rb
|
67
88
|
- spec/fake_app/user_service.rb
|
@@ -83,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
104
|
version: '0'
|
84
105
|
segments:
|
85
106
|
- 0
|
86
|
-
hash: -
|
107
|
+
hash: -3374581575376530341
|
87
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
109
|
none: false
|
89
110
|
requirements:
|
@@ -92,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
113
|
version: '0'
|
93
114
|
segments:
|
94
115
|
- 0
|
95
|
-
hash: -
|
116
|
+
hash: -3374581575376530341
|
96
117
|
requirements: []
|
97
118
|
rubyforge_project:
|
98
119
|
rubygems_version: 1.8.25
|
@@ -100,6 +121,8 @@ signing_key:
|
|
100
121
|
specification_version: 3
|
101
122
|
summary: Models and patterns used by Zertico
|
102
123
|
test_files:
|
124
|
+
- spec/fake_app/admin/user_controller.rb
|
125
|
+
- spec/fake_app/admin/user_service.rb
|
103
126
|
- spec/fake_app/user.rb
|
104
127
|
- spec/fake_app/user_controller.rb
|
105
128
|
- spec/fake_app/user_service.rb
|