mongify 0.3.1 → 0.9
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/.rspec +1 -0
- data/CHANGELOG.rdoc +8 -0
- data/Gemfile.lock +20 -21
- data/README.rdoc +34 -35
- data/bin/mongify +6 -1
- data/features/options.feature +14 -16
- data/features/print.feature +1 -1
- data/features/process.feature +2 -2
- data/features/step_definitions/mongify_steps.rb +1 -1
- data/lib/mongify/cli.rb +5 -3
- data/lib/mongify/cli/application.rb +1 -2
- data/lib/mongify/cli/command/help.rb +19 -0
- data/lib/mongify/cli/command/version.rb +20 -0
- data/lib/mongify/cli/command/worker.rb +101 -0
- data/lib/mongify/cli/options.rb +28 -35
- data/lib/mongify/database/no_sql_connection.rb +1 -1
- data/lib/mongify/database/sql_connection.rb +0 -1
- data/lib/mongify/progressbar.rb +4 -2
- data/lib/mongify/version.rb +1 -1
- data/mongify.gemspec +5 -5
- data/spec/mongify/cli/application_spec.rb +3 -4
- data/spec/mongify/cli/{help_command_spec.rb → command/help_spec.rb} +2 -2
- data/spec/mongify/cli/{version_command_spec.rb → command/version_spec.rb} +3 -3
- data/spec/mongify/cli/options_spec.rb +24 -28
- data/spec/mongify/cli/worker_command_spec.rb +10 -10
- data/spec/mongify/database/no_sql_connection_spec.rb +1 -1
- data/spec/mongify/database/sql_connection_spec.rb +16 -28
- data/spec/mongify/translation/process_spec.rb +1 -0
- data/spec/support/database.example +1 -1
- metadata +31 -46
- data/lib/mongify/cli/help_command.rb +0 -17
- data/lib/mongify/cli/version_command.rb +0 -19
- data/lib/mongify/cli/worker_command.rb +0 -101
@@ -6,6 +6,7 @@ describe Mongify::Translation::Process do
|
|
6
6
|
@sql_connection = DatabaseGenerator.sqlite_connection
|
7
7
|
@no_sql_connection = DatabaseGenerator.mongo_connection
|
8
8
|
@translation = Mongify::Translation.new
|
9
|
+
Mongify::Configuration.out_stream = nil
|
9
10
|
end
|
10
11
|
|
11
12
|
it "validates a sqlconnection" do
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: mongify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: '0.9'
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andrew Kalek
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|
@@ -48,49 +48,33 @@ dependencies:
|
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
name: mysql2
|
55
|
-
prerelease: false
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
51
|
+
- - ~>
|
60
52
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
type: :runtime
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.1.5
|
53
|
+
version: 1.8.2
|
70
54
|
name: mongo
|
71
55
|
prerelease: false
|
72
56
|
requirement: !ruby/object:Gem::Requirement
|
73
57
|
none: false
|
74
58
|
requirements:
|
75
|
-
- -
|
59
|
+
- - ~>
|
76
60
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.
|
61
|
+
version: 1.8.2
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
63
|
type: :runtime
|
80
64
|
version_requirements: !ruby/object:Gem::Requirement
|
81
65
|
none: false
|
82
66
|
requirements:
|
83
|
-
- -
|
67
|
+
- - ~>
|
84
68
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.
|
69
|
+
version: 1.8.2
|
86
70
|
name: bson_ext
|
87
71
|
prerelease: false
|
88
72
|
requirement: !ruby/object:Gem::Requirement
|
89
73
|
none: false
|
90
74
|
requirements:
|
91
|
-
- -
|
75
|
+
- - ~>
|
92
76
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
77
|
+
version: 1.8.2
|
94
78
|
- !ruby/object:Gem::Dependency
|
95
79
|
type: :runtime
|
96
80
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -194,31 +178,31 @@ dependencies:
|
|
194
178
|
requirements:
|
195
179
|
- - ! '>='
|
196
180
|
- !ruby/object:Gem::Version
|
197
|
-
version: '
|
198
|
-
name:
|
181
|
+
version: '1.3'
|
182
|
+
name: sqlite3-ruby
|
199
183
|
prerelease: false
|
200
184
|
requirement: !ruby/object:Gem::Requirement
|
201
185
|
none: false
|
202
186
|
requirements:
|
203
187
|
- - ! '>='
|
204
188
|
- !ruby/object:Gem::Version
|
205
|
-
version: '
|
189
|
+
version: '1.3'
|
206
190
|
- !ruby/object:Gem::Dependency
|
207
191
|
type: :development
|
208
192
|
version_requirements: !ruby/object:Gem::Requirement
|
209
193
|
none: false
|
210
194
|
requirements:
|
211
|
-
- -
|
195
|
+
- - ~>
|
212
196
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
214
|
-
name:
|
197
|
+
version: 0.2.7
|
198
|
+
name: mysql2
|
215
199
|
prerelease: false
|
216
200
|
requirement: !ruby/object:Gem::Requirement
|
217
201
|
none: false
|
218
202
|
requirements:
|
219
|
-
- -
|
203
|
+
- - ~>
|
220
204
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
205
|
+
version: 0.2.7
|
222
206
|
- !ruby/object:Gem::Dependency
|
223
207
|
type: :development
|
224
208
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -226,15 +210,15 @@ dependencies:
|
|
226
210
|
requirements:
|
227
211
|
- - ! '>='
|
228
212
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
230
|
-
name:
|
213
|
+
version: '0.6'
|
214
|
+
name: watchr
|
231
215
|
prerelease: false
|
232
216
|
requirement: !ruby/object:Gem::Requirement
|
233
217
|
none: false
|
234
218
|
requirements:
|
235
219
|
- - ! '>='
|
236
220
|
- !ruby/object:Gem::Version
|
237
|
-
version:
|
221
|
+
version: '0.6'
|
238
222
|
- !ruby/object:Gem::Dependency
|
239
223
|
type: :development
|
240
224
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -263,6 +247,7 @@ extra_rdoc_files:
|
|
263
247
|
- README.rdoc
|
264
248
|
files:
|
265
249
|
- .gitignore
|
250
|
+
- .rspec
|
266
251
|
- CHANGELOG.rdoc
|
267
252
|
- Gemfile
|
268
253
|
- Gemfile.lock
|
@@ -280,10 +265,10 @@ files:
|
|
280
265
|
- lib/mongify.rb
|
281
266
|
- lib/mongify/cli.rb
|
282
267
|
- lib/mongify/cli/application.rb
|
283
|
-
- lib/mongify/cli/
|
268
|
+
- lib/mongify/cli/command/help.rb
|
269
|
+
- lib/mongify/cli/command/version.rb
|
270
|
+
- lib/mongify/cli/command/worker.rb
|
284
271
|
- lib/mongify/cli/options.rb
|
285
|
-
- lib/mongify/cli/version_command.rb
|
286
|
-
- lib/mongify/cli/worker_command.rb
|
287
272
|
- lib/mongify/configuration.rb
|
288
273
|
- lib/mongify/database.rb
|
289
274
|
- lib/mongify/database/base_connection.rb
|
@@ -306,9 +291,9 @@ files:
|
|
306
291
|
- spec/files/embedded_parent_translation.rb
|
307
292
|
- spec/files/translation.rb
|
308
293
|
- spec/mongify/cli/application_spec.rb
|
309
|
-
- spec/mongify/cli/
|
294
|
+
- spec/mongify/cli/command/help_spec.rb
|
295
|
+
- spec/mongify/cli/command/version_spec.rb
|
310
296
|
- spec/mongify/cli/options_spec.rb
|
311
|
-
- spec/mongify/cli/version_command_spec.rb
|
312
297
|
- spec/mongify/cli/worker_command_spec.rb
|
313
298
|
- spec/mongify/configuration_spec.rb
|
314
299
|
- spec/mongify/database/base_connection_spec.rb
|
@@ -355,11 +340,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
355
340
|
- !ruby/object:Gem::Version
|
356
341
|
segments:
|
357
342
|
- 0
|
358
|
-
hash:
|
343
|
+
hash: 2090311925620854324
|
359
344
|
version: '0'
|
360
345
|
requirements: []
|
361
346
|
rubyforge_project:
|
362
|
-
rubygems_version: 1.8.
|
347
|
+
rubygems_version: 1.8.25
|
363
348
|
signing_key:
|
364
349
|
specification_version: 3
|
365
350
|
summary: Translate your SQL data to MongoDB with ease
|
@@ -376,9 +361,9 @@ test_files:
|
|
376
361
|
- spec/files/embedded_parent_translation.rb
|
377
362
|
- spec/files/translation.rb
|
378
363
|
- spec/mongify/cli/application_spec.rb
|
379
|
-
- spec/mongify/cli/
|
364
|
+
- spec/mongify/cli/command/help_spec.rb
|
365
|
+
- spec/mongify/cli/command/version_spec.rb
|
380
366
|
- spec/mongify/cli/options_spec.rb
|
381
|
-
- spec/mongify/cli/version_command_spec.rb
|
382
367
|
- spec/mongify/cli/worker_command_spec.rb
|
383
368
|
- spec/mongify/configuration_spec.rb
|
384
369
|
- spec/mongify/database/base_connection_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Mongify
|
2
|
-
module CLI
|
3
|
-
#
|
4
|
-
# A command to display usage information for this application.
|
5
|
-
#
|
6
|
-
class HelpCommand
|
7
|
-
def initialize(parser)
|
8
|
-
@parser = parser
|
9
|
-
end
|
10
|
-
#Executes the help command
|
11
|
-
def execute(view)
|
12
|
-
view.output(@parser.to_s)
|
13
|
-
view.report_success
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'mongify/version'
|
2
|
-
module Mongify
|
3
|
-
module CLI
|
4
|
-
|
5
|
-
#
|
6
|
-
# A command to report the application's current version number.
|
7
|
-
#
|
8
|
-
class VersionCommand
|
9
|
-
def initialize(progname)
|
10
|
-
@progname = progname
|
11
|
-
end
|
12
|
-
#Executes version command
|
13
|
-
def execute(view)
|
14
|
-
view.output("#{@progname} #{Mongify::VERSION}\n")
|
15
|
-
view.report_success
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module Mongify
|
2
|
-
module CLI
|
3
|
-
|
4
|
-
#
|
5
|
-
# A command to run the different commands in the application (related to Mongifying).
|
6
|
-
#
|
7
|
-
class WorkerCommand
|
8
|
-
attr_accessor :view
|
9
|
-
|
10
|
-
# A hash of available commands
|
11
|
-
# Including description, additional shortcuts to run the commands and requirements to run the command
|
12
|
-
AVAILABLE_COMMANDS = {
|
13
|
-
:check => {:commands => ['check', 'ck'], :description => "Checks connection for sql and no_sql databases", :required => [:configuration_file]},
|
14
|
-
:translation => {:commands => ['translation', 'tr'], :description => "Outputs a translation file from a sql connection", :required => [:configuration_file]},
|
15
|
-
:process => {:commands => ['process', 'pr'], :description => "Takes a translation and process it to mongodb", :required => [:configuration_file, :translation_file]}
|
16
|
-
}
|
17
|
-
|
18
|
-
# Prints out a nice display of the list of commands
|
19
|
-
def self.list_commands
|
20
|
-
[].tap do |commands|
|
21
|
-
AVAILABLE_COMMANDS.each do |key, obj|
|
22
|
-
commands << "#{obj[:commands].map{|w| %["#{w}"]}.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ').ljust(25)} >> #{obj[:description]}#{ " [#{obj[:required].join(', ')}]" if obj[:required]}"
|
23
|
-
end
|
24
|
-
end.sort
|
25
|
-
end
|
26
|
-
|
27
|
-
# Finds a command array by any of the shortcut commands
|
28
|
-
def self.find_command(command)
|
29
|
-
AVAILABLE_COMMANDS.each do |key, options|
|
30
|
-
return [key, options] if(options[:commands].include?(command.to_s.downcase))
|
31
|
-
end
|
32
|
-
'unknown'
|
33
|
-
end
|
34
|
-
|
35
|
-
def initialize(command, config=nil, translation_file=nil, parser="")
|
36
|
-
@command = command.to_s.downcase
|
37
|
-
@config = config
|
38
|
-
@translation_file = translation_file
|
39
|
-
@parser = parser
|
40
|
-
end
|
41
|
-
|
42
|
-
#Executes the worked based on a given command
|
43
|
-
def execute(view)
|
44
|
-
self.view = view
|
45
|
-
|
46
|
-
current_command, command_options = find_command
|
47
|
-
|
48
|
-
if command_options
|
49
|
-
#FIXME: Should parse configuration file in this action, (when I know it's required)
|
50
|
-
raise ConfigurationFileNotFound, "Configuration file is required" if command_options[:required] && command_options[:required].include?(:configuration_file) && @config.nil?
|
51
|
-
if command_options[:required] && command_options[:required].include?(:translation_file)
|
52
|
-
raise TranslationFileNotFound, "Translation file is required for command '#{current_command}'" unless @translation_file
|
53
|
-
raise TranslationFileNotFound, "Unable to find Translation File at #{@translation_file}" unless File.exists?(@translation_file)
|
54
|
-
@translation = Translation.parse(@translation_file)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
case current_command
|
59
|
-
when :translation
|
60
|
-
check_connections
|
61
|
-
view.output(Mongify::Translation.load(@config.sql_connection).print)
|
62
|
-
when :check
|
63
|
-
view.output("SQL connection works") if check_sql_connection
|
64
|
-
view.output("NoSQL connection works") if check_nosql_connection
|
65
|
-
when :process
|
66
|
-
check_connections
|
67
|
-
@translation.process(@config.sql_connection, @config.no_sql_connection)
|
68
|
-
else
|
69
|
-
view.output("Unknown action #{@command}\n\n#{@parser}")
|
70
|
-
view.report_error
|
71
|
-
return
|
72
|
-
end
|
73
|
-
view.report_success
|
74
|
-
end
|
75
|
-
|
76
|
-
# Passes find command to parent class
|
77
|
-
def find_command(command=@command)
|
78
|
-
self.class.find_command(command)
|
79
|
-
end
|
80
|
-
|
81
|
-
#######
|
82
|
-
private
|
83
|
-
#######
|
84
|
-
|
85
|
-
# Checks both sql and no sql connection
|
86
|
-
def check_connections
|
87
|
-
check_sql_connection && check_nosql_connection
|
88
|
-
end
|
89
|
-
|
90
|
-
# Checks sql connection if it's valid and has_connection?
|
91
|
-
def check_sql_connection
|
92
|
-
@config.sql_connection.valid? && @config.sql_connection.has_connection?
|
93
|
-
end
|
94
|
-
|
95
|
-
# Checks no sql connection if it's valid and has_connection?
|
96
|
-
def check_nosql_connection
|
97
|
-
@config.no_sql_connection.valid? && @config.no_sql_connection.has_connection?
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|