dbt 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +51 -6
  3. data/lib/dbt.rb +13 -7
  4. data/lib/dbt/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba557c498d79c32a182b797644a88c4f646b5e8
4
- data.tar.gz: 16954fb22aa547fdbf93f0d78c063df2f8524534
3
+ metadata.gz: 5153399f4bfbef848e903d4d05746d072b134bfe
4
+ data.tar.gz: d257bbf98944963437dafc1f802db78e6aa01118
5
5
  SHA512:
6
- metadata.gz: 5553bc8f890fa582c427516872b0a976ab972968aab7e5b5511ee1513fa92b6ff29ae5e2d4e8af50b3e3b6641d184c5e2f8cdcea1965a41c842546b96a60d90e
7
- data.tar.gz: 2683b9a49e18bfd2b85f7128cb55a07f84e0623805d852e60f316d731ba4edcc384f5b8d054f7ecbc982b7b59434952e742bcda9760be96990a55fb2b83e3bbc
6
+ metadata.gz: 3ecac263c5e9f6ac0d94d5853f2345846a01f70064958fcd186cb1381db991144923bf10180e8bda7a51971769c239037d0098d15244622b42cad9d15478cfc4
7
+ data.tar.gz: 0a60c2d365128894d4dc72aa143fa270e0064d916b55ee08e8bc238c3a46a651e6a8e240b03e74a69e536ffee84616693423f3e771dd06aa218b7cacf087674f
data/README.md CHANGED
@@ -1,17 +1,18 @@
1
1
  DBT
2
- ----------
2
+ ---
3
3
 
4
4
  DBT (Dependencies and deBugging Tool) is a tool that looks for `break`,
5
5
  `require`, and `provides` commands (and does a *teensy* bit of code analyzing -
6
6
  it will detect VERY basic class and module declarations) to make your RubyMotion
7
- `Rakefile` and `debugger_cmds` files short and consistent.
7
+ `debugger_cmds` file easy to create, and declaring your file dependencies stupid
8
+ simple.
8
9
 
9
10
  **CAUTION**: It overwrites the `debugger_cmds` file!
10
11
 
11
12
  To use, include this gem (`gem 'dbt'`), and add `DBT.analyze(app)` to your
12
- `Rakefile`, after you have added your libraries and whatnot. It looks at
13
+ `Rakefile`, after you have added your own files to `app.files`. It looks at
13
14
  `app.files` and scans those files, so I mean it when I say "after you have added
14
- your libraries and whatnot". In your source code you add DBT commands:
15
+ your own files". In your source code you add DBT commands:
15
16
 
16
17
  ```ruby
17
18
  # @provides Foo
@@ -30,7 +31,7 @@ end
30
31
  ```
31
32
 
32
33
  When you run `rake`, these commands will be found and translated into directives
33
- for `app.files_dependencies` and `debugger_cmds`. Run `rake` or `rake debug=1`,
34
+ for `app.files_dependencies` and `debugger_cmds`. Run `rake` or `rake debug=1`,
34
35
  and off you go!
35
36
 
36
37
  Your files will be grep'd for `^\w*(class|module)`, and these will be registered
@@ -43,7 +44,17 @@ class ClassName
43
44
  end
44
45
 
45
46
  # @provides module:ModuleName
46
- class ModuleName
47
+ module ModuleName
48
+ end
49
+
50
+
51
+ # @provides module:Foo
52
+ module Foo
53
+ # Sorry, no support for Foo::Bar... I do intend to add it, though!
54
+ #
55
+ # @provides class:Bar
56
+ class Bar
57
+ end
47
58
  end
48
59
 
49
60
 
@@ -59,6 +70,40 @@ So right out of the box, you can add `# @requires class:Foo` if you're having
59
70
  trouble with dependencies and want a quick fix without having to add
60
71
  `# @provides` declarations all over the place.
61
72
 
