blueprint-generators-rails 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4dd3746418f3f322d038649eb2762cbbb22e4da
4
- data.tar.gz: ecacd6fb0c21f510278c41ec0a9963da28e04ef5
3
+ metadata.gz: 9f4dde552d765f037d4d27832a79cf49401806c2
4
+ data.tar.gz: 3e4c1d2f522495f630bbe1c4938fc6416e1294a0
5
5
  SHA512:
6
- metadata.gz: 0864eaf8fff6cda4a35a7bbfd3f7bc5204a08a9b9e28e518146f88400910f4ab200978bb6c9e46994b46cc01e6ab5f7849b8eb9ed67400027dd7e71bc1088cde
7
- data.tar.gz: 3d5bada5557c13e498bb723b5bf59c927f412854f03bdd77ae929c2778c611eb25e7a7ff939f28e57a80b51619757428e0f768ca77d8eb64b5fea4c61b817dfb
6
+ metadata.gz: 4b14623410b34911657054fbc55719249e01cd5786c175591caafd2477a30336d30ab84b101df5f0684ad9ca7ade370d4f04e638d67e4d3b0470653562e701c6
7
+ data.tar.gz: 9d007c8492bdebef931e0dc40091c34dc76e0fb81355b337d1cf32a9681b3cc769c829473272b5de684a9a4b6683be6c83000b40b1abe51b6e4167bbe3c21e38
@@ -1,7 +1,7 @@
1
1
  module Blueprint
2
2
  module Generators
3
3
  module Rails
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
6
6
  end
7
7
  end
@@ -4,11 +4,12 @@ namespace :blueprint do
4
4
 
5
5
  desc 'Generate a Conceptual Model diagram for the current Rails project'
6
6
  task :cm, [:options] do |t, args|
7
- # Rails.application.eager_load!
8
7
 
9
8
  # set the debug flag
10
9
  @debug = args[:options] == 'debug'
11
10
 
11
+ # TODO perform a sanity check to make sure that this is a Rails project
12
+
12
13
  # we store the detected model in a hash - which we later serialize to PogoScript
13
14
  model = { }
14
15
 
@@ -16,17 +17,35 @@ namespace :blueprint do
16
17
  step_count = 1
17
18
 
18
19
  # get the configured app name
19
- app_name = Dir.pwd.split('/').last.capitalize
20
- # app_name = Rails.application.class.parent_name
20
+ app_name = nil
21
+
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
21
27
 
22
- print_debug step_count, "Application name is " + app_name
23
- step_count += 1
28
+ # otherwise find the application name
29
+ Dir.chdir(Dir.pwd + '/config') do
30
+ File.open('application.rb') do |f|
31
+ f.each_line do |line|
32
+ m, app_name = line.match(/(module )(.*)/).try(:captures)
33
+ unless app_name.nil?
34
+ print_debug step_count, "Application name is " + app_name
35
+ step_count += 1
36
+ break
37
+ end
38
+ end
39
+ end
40
+ end
24
41
 
42
+ # if the models directory can't be found then stop
25
43
  unless Dir.exist?(Dir.pwd + '/app/models')
26
44
  print_debug step_count, 'Could not find models directory. Stopping analysis.'
27
- return 0
45
+ next
28
46
  end
29
47
 
48
+ # otherwise continue analysis
30
49
  Dir.chdir(Dir.pwd + '/app/models') do
31
50
 
32
51
  # list all files in the directory
@@ -37,11 +56,11 @@ namespace :blueprint do
37
56
  # puts "Found: #{f}"
38
57
 
39
58
  # process each file
40
- File.open(f) do |m|
59
+ File.open(f) do |g|
41
60
  concept_name = nil
42
61
 
43
62
  # process each line of the file
44
- m.each_line do |line|
63
+ g.each_line do |line|
45
64
 
46
65
  # search for the class declaration line
47
66
  clazz, super_clazz = line.match(/class ([^<]*) < (.*)/).try(:captures)
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.5
4
+ version: 0.1.6
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-27 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler