blueprint-generators-rails 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blueprint/generators/rails/version.rb +1 -1
- data/lib/tasks/blueprint.rake +29 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 471aa431879477e255e4a76c14f55a235ae1db39
|
4
|
+
data.tar.gz: 2885822fa8c7798469c5b431738d05ccc5fd676d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c3e88fdee8fec049a9645dbe062746fe9ff5344d0eb3adc9c9480b7fd87439679023a34b61a1dce651893030102de5d2ef03c75d2e807032bbf0f851c56423
|
7
|
+
data.tar.gz: 9d6db38e292560a0e1a99debd48c57006738f3fd6f92f3ac552b25fc9036a4a8769b4eef5487f2c7d9eb8cca3f334a64bf8c267024a497201fc436de75461d36
|
data/lib/tasks/blueprint.rake
CHANGED
@@ -3,12 +3,35 @@ namespace :blueprint do
|
|
3
3
|
@debug = false
|
4
4
|
|
5
5
|
desc 'Generate a Conceptual Model diagram for the current Rails project'
|
6
|
-
task :cm,
|
6
|
+
task :cm, :root_dir, :debug do |t, args|
|
7
7
|
|
8
|
-
|
9
|
-
@debug = args[:
|
8
|
+
root_dir = args[:root_dir] || '.'
|
9
|
+
@debug = args[:debug] || false
|
10
10
|
|
11
|
-
|
11
|
+
if @debug
|
12
|
+
puts "Debug mode #{@debug}"
|
13
|
+
puts "Root directory for analysis is: #{root_dir}"
|
14
|
+
end
|
15
|
+
|
16
|
+
# check that this is actually a Rails projects
|
17
|
+
unless File.exist?(root_dir + '/Gemfile')
|
18
|
+
puts 'No Gemfile found. Is this a Rails project?'
|
19
|
+
next
|
20
|
+
end
|
21
|
+
|
22
|
+
# if the config directory can't be found then stop
|
23
|
+
unless Dir.exist?(root_dir + '/config')
|
24
|
+
puts 'No config directory found. Is this a Rails project?'
|
25
|
+
next
|
26
|
+
end
|
27
|
+
|
28
|
+
# if the models directory can't be found then stop
|
29
|
+
unless Dir.exist?(root_dir + '/app/models')
|
30
|
+
puts 'No app/models directory found. Is this a Rails project?'
|
31
|
+
next
|
32
|
+
end
|
33
|
+
|
34
|
+
# if we get here than all base sanity checks are passed
|
12
35
|
|
13
36
|
# we store the detected model in a hash - which we later serialize to PogoScript
|
14
37
|
model = { }
|
@@ -19,14 +42,8 @@ namespace :blueprint do
|
|
19
42
|
# get the configured app name
|
20
43
|
app_name = nil
|
21
44
|
|
22
|
-
# if the config directory can't be found then stop
|
23
|
-
unless Dir.exist?(Dir.pwd + '/config')
|
24
|
-
print_debug step_count, 'Could not find config directory. Stopping analysis.'
|
25
|
-
next
|
26
|
-
end
|
27
|
-
|
28
45
|
# otherwise find the application name
|
29
|
-
Dir.chdir(
|
46
|
+
Dir.chdir(root_dir + '/config') do
|
30
47
|
File.open('application.rb') do |f|
|
31
48
|
f.each_line do |line|
|
32
49
|
m, app_name = line.match(/(module )(.*)/).try(:captures)
|
@@ -39,21 +56,14 @@ namespace :blueprint do
|
|
39
56
|
end
|
40
57
|
end
|
41
58
|
|
42
|
-
# if the models directory can't be found then stop
|
43
|
-
unless Dir.exist?(Dir.pwd + '/app/models')
|
44
|
-
print_debug step_count, 'Could not find models directory. Stopping analysis.'
|
45
|
-
next
|
46
|
-
end
|
47
|
-
|
48
59
|
# otherwise continue analysis
|
49
|
-
Dir.chdir(
|
60
|
+
Dir.chdir(root_dir + '/app/models') do
|
50
61
|
|
51
62
|
# list all files in the directory
|
52
63
|
Dir.foreach('.') { |f|
|
53
64
|
|
54
65
|
# only deal with files that have a '.rb' extension
|
55
66
|
if File.extname(f) == '.rb'
|
56
|
-
# puts "Found: #{f}"
|
57
67
|
|
58
68
|
# process each file
|
59
69
|
File.open(f) do |g|
|
@@ -67,7 +77,6 @@ namespace :blueprint do
|
|
67
77
|
|
68
78
|
# if we find a class declaration line, add the new concept to the model
|
69
79
|
unless clazz.nil?
|
70
|
-
# puts "Parsed: #{clazz} : #{super_clazz}"
|
71
80
|
concept_name = clazz.pluralize
|
72
81
|
|
73
82
|
# add the concept to the model hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueprint-generators-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benjii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|