codeigniter_vender 0.0.5 → 0.0.6
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/VERSION +1 -1
- data/codeigniter_vender.gemspec +4 -4
- data/lib/generators/ci/install/install_generator.rb +9 -0
- data/lib/generators/ci/model/model_generator.rb +30 -8
- data/lib/generators/ci/model/templates/migration.rb.erb +16 -0
- data/lib/generators/ci/model/templates/model.php +3 -8
- data/lib/generators/ci/model/templates/{model.rb → model.rb.erb} +0 -0
- metadata +5 -5
- data/lib/generators/ci/model/templates/model_migration.rb.erb +0 -16
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/codeigniter_vender.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{codeigniter_vender}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["qichunren"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-25}
|
13
13
|
s.description = %q{CodeigniterVender is a Ruby gem for php coder who love CodeIgniter.This is for rubyist who also love php.}
|
14
14
|
s.email = %q{whyruby@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -369,9 +369,9 @@ Gem::Specification.new do |s|
|
|
369
369
|
"lib/generators/ci/layout/templates/application_layout.php",
|
370
370
|
"lib/generators/ci/model/USAGE",
|
371
371
|
"lib/generators/ci/model/model_generator.rb",
|
372
|
+
"lib/generators/ci/model/templates/migration.rb.erb",
|
372
373
|
"lib/generators/ci/model/templates/model.php",
|
373
|
-
"lib/generators/ci/model/templates/model.rb",
|
374
|
-
"lib/generators/ci/model/templates/model_migration.rb.erb",
|
374
|
+
"lib/generators/ci/model/templates/model.rb.erb",
|
375
375
|
"lib/generators/ci/named_base.rb",
|
376
376
|
"spec/spec_helper.rb",
|
377
377
|
"uninstall.rb"
|
@@ -28,6 +28,15 @@ module Ci
|
|
28
28
|
create_file "config/codeigniter.yml" do
|
29
29
|
"version: #{options.version}\npath: public/#{@subdir}"
|
30
30
|
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_resources_dir_and_files
|
34
|
+
say_status("Generate assets directory for resources", "", :green)
|
35
|
+
empty_directory "public/#{@subdir}/assets"
|
36
|
+
empty_directory "public/#{@subdir}/assets/images"
|
37
|
+
empty_directory "public/#{@subdir}/assets/javascripts"
|
38
|
+
empty_directory "public/#{@subdir}/assets/stylesheets"
|
39
|
+
empty_directory "public/#{@subdir}/assets/uploads"
|
31
40
|
end
|
32
41
|
|
33
42
|
def set_db_config
|
@@ -1,25 +1,47 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rails/generators/active_record'
|
2
3
|
|
3
4
|
module Ci
|
4
5
|
module Generators
|
5
6
|
|
6
|
-
class ModelGenerator <
|
7
|
+
class ModelGenerator < ActiveRecord::Generators::Base
|
8
|
+
desc "Create a codeIgniter model."
|
9
|
+
|
10
|
+
|
7
11
|
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
8
|
-
class_option :
|
12
|
+
class_option :skip_migration, :type => :boolean, :default => false
|
9
13
|
|
10
|
-
|
14
|
+
def self.source_root
|
15
|
+
@source_root ||= File.expand_path('../templates', __FILE__)
|
16
|
+
end
|
11
17
|
|
18
|
+
|
19
|
+
def generate_migration
|
20
|
+
migration_template "migration.rb.erb", "db/migrate/#{migration_file_name}" unless options.skip_migration?
|
21
|
+
end
|
22
|
+
|
12
23
|
def create_ci_model
|
13
24
|
template "model.php", "#{ci_root}/application/models/#{file_name}_model.php"
|
14
25
|
end
|
15
26
|
|
16
27
|
def create_rails_model
|
17
|
-
|
28
|
+
template "model.rb.erb", "app/models/#{file_name}.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def migration_file_name
|
34
|
+
"create_#{table_name}.rb"
|
18
35
|
end
|
36
|
+
|
37
|
+
def migration_class_name
|
38
|
+
"create_#{table_name}".camelize
|
39
|
+
end
|
19
40
|
|
20
|
-
def
|
21
|
-
|
22
|
-
end
|
41
|
+
def ci_root
|
42
|
+
@ci_root ||= YAML.load_file("config/codeigniter.yml")["path"]
|
43
|
+
end
|
44
|
+
|
23
45
|
|
24
46
|
end
|
25
47
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class <%= migration_class_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= table_name %> do |t|
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<% end -%>
|
7
|
+
<% if options[:timestamps] %>
|
8
|
+
t.timestamps
|
9
|
+
<% end -%>
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :<%= table_name %>
|
15
|
+
end
|
16
|
+
end
|
@@ -7,16 +7,11 @@ class <%= class_name %>_model extends CI_Model {
|
|
7
7
|
function __construct(){
|
8
8
|
parent::__construct();
|
9
9
|
// Write your own initialize code
|
10
|
-
}
|
10
|
+
}
|
11
11
|
|
12
|
-
function get($limit){
|
13
|
-
$query = $this->db->get("<%= table_name %>", $limit);
|
14
|
-
return $query->result();
|
15
|
-
}
|
16
|
-
|
17
|
-
function get($per_page, $offset){
|
12
|
+
function get($limit, $offset = 0){
|
18
13
|
$query = $this->db->get("<%= table_name %>", $limit, $offset);
|
19
|
-
return $query->result();
|
14
|
+
return $query->result();
|
20
15
|
}
|
21
16
|
|
22
17
|
|
File without changes
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- qichunren
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-25 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -380,9 +380,9 @@ files:
|
|
380
380
|
- lib/generators/ci/layout/templates/application_layout.php
|
381
381
|
- lib/generators/ci/model/USAGE
|
382
382
|
- lib/generators/ci/model/model_generator.rb
|
383
|
+
- lib/generators/ci/model/templates/migration.rb.erb
|
383
384
|
- lib/generators/ci/model/templates/model.php
|
384
|
-
- lib/generators/ci/model/templates/model.rb
|
385
|
-
- lib/generators/ci/model/templates/model_migration.rb.erb
|
385
|
+
- lib/generators/ci/model/templates/model.rb.erb
|
386
386
|
- lib/generators/ci/named_base.rb
|
387
387
|
- spec/spec_helper.rb
|
388
388
|
- uninstall.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :<%= table_name -%> do |t|
|
4
|
-
<% for attribute in attributes -%>
|
5
|
-
t.<%= attribute.type -%> :<%= attribute.name -%>
|
6
|
-
<% end -%>
|
7
|
-
<% unless options[:skip_timestamps] -%>
|
8
|
-
t.timestamps
|
9
|
-
<% end -%>
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.down
|
14
|
-
drop_table :<%= table_name -%>
|
15
|
-
end
|
16
|
-
end
|