blueprint-generators-rails 0.1.6 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f4dde552d765f037d4d27832a79cf49401806c2
4
- data.tar.gz: 3e4c1d2f522495f630bbe1c4938fc6416e1294a0
3
+ metadata.gz: 471aa431879477e255e4a76c14f55a235ae1db39
4
+ data.tar.gz: 2885822fa8c7798469c5b431738d05ccc5fd676d
5
5
  SHA512:
6
- metadata.gz: 4b14623410b34911657054fbc55719249e01cd5786c175591caafd2477a30336d30ab84b101df5f0684ad9ca7ade370d4f04e638d67e4d3b0470653562e701c6
7
- data.tar.gz: 9d007c8492bdebef931e0dc40091c34dc76e0fb81355b337d1cf32a9681b3cc769c829473272b5de684a9a4b6683be6c83000b40b1abe51b6e4167bbe3c21e38
6
+ metadata.gz: 81c3e88fdee8fec049a9645dbe062746fe9ff5344d0eb3adc9c9480b7fd87439679023a34b61a1dce651893030102de5d2ef03c75d2e807032bbf0f851c56423
7
+ data.tar.gz: 9d6db38e292560a0e1a99debd48c57006738f3fd6f92f3ac552b25fc9036a4a8769b4eef5487f2c7d9eb8cca3f334a64bf8c267024a497201fc436de75461d36
@@ -1,7 +1,7 @@
1
1
  module Blueprint
2
2
  module Generators
3
3
  module Rails
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
6
6
  end
7
7
  end
@@ -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, [:options] do |t, args|
6
+ task :cm, :root_dir, :debug do |t, args|
7
7
 
8
- # set the debug flag
9
- @debug = args[:options] == 'debug'
8
+ root_dir = args[:root_dir] || '.'
9
+ @debug = args[:debug] || false
10
10
 
11
- # TODO perform a sanity check to make sure that this is a Rails project
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(Dir.pwd + '/config') do
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(Dir.pwd + '/app/models') do
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.6
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-28 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler