apit 0.0.34
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 +3 -0
- data/Gemfile +5 -0
- data/Rakefile +2 -0
- data/apit.gemspec +21 -0
- data/avo-setup.gemspec +21 -0
- data/lib/.DS_Store +0 -0
- data/lib/apit/.DS_Store +0 -0
- data/lib/apit/version.rb +3 -0
- data/lib/apit.rb +5 -0
- data/lib/generators/apit/USAGE +8 -0
- data/lib/generators/apit/layout_generator.rb +20 -0
- data/lib/generators/apit/setup_generator.rb +63 -0
- data/lib/generators/apit/templates/ability.rb +11 -0
- data/lib/generators/apit/templates/create_roles_migration.rb +28 -0
- data/lib/generators/apit/templates/layout.html.erb +19 -0
- data/lib/generators/apit/templates/role.rb +3 -0
- data/lib/generators/apit/templates/stylesheet.css +1 -0
- data/lib/generators/apit/templates/user.rb +39 -0
- data/lib/generators/apit/templates/user_token.rb +3 -0
- metadata +83 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/apit.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "apit/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "apit"
|
7
|
+
s.version = Apit::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Avocado"]
|
10
|
+
s.email = ["mail@avocado.nl"]
|
11
|
+
s.homepage = "http://www.avocado.nl"
|
12
|
+
s.summary = %q{Apit framework}
|
13
|
+
s.description = %q{Set up the apit framework for your rails project}
|
14
|
+
|
15
|
+
s.rubyforge_project = "apit"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/avo-setup.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "avo-setup/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "avo-setup"
|
7
|
+
s.version = Avo::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Avocado"]
|
10
|
+
s.email = ["mail@avocado.nl"]
|
11
|
+
s.homepage = "http://www.avocado.nl"
|
12
|
+
s.summary = %q{Avo-setup generator}
|
13
|
+
s.description = %q{Set up an Avocado Enviromnment to start a new rails project}
|
14
|
+
|
15
|
+
s.rubyforge_project = "avo-setup"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/apit/.DS_Store
ADDED
Binary file
|
data/lib/apit/version.rb
ADDED
data/lib/apit.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Apit
|
2
|
+
module Generators
|
3
|
+
class LayoutGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
argument :layout_name, :type => :string, :default => "application"
|
6
|
+
class_option :stylesheet, :type => :boolean, :default => true, :desc => "Include stylesheet file."
|
7
|
+
|
8
|
+
def generate_layout
|
9
|
+
copy_file "stylesheet.css", "public/stylesheets/#{file_name}.css" if options.stylesheet?
|
10
|
+
template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def file_name
|
16
|
+
layout_name.underscore
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Apit
|
2
|
+
module Generators
|
3
|
+
class SetupGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
def setup
|
8
|
+
if yes?("Would you like to generate a layout?")
|
9
|
+
generate("apit:layout")
|
10
|
+
end
|
11
|
+
if yes?("Would you like to use simple-form for form generation?")
|
12
|
+
gem("simple_form")
|
13
|
+
end
|
14
|
+
#Devise
|
15
|
+
if yes?("Would you like to use Devise for authentication?")
|
16
|
+
gem("devise", :git => 'git://github.com/plataformatec/devise', :branch => 'master')
|
17
|
+
run('bundle install')
|
18
|
+
generate("devise:install")
|
19
|
+
template "user_token.rb", "app/models/user_token.rb"
|
20
|
+
template "user.rb", "app/models/user.rb"
|
21
|
+
|
22
|
+
model_name = "user" if model_name.blank?
|
23
|
+
generate("devise", model_name)
|
24
|
+
generate("devise:views")
|
25
|
+
|
26
|
+
|
27
|
+
#CanCan
|
28
|
+
if yes?("Would you like to use CanCan for authorization?")
|
29
|
+
gem("cancan")
|
30
|
+
copy_file "ability.rb", "models/ability.rb"
|
31
|
+
@single=model_name
|
32
|
+
#insert_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
|
33
|
+
inject_into_class "app/models/user.rb", model_name.camelcase, "has_and_belongs_to_many :roles\n"
|
34
|
+
|
35
|
+
|
36
|
+
template "role.rb", "app/models/role.rb"
|
37
|
+
|
38
|
+
|
39
|
+
migration_template 'create_roles_migration.rb', "db/migrate/create_roles.rb"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def file_name
|
48
|
+
layout_name.underscore
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.next_migration_number(dirname)
|
52
|
+
if ActiveRecord::Base.timestamped_migrations
|
53
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
54
|
+
else
|
55
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateRolesMigration < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :roles, :force => true do |t|
|
4
|
+
t.string :title
|
5
|
+
t.timestamps
|
6
|
+
end
|
7
|
+
|
8
|
+
create_table :user_tokens, :force => true do |t|
|
9
|
+
t.string :provider
|
10
|
+
t.string :uid
|
11
|
+
t.integer :user_id
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
create_table :roles_users, :force => true do |t|
|
15
|
+
t.integer :user_id
|
16
|
+
t.integer :role_id
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.down
|
24
|
+
drop_table :user_tokens
|
25
|
+
drop_table :roles_users
|
26
|
+
drop_table :roles
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
|
5
|
+
<%%= stylesheet_link_tag "<%= file_name %>" %>
|
6
|
+
<%%= javascript_include_tag :defaults %>
|
7
|
+
<%%= csrf_meta_tag %>
|
8
|
+
<%%= yield(:head) %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<%% flash.each do |name, msg| %>
|
13
|
+
<%%= content_tag :div, msg, :id => "flash_#{name}" %>
|
14
|
+
<%% end %>
|
15
|
+
<%%= content_tag :h1, yield(:title) if show_title? %>
|
16
|
+
<%%= yield %>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
test
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
has_many :user_tokens
|
3
|
+
# Include default devise modules. Others available are:
|
4
|
+
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
5
|
+
devise :database_authenticatable, :registerable,
|
6
|
+
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
|
7
|
+
|
8
|
+
# Setup accessible (or protected) attributes for your model
|
9
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me
|
10
|
+
|
11
|
+
def self.new_with_session(params, session)
|
12
|
+
super.tap do |user|
|
13
|
+
if data = session[:omniauth]
|
14
|
+
user.user_tokens.build(:provider => data['provider'], :uid => data['uid'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def apply_omniauth(omniauth)
|
20
|
+
#add some info about the user
|
21
|
+
#self.name = omniauth['user_info']['name'] if name.blank?
|
22
|
+
#self.nickname = omniauth['user_info']['nickname'] if nickname.blank?
|
23
|
+
|
24
|
+
unless omniauth['credentials'].blank?
|
25
|
+
user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
|
26
|
+
#user_tokens.build(:provider => omniauth['provider'],
|
27
|
+
# :uid => omniauth['uid'],
|
28
|
+
# :token => omniauth['credentials']['token'],
|
29
|
+
# :secret => omniauth['credentials']['secret'])
|
30
|
+
else
|
31
|
+
user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
|
32
|
+
end
|
33
|
+
#self.confirm!# unless user.email.blank?
|
34
|
+
end
|
35
|
+
|
36
|
+
def password_required?
|
37
|
+
(user_tokens.empty? || !password.blank?) && super
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 34
|
9
|
+
version: 0.0.34
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Avocado
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-30 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Set up the apit framework for your rails project
|
22
|
+
email:
|
23
|
+
- mail@avocado.nl
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- Rakefile
|
34
|
+
- apit.gemspec
|
35
|
+
- avo-setup.gemspec
|
36
|
+
- lib/.DS_Store
|
37
|
+
- lib/apit.rb
|
38
|
+
- lib/apit/.DS_Store
|
39
|
+
- lib/apit/version.rb
|
40
|
+
- lib/generators/apit/USAGE
|
41
|
+
- lib/generators/apit/layout_generator.rb
|
42
|
+
- lib/generators/apit/setup_generator.rb
|
43
|
+
- lib/generators/apit/templates/ability.rb
|
44
|
+
- lib/generators/apit/templates/create_roles_migration.rb
|
45
|
+
- lib/generators/apit/templates/layout.html.erb
|
46
|
+
- lib/generators/apit/templates/role.rb
|
47
|
+
- lib/generators/apit/templates/stylesheet.css
|
48
|
+
- lib/generators/apit/templates/user.rb
|
49
|
+
- lib/generators/apit/templates/user_token.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://www.avocado.nl
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: apit
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Apit framework
|
82
|
+
test_files: []
|
83
|
+
|