73
+ Which begs the question, *when* would you need to declare an explicit
74
+ `# @provides`? Examples:
75
+
76
+ ##### Splitting up a class across multiple files:
77
+ ###### controller.rb
78
+ ```ruby
79
+ # @provides Controller
80
+ class Controller < UIViewController
81
+ end
82
+ ```
83
+
84
+ ###### controller_table_view.rb
85
+ ```ruby
86
+ # provides table view methods
87
+ #
88
+ # @requires Controller
89
+ class Controller
90
+
91
+ def numberOfSectionsInTableView(table_view)
92
+ 1
93
+ end
94
+
95
+ end
96
+ ```
97
+
98
+ ##### Not-easily-greppable syntax
99
+ ```ruby
100
+ # @provides module:Foo::Bar
101
+ module Foo ; module Bar
102
+ end end
103
+ ```
104
+
105
+ # Breakpoints
106
+
62
107
  Breakpoints are created using the syntax `#--> break`, with two or more dashes
63
108
  before the `>`. There must not be any whitespace before or after the `#`.
64
109
 
data/lib/dbt.rb CHANGED
@@ -3,9 +3,10 @@
3
3
  module DBT
4
4
  module_function
5
5
  def analyze(app)
6
- debugger_cmds_output = "#------> Creado por el DBT <------#\n"
6
+ debugger_cmds_output = ''
7
7
  dependers = Hash.new { |hash,key| hash[key] = [] }
8
8
  providers = {}
9
+ default_providers = {}
9
10
 
10
11
  files = app.files.flatten.uniq
11
12
  files.flatten.each do |filename|
@@ -15,8 +16,8 @@ module DBT
15
16
 
16
17
  if line =~ /^#--+>/
17
18
  command, dep = line.rstrip.sub(/^#--+> */, '').split(' ', 2)
18
- elsif line =~ /^#[ \t]*@(provides|requires)/
19
- command, dep = line.rstrip.sub(/^#[ \t]*@/, '').split(' ', 2)
19
+ elsif line =~ /^[ \t]*#[ \t]*@(provides|requires)/
20
+ command, dep = line.rstrip.sub(/^[ \t]*#[ \t]*@/, '').split(' ', 2)
20
21
  end
21
22
 
22
23
  if command
@@ -35,17 +36,21 @@ module DBT
35
36
  puts "\033[1m!NO COMPRENDO!\033[0m \"#{command} #{dep}\""
36
37
  puts "\033[1;31m#{filename}:#{file.lineno}\033[0m"
37
38
  end
38
- elsif line =~ /^\s*class\s+(\w+)/
39
+ elsif line =~ /^[ \t]*class[ \t]+(\w+)/
39
40
  dep = "class:#{$1}"
40
- providers[dep] = filename
41
- elsif line =~ /^\s*module\s+(\w+)/
41
+ default_providers[dep] = filename
42
+ elsif line =~ /^[ \t]*module[ \t]+(\w+)/
42
43
  dep = "module:#{$1}"
43
- providers[dep] = filename
44
+ default_providers[dep] = filename
44
45
  end
45
46
  end
46
47
  end
47
48
  end # files
48
49
 
50
+ default_providers.each do |dep, filename|
51
+ providers[key] ||= filename
52
+ end
53
+
49
54
  dependers.each do |filename, dependencies|
50
55
  if dep = dependencies.find { |dep| ! providers.include? dep }
51
56
  puts "\033[1m!NO HAY!\033[0m \033[1;31m#{dep}\033[0m"
@@ -57,6 +62,7 @@ module DBT
57
62
 
58
63
  unless debugger_cmds_output.empty?
59
64
  File.open('debugger_cmds', 'w') do |file|
65
+ file.write "#------> Creado por el DBT <------#\n"
60
66
  file.write debugger_cmds_output
61
67
  end
62
68
  end
data/lib/dbt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DBT
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Thomas-Arnold <colinta@gmail.com>
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-24 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  == DBT (Dependencies and deBugging Tool)