tida_sina_weibo 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/Gemfile +2 -0
- data/lib/.DS_Store +0 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/active_record/templates/migration.rb +15 -0
- data/lib/generators/active_record/templates/migration_existing.rb +22 -0
- data/lib/generators/active_record/tida_sina_weibo_generator.rb +23 -0
- data/lib/generators/tida_sina_weibo/.DS_Store +0 -0
- data/lib/generators/tida_sina_weibo/install_generator.rb +8 -0
- data/lib/generators/tida_sina_weibo/orm_helpers.rb +28 -0
- data/lib/tida_sina_weibo/version.rb +1 -1
- metadata +11 -2
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
CHANGED
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class TidaSinaWeiboCreate<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table(:<%= table_name %>) do |t|
|
4
|
+
<%= migration_data -%>
|
5
|
+
|
6
|
+
<% attributes.each do |attribute| -%>
|
7
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :<%= table_name %>, :name, :unique => true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class AddTidaSinaWeiboTo<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
change_table(:<%= table_name %>) do |t|
|
4
|
+
<%= migration_data -%>
|
5
|
+
|
6
|
+
<% attributes.each do |attribute| -%>
|
7
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
# Uncomment below if timestamps were not included in your original model.
|
11
|
+
# t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :<%= table_name %>, :email, :unique => true
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
# By default, we don't want to make any assumption about how to roll back a migration when your
|
19
|
+
# model already existed. Please edit below which fields you would like to remove in this migration.
|
20
|
+
raise ActiveRecord::IrreversibleMigration
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
require 'generators/tida_sina_weibo/orm_helpers'
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
module Generators
|
6
|
+
class TidaSinaWeiboGenerator < ActiveRecord::Generators::Base
|
7
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
8
|
+
|
9
|
+
include TidaSinaWeibo::Generators::OrmHelpers
|
10
|
+
source_root File.expand_path("../templates", __FILE__)
|
11
|
+
|
12
|
+
def copy_devise_migration
|
13
|
+
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
|
14
|
+
migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}"
|
15
|
+
else
|
16
|
+
migration_template "migration.rb", "db/migrate/devise_create_#{table_name}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TidaSinaWeibo
|
2
|
+
module Generators
|
3
|
+
module OrmHelpers
|
4
|
+
def model_contents
|
5
|
+
<<-CONTENT
|
6
|
+
|
7
|
+
|
8
|
+
CONTENT
|
9
|
+
end
|
10
|
+
|
11
|
+
def model_exists?
|
12
|
+
File.exists?(File.join(destination_root, model_path))
|
13
|
+
end
|
14
|
+
|
15
|
+
def migration_exists?(table_name)
|
16
|
+
Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_tida_sina_weibo_to_#{table_name}.rb$/).first
|
17
|
+
end
|
18
|
+
|
19
|
+
def migration_path
|
20
|
+
@migration_path ||= File.join("db", "migrate")
|
21
|
+
end
|
22
|
+
|
23
|
+
def model_path
|
24
|
+
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tida_sina_weibo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-01-
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -66,11 +66,20 @@ executables: []
|
|
66
66
|
extensions: []
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
|
+
- .DS_Store
|
69
70
|
- .gitignore
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE.txt
|
72
73
|
- README.md
|
73
74
|
- Rakefile
|
75
|
+
- lib/.DS_Store
|
76
|
+
- lib/generators/.DS_Store
|
77
|
+
- lib/generators/active_record/templates/migration.rb
|
78
|
+
- lib/generators/active_record/templates/migration_existing.rb
|
79
|
+
- lib/generators/active_record/tida_sina_weibo_generator.rb
|
80
|
+
- lib/generators/tida_sina_weibo/.DS_Store
|
81
|
+
- lib/generators/tida_sina_weibo/install_generator.rb
|
82
|
+
- lib/generators/tida_sina_weibo/orm_helpers.rb
|
74
83
|
- lib/tida_sina_weibo.rb
|
75
84
|
- lib/tida_sina_weibo/api_wrapper.rb
|
76
85
|
- lib/tida_sina_weibo/exceptions.rb
|