blog_io 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +198 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/blog_io.gemspec +29 -0
- data/lib/blog_io/version.rb +3 -0
- data/lib/blog_io.rb +8 -0
- data/lib/generators/blog_io/install_generator.rb +69 -0
- data/lib/generators/blog_io/templates/attachment_template.rb +7 -0
- data/lib/generators/blog_io/templates/comment_template.rb +9 -0
- data/lib/generators/blog_io/templates/db_connector_template.rb +11 -0
- data/lib/generators/blog_io/templates/post_template.rb +36 -0
- data/lib/generators/blog_io/templates/tag_template.rb +12 -0
- data/lib/generators/blog_io/templates/user_template.rb +9 -0
- data/spec/fixtures/config/database.yml +8 -0
- data/spec/lib/generators/install_generator_spec.rb +24 -0
- data/spec/spec_helper.rb +7 -0
- metadata +202 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 84477f20d3dc065bf268b90aec956a4206574efc
|
4
|
+
data.tar.gz: 85397e85d913efc26c3c7dae9268fad58908b3a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b774aac0f2f8c4bfb8d74c934d7062461ad5bce03acfd4f599fcbeae53946077d8a47cb70dc4f98383152710386df0bd6fe159f200b70f8a9199d7b09d0f7eb0
|
7
|
+
data.tar.gz: 382e4ebb6185c416797cc68bf07b3fabb93e41e93c786575eceef2cf821c0f5412c4f959e6fc9b1daf8db4696a7f7203bdf9e5594e75c0760cc30e0cc490e689
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
blog_io (0.0.1)
|
5
|
+
highline (= 1.5.2)
|
6
|
+
mysql2 (~> 0.3, >= 0.3.11)
|
7
|
+
rails (~> 3.2, >= 3.2.17)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (3.2.19)
|
13
|
+
actionpack (= 3.2.19)
|
14
|
+
mail (~> 2.5.4)
|
15
|
+
actionpack (3.2.19)
|
16
|
+
activemodel (= 3.2.19)
|
17
|
+
activesupport (= 3.2.19)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
journey (~> 1.0.4)
|
21
|
+
rack (~> 1.4.5)
|
22
|
+
rack-cache (~> 1.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.2.1)
|
25
|
+
activemodel (3.2.19)
|
26
|
+
activesupport (= 3.2.19)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
activerecord (3.2.19)
|
29
|
+
activemodel (= 3.2.19)
|
30
|
+
activesupport (= 3.2.19)
|
31
|
+
arel (~> 3.0.2)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activeresource (3.2.19)
|
34
|
+
activemodel (= 3.2.19)
|
35
|
+
activesupport (= 3.2.19)
|
36
|
+
activesupport (3.2.19)
|
37
|
+
i18n (~> 0.6, >= 0.6.4)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
addressable (2.3.6)
|
40
|
+
arel (3.0.3)
|
41
|
+
arrayfields (4.9.2)
|
42
|
+
awesome_print (1.2.0)
|
43
|
+
builder (3.0.4)
|
44
|
+
cane (2.6.2)
|
45
|
+
parallel
|
46
|
+
chronic (0.10.2)
|
47
|
+
churn (0.0.35)
|
48
|
+
chronic (>= 0.2.3)
|
49
|
+
hirb
|
50
|
+
json_pure
|
51
|
+
main
|
52
|
+
rest-client (>= 1.6.0)
|
53
|
+
ruby_parser (~> 3.0)
|
54
|
+
sexp_processor (~> 4.1)
|
55
|
+
code_analyzer (0.4.5)
|
56
|
+
sexp_processor
|
57
|
+
code_metrics (0.1.3)
|
58
|
+
coderay (1.1.0)
|
59
|
+
colored (1.2)
|
60
|
+
columnize (0.8.9)
|
61
|
+
debugger (1.6.8)
|
62
|
+
columnize (>= 0.3.1)
|
63
|
+
debugger-linecache (~> 1.2.0)
|
64
|
+
debugger-ruby_core_source (~> 1.3.5)
|
65
|
+
debugger-linecache (1.2.0)
|
66
|
+
debugger-ruby_core_source (1.3.5)
|
67
|
+
diff-lcs (1.2.5)
|
68
|
+
erubis (2.7.0)
|
69
|
+
fattr (2.2.2)
|
70
|
+
flay (2.5.0)
|
71
|
+
ruby_parser (~> 3.0)
|
72
|
+
sexp_processor (~> 4.0)
|
73
|
+
flog (4.2.1)
|
74
|
+
ruby_parser (~> 3.1, > 3.1.0)
|
75
|
+
sexp_processor (~> 4.4)
|
76
|
+
highline (1.5.2)
|
77
|
+
hike (1.2.3)
|
78
|
+
hirb (0.7.2)
|
79
|
+
i18n (0.6.11)
|
80
|
+
journey (1.0.4)
|
81
|
+
json (1.8.1)
|
82
|
+
json_pure (1.8.1)
|
83
|
+
launchy (2.4.2)
|
84
|
+
addressable (~> 2.3)
|
85
|
+
mail (2.5.4)
|
86
|
+
mime-types (~> 1.16)
|
87
|
+
treetop (~> 1.4.8)
|
88
|
+
main (6.0.0)
|
89
|
+
arrayfields (>= 4.7.4)
|
90
|
+
chronic (>= 0.6.2)
|
91
|
+
fattr (>= 2.2.0)
|
92
|
+
map (>= 5.1.0)
|
93
|
+
map (6.5.4)
|
94
|
+
metric_fu (4.11.1)
|
95
|
+
cane (~> 2.5, >= 2.5.2)
|
96
|
+
churn (~> 0.0.35)
|
97
|
+
code_metrics (~> 0.1)
|
98
|
+
coderay
|
99
|
+
flay (~> 2.1, >= 2.0.1)
|
100
|
+
flog (~> 4.1, >= 4.1.1)
|
101
|
+
launchy (~> 2.0)
|
102
|
+
metric_fu-Saikuro (~> 1.1, >= 1.1.3)
|
103
|
+
multi_json
|
104
|
+
rails_best_practices (~> 1.14, >= 1.14.3)
|
105
|
+
redcard
|
106
|
+
reek (~> 1.3, >= 1.3.4)
|
107
|
+
roodi (~> 3.1)
|
108
|
+
metric_fu-Saikuro (1.1.3)
|
109
|
+
mime-types (1.25.1)
|
110
|
+
multi_json (1.10.1)
|
111
|
+
mysql2 (0.3.16)
|
112
|
+
netrc (0.7.7)
|
113
|
+
parallel (1.0.0)
|
114
|
+
polyglot (0.3.5)
|
115
|
+
rack (1.4.5)
|
116
|
+
rack-cache (1.2)
|
117
|
+
rack (>= 0.4)
|
118
|
+
rack-ssl (1.3.4)
|
119
|
+
rack
|
120
|
+
rack-test (0.6.2)
|
121
|
+
rack (>= 1.0)
|
122
|
+
rails (3.2.19)
|
123
|
+
actionmailer (= 3.2.19)
|
124
|
+
actionpack (= 3.2.19)
|
125
|
+
activerecord (= 3.2.19)
|
126
|
+
activeresource (= 3.2.19)
|
127
|
+
activesupport (= 3.2.19)
|
128
|
+
bundler (~> 1.0)
|
129
|
+
railties (= 3.2.19)
|
130
|
+
rails_best_practices (1.15.4)
|
131
|
+
activesupport
|
132
|
+
awesome_print
|
133
|
+
code_analyzer (>= 0.4.3)
|
134
|
+
colored
|
135
|
+
erubis
|
136
|
+
i18n
|
137
|
+
json
|
138
|
+
require_all
|
139
|
+
ruby-progressbar
|
140
|
+
railties (3.2.19)
|
141
|
+
actionpack (= 3.2.19)
|
142
|
+
activesupport (= 3.2.19)
|
143
|
+
rack-ssl (~> 1.3.2)
|
144
|
+
rake (>= 0.8.7)
|
145
|
+
rdoc (~> 3.4)
|
146
|
+
thor (>= 0.14.6, < 2.0)
|
147
|
+
rainbow (2.0.0)
|
148
|
+
rake (10.3.2)
|
149
|
+
rdoc (3.12.2)
|
150
|
+
json (~> 1.4)
|
151
|
+
redcard (1.1.0)
|
152
|
+
reek (1.3.8)
|
153
|
+
rainbow (>= 1.99, < 3.0)
|
154
|
+
ruby2ruby (>= 2.0.8, < 3.0)
|
155
|
+
ruby_parser (~> 3.3)
|
156
|
+
sexp_processor
|
157
|
+
require_all (1.3.2)
|
158
|
+
rest-client (1.7.1)
|
159
|
+
mime-types (>= 1.16, < 3.0)
|
160
|
+
netrc (~> 0.7)
|
161
|
+
roodi (3.3.1)
|
162
|
+
ruby_parser (~> 3.2, >= 3.2.2)
|
163
|
+
rspec (2.14.1)
|
164
|
+
rspec-core (~> 2.14.0)
|
165
|
+
rspec-expectations (~> 2.14.0)
|
166
|
+
rspec-mocks (~> 2.14.0)
|
167
|
+
rspec-core (2.14.8)
|
168
|
+
rspec-expectations (2.14.5)
|
169
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
170
|
+
rspec-mocks (2.14.6)
|
171
|
+
ruby-progressbar (1.5.1)
|
172
|
+
ruby2ruby (2.1.1)
|
173
|
+
ruby_parser (~> 3.1)
|
174
|
+
sexp_processor (~> 4.0)
|
175
|
+
ruby_parser (3.6.1)
|
176
|
+
sexp_processor (~> 4.1)
|
177
|
+
sexp_processor (4.4.3)
|
178
|
+
sprockets (2.2.2)
|
179
|
+
hike (~> 1.2)
|
180
|
+
multi_json (~> 1.0)
|
181
|
+
rack (~> 1.0)
|
182
|
+
tilt (~> 1.1, != 1.3.0)
|
183
|
+
thor (0.19.1)
|
184
|
+
tilt (1.4.1)
|
185
|
+
treetop (1.4.15)
|
186
|
+
polyglot
|
187
|
+
polyglot (>= 0.3.1)
|
188
|
+
tzinfo (0.3.39)
|
189
|
+
|
190
|
+
PLATFORMS
|
191
|
+
ruby
|
192
|
+
|
193
|
+
DEPENDENCIES
|
194
|
+
blog_io!
|
195
|
+
debugger (~> 1.6.6)
|
196
|
+
metric_fu (~> 4.11.1)
|
197
|
+
rake (~> 10.3.2)
|
198
|
+
rspec (~> 2.14.1)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 yogendra689
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# BlogIo
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'blog_io', git: 'https://your_id@bitbucket.org/shivanibhanwal/blog_io.git'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install blog_io
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://bitbucket.org/[my-bitbucket-username]/blog_io/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/blog_io.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'blog_io/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "blog_io"
|
8
|
+
spec.version = BlogIo::VERSION
|
9
|
+
spec.authors = ["yogendra689", "gouravtiwari21"]
|
10
|
+
spec.email = ["yogendra.tala@kiprosh.com", "gouravtiwari21@gmail.com"]
|
11
|
+
spec.summary = %q{Simply migrate your blog posts/comments to another application}
|
12
|
+
spec.description = %q{This gem help you migrating your blog posts to a new web application, via automated migrations}
|
13
|
+
spec.homepage = "http://github.com/kiprosh"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency("rails", "~> 3.2", ">= 3.2.17")
|
22
|
+
spec.add_dependency("highline", "= 1.5.2")
|
23
|
+
spec.add_dependency("mysql2", "~> 0.3", ">= 0.3.11")
|
24
|
+
|
25
|
+
spec.add_development_dependency "debugger", "~> 1.6", ">= 1.6.6"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.3", ">= 10.3.2"
|
27
|
+
spec.add_development_dependency "metric_fu", "~> 4.11", ">= 4.11.1"
|
28
|
+
spec.add_development_dependency "rspec", "~> 2.14", ">= 2.14.1"
|
29
|
+
end
|
data/lib/blog_io.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require "blog_io/version"
|
2
|
+
|
3
|
+
module BlogIo
|
4
|
+
#constants
|
5
|
+
REMOTE_TABLES = ['posts', 'comments', 'attachments', 'users', 'tags']
|
6
|
+
RECORD_CHECK = "====== BlogSettings table already contains data ======"
|
7
|
+
FIXTURE_MODEL_PATH = "spec/fixtures/app/models/post.rb"
|
8
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rails/all'
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'yaml'
|
4
|
+
require 'highline/import'
|
5
|
+
|
6
|
+
module BlogIo
|
7
|
+
module Generators
|
8
|
+
class InstallGenerator < Rails::Generators::Base
|
9
|
+
|
10
|
+
source_root File.expand_path("../templates", __FILE__)
|
11
|
+
|
12
|
+
def check_db_connection(source = Rails.root)
|
13
|
+
@data = YAML.load_file "#{source}/config/database.yml"
|
14
|
+
ActiveRecord::Base.establish_connection @data['blog_db_connector']
|
15
|
+
ActiveRecord::Base.connection
|
16
|
+
@connection_flag = ActiveRecord::Base.connected?
|
17
|
+
ActiveRecord::Base.remove_connection if @connection_flag
|
18
|
+
@connection_flag
|
19
|
+
end
|
20
|
+
|
21
|
+
def blog_settings
|
22
|
+
if @connection_flag
|
23
|
+
Rails::Generators.invoke("model",
|
24
|
+
[ "BlogSettings",
|
25
|
+
"original_table_name:string",
|
26
|
+
"model_name:string",
|
27
|
+
"primary_key_field:string",
|
28
|
+
"--no-test-framework"]
|
29
|
+
)
|
30
|
+
%x[rake db:migrate]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_user_data
|
35
|
+
@get_data = {}
|
36
|
+
BlogIo::REMOTE_TABLES.each do |table_name|
|
37
|
+
name = ask("Enter model name for #{table_name}:")
|
38
|
+
pkey = ask("Enter primary key for #{table_name}:")
|
39
|
+
name = table_name if name.blank?
|
40
|
+
pkey = "id" if pkey.blank?
|
41
|
+
@get_data[table_name] = {'name' => name, 'pkey' => pkey}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_records
|
46
|
+
BlogSettings.establish_connection(@data['#{Rails.env}'])
|
47
|
+
if BlogSettings.all.empty?
|
48
|
+
@get_data.each do |name, field|
|
49
|
+
BlogSettings.create(original_table_name: name,
|
50
|
+
model_name: field['name'],
|
51
|
+
primary_key_field: field['pkey'])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
say(BlogIo::RECORD_CHECK)
|
55
|
+
end
|
56
|
+
BlogSettings.remove_connection
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_models_data(source = Rails.root, user_data = @get_data)
|
60
|
+
user_data.each do |name, field|
|
61
|
+
field_name = field['name']
|
62
|
+
@user_data, @name, @field = user_data, name, field_name
|
63
|
+
template "#{field_name}_template.rb","#{source}/app/models/#{field_name}.rb"
|
64
|
+
end
|
65
|
+
template "db_connector_template.rb","#{source}/lib/blog_db_connect.rb"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class <%= @field.classify %> < ActiveRecord::Base
|
2
|
+
include BlogDbConnect
|
3
|
+
connect_to_db('<%= @name.pluralize %>')
|
4
|
+
|
5
|
+
belongs_to :<%= @user_data['posts']['name'] %>,
|
6
|
+
class_name: '<%= @user_data['posts']['name'].classify %>', foreign_key: 'post_id'
|
7
|
+
belongs_to :<%= @user_data['users']['name'] %>,
|
8
|
+
class_name: '<%= @user_data['users']['name'].classify %>', foreign_key: 'user_id'
|
9
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class <%= @field.classify %> < ActiveRecord::Base
|
2
|
+
include BlogDbConnect
|
3
|
+
connect_to_db('<%= @name.pluralize %>')
|
4
|
+
|
5
|
+
belongs_to :<%= @user_data['users']['name'] %>,
|
6
|
+
class_name: '<%= @user_data['users']['name'].classify %>', foreign_key: 'user_id'
|
7
|
+
has_many :<%= @user_data['attachments']['name'].pluralize %>,
|
8
|
+
class_name: '<%= @user_data['attachments']['name'].classify %>', foreign_key: '<%= @name.singularize %>_id'
|
9
|
+
has_many :<%= @user_data['comments']['name'].pluralize %>,
|
10
|
+
class_name: '<%= @user_data['comments']['name'].classify %>', foreign_key: '<%= @name.singularize %>_id'
|
11
|
+
|
12
|
+
def get_user_info
|
13
|
+
user.to_json(only: [:email, :name])
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_attachments
|
17
|
+
attachments.to_json(only: [ :post_file_name, :post_content_type ])
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_comments
|
21
|
+
comments.to_json(only: [:comment])
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.get_post(id)
|
25
|
+
where(id: id).first.to_json(
|
26
|
+
include: { user: { only: [:email, :name] }, comments: { only: [:comment] },
|
27
|
+
attachments: { only: [ :post_file_name, :post_content_type ] } })
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.by_tags(tag_name)
|
31
|
+
Post.find_by_sql("SELECT posts.* FROM posts JOIN taggings posts_taggings
|
32
|
+
ON posts_taggings.taggable_id = posts.id AND posts_taggings.taggable_type = 'Post'
|
33
|
+
AND posts_taggings.tag_id = (select tags.id from tags where tags.name = '#{tag_name}')
|
34
|
+
WHERE (posts.deleted_at IS NULL) ORDER BY created_at DESC")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= @field.classify %> < ActiveRecord::Base
|
2
|
+
include BlogDbConnect
|
3
|
+
connect_to_db('<%= @name.pluralize %>')
|
4
|
+
|
5
|
+
|
6
|
+
def self.get_tags(post_id)
|
7
|
+
find_by_sql("SELECT tags.* FROM tags INNER JOIN taggings
|
8
|
+
ON tags.id = taggings.tag_id WHERE taggings.taggable_id = #{post_id}
|
9
|
+
AND taggings.taggable_type = 'Post'
|
10
|
+
AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL)")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class <%= @field.classify %> < ActiveRecord::Base
|
2
|
+
include BlogDbConnect
|
3
|
+
connect_to_db('<%= @name.pluralize %>')
|
4
|
+
|
5
|
+
has_many :<%= @user_data['comments']['name'].pluralize %>,
|
6
|
+
class_name: '<%= @user_data['comments']['name'].classify %>', foreign_key: '<%= @name.singularize %>_id'
|
7
|
+
has_many :<%= @user_data['posts']['name'].pluralize %>,
|
8
|
+
class_name: '<%= @user_data['posts']['name'].classify %>', foreign_key: '<%= @name.singularize %>_id'
|
9
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "generators/blog_io/install_generator"
|
2
|
+
require "blog_io"
|
3
|
+
|
4
|
+
describe "install_generator" do
|
5
|
+
before :all do
|
6
|
+
@install_generator = BlogIo::Generators::InstallGenerator.new
|
7
|
+
@get_data = {'post'=>{'name'=>'post', 'pkey'=>'post_id'},
|
8
|
+
'attachment'=>{'name'=>'attach', 'pkey'=>'attach_id'},
|
9
|
+
'user'=>{'name'=>'user', 'pkey'=>'user_id'},
|
10
|
+
'comment'=>{'name'=>'comment', 'pkey'=>'comment_id'},}
|
11
|
+
@file_path = BlogIo::FIXTURE_MODEL_PATH
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'checks database connection' do
|
15
|
+
flag = @install_generator.check_db_connection("spec/fixtures")
|
16
|
+
expect(flag).to be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should add data in models file" do
|
20
|
+
@install_generator.add_models_data("spec/fixtures", @get_data)
|
21
|
+
expect(File.read(@file_path)).to include("include BlogDbConnect")
|
22
|
+
expect(File.read(@file_path)).to include("connect_to_db('posts')")
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blog_io
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yogendra689
|
8
|
+
- gouravtiwari21
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.2'
|
21
|
+
- - '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.2.17
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '3.2'
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.17
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: highline
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.2
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.5.2
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mysql2
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.3'
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.3.11
|
58
|
+
type: :runtime
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0.3'
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.3.11
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: debugger
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.6'
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.6.6
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '1.6'
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.6.6
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: rake
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '10.3'
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 10.3.2
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '10.3'
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 10.3.2
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
name: metric_fu
|
110
|
+
requirement: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ~>
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '4.11'
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.11.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.11'
|
125
|
+
- - '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 4.11.1
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: rspec
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ~>
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '2.14'
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.14.1
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ~>
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '2.14'
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 2.14.1
|
148
|
+
description: This gem help you migrating your blog posts to a new web application,
|
149
|
+
via automated migrations
|
150
|
+
email:
|
151
|
+
- yogendra.tala@kiprosh.com
|
152
|
+
- gouravtiwari21@gmail.com
|
153
|
+
executables: []
|
154
|
+
extensions: []
|
155
|
+
extra_rdoc_files: []
|
156
|
+
files:
|
157
|
+
- Gemfile
|
158
|
+
- Gemfile.lock
|
159
|
+
- LICENSE.txt
|
160
|
+
- README.md
|
161
|
+
- Rakefile
|
162
|
+
- blog_io.gemspec
|
163
|
+
- lib/blog_io.rb
|
164
|
+
- lib/blog_io/version.rb
|
165
|
+
- lib/generators/blog_io/install_generator.rb
|
166
|
+
- lib/generators/blog_io/templates/attachment_template.rb
|
167
|
+
- lib/generators/blog_io/templates/comment_template.rb
|
168
|
+
- lib/generators/blog_io/templates/db_connector_template.rb
|
169
|
+
- lib/generators/blog_io/templates/post_template.rb
|
170
|
+
- lib/generators/blog_io/templates/tag_template.rb
|
171
|
+
- lib/generators/blog_io/templates/user_template.rb
|
172
|
+
- spec/fixtures/config/database.yml
|
173
|
+
- spec/lib/generators/install_generator_spec.rb
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
homepage: http://github.com/kiprosh
|
176
|
+
licenses:
|
177
|
+
- MIT
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - '>='
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.2.2
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: Simply migrate your blog posts/comments to another application
|
199
|
+
test_files:
|
200
|
+
- spec/fixtures/config/database.yml
|
201
|
+
- spec/lib/generators/install_generator_spec.rb
|
202
|
+
- spec/spec_helper.rb
|