zertico 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .coveralls.yml
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby
6
+ - ree
7
+ gemfile:
8
+ - gemfiles/Gemfile.rails3.1
9
+ - gemfiles/Gemfile.rails3.2
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Zertico
2
2
 
3
- TODO: Write a gem description
3
+ [![Gem Version](https://badge.fury.io/rb/zertico.png)](http://badge.fury.io/rb/zertico) [![Build Status](https://travis-ci.org/zertico/zertico.png)](https://travis-ci.org/zertico/zertico) [![Dependency Status](https://gemnasium.com/zertico/zertico.png)](https://gemnasium.com/zertico/zertico) [![Coverage Status](https://coveralls.io/repos/zertico/zertico/badge.png?branch=master)](https://coveralls.io/r/zertico/zertico) [![Code Climate](https://codeclimate.com/github/zertico/zertico.png)](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
- TODO: Write usage instructions here
86
+ [@silviolrjunio](https://github.com/silviolrjunior)
22
87
 
23
88
  ## Contributing
24
89
 
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ desc "Default Task"
7
+ task :default => [ :spec ]
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'rails', '3.1'
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'rails', '3.2'
4
+
5
+ gemspec :path => '../'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Zertico
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,4 @@
1
+ module Admin
2
+ class UserController < Zertico::Controller
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ module Admin
2
+ module UserService
3
+ include Zertico::Service
4
+
5
+ def admin_user
6
+ end
7
+ end
8
+ end
@@ -1,7 +1,8 @@
1
1
  require "rspec"
2
+ require "coveralls"
2
3
 
3
- require File.dirname(__FILE__) + "/../lib/zertico"
4
+ Coveralls.wear!
4
5
 
5
- require File.dirname(__FILE__) + "/fake_app/user"
6
- require File.dirname(__FILE__) + "/fake_app/user_controller"
7
- require File.dirname(__FILE__) + "/fake_app/user_service"
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)
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_runtime_dependency "rails"
21
21
  gem.add_development_dependency "rspec"
22
+ gem.add_development_dependency "coveralls"
22
23
  end
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.1.3
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-25 00:00:00.000000000 Z
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: -1214307588938560788
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: -1214307588938560788
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