mote-debug 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010, 2011 Michel Martens, Damian Janowski and Cyril David
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ require "digest/md5"
2
+ require "fileutils"
3
+
4
+ # This mote plugin is meant to be used only during
5
+ # development, to help with debugging errors.
6
+ #
7
+ # You debug errors by checking out:
8
+ #
9
+ # tmp/cache/mote/*.mote.rb
10
+ #
11
+ # The files written here are compiled, and you can
12
+ # explore how mote actually writes them. When you
13
+ # run into an error, the browser reports the line
14
+ # number in these files. From there you can check
15
+ # the actual offending line in the compiled mote file.
16
+ #
17
+ class Mote
18
+ # This overrides the standard `Mote::compile` method
19
+ # by writing the compiled form into a file, and passing
20
+ # the filename into instance_eval. That way errors
21
+ # can be properly traced back to the actual offending line.
22
+ def self.compile(context, parts)
23
+ FileUtils.mkdir_p(cache_path) unless File.directory?(cache_path)
24
+
25
+ cache(parts) do |path|
26
+ context.instance_eval(parts, path, 1)
27
+ end
28
+ end
29
+
30
+ def self.cache(data)
31
+ # First we write the generated the filename using the MD5
32
+ # of the data. This prevents us from re-writing them if
33
+ # ever we've already done so.
34
+ path = cache_path(Digest::MD5.hexdigest(data) + ".mote.rb")
35
+
36
+ # Now we can write the file into the specified path, if
37
+ # it doesn't exist yet.
38
+ write(path, data) unless File.exist?(path)
39
+
40
+ yield path
41
+ end
42
+
43
+ # The default cache path is in your project /tmp folder.
44
+ def self.cache_path(*args)
45
+ File.join(Dir.pwd, "tmp/cache/mote", *args)
46
+ end
47
+
48
+ def self.write(path, parts)
49
+ File.open(path, "w") { |f| f.write(parts) }
50
+ end
51
+ end
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "mote-debug"
3
+ s.version = "0.0.1"
4
+ s.summary = "Mote debug aid."
5
+ s.description = "Minimal debugging support for mote."
6
+ s.authors = ["Cyril David"]
7
+ s.email = ["me@cyrildavid.com"]
8
+ s.homepage = "http://github.com/cyx/mote-debug"
9
+
10
+ s.files = Dir[
11
+ "LICENSE",
12
+ "README",
13
+ "rakefile",
14
+ "lib/**/*.rb",
15
+ "*.gemspec",
16
+ "test/*.*"
17
+ ]
18
+
19
+ s.add_dependency "mote", "~> 0.2.4"
20
+ s.add_development_dependency "dep"
21
+ s.add_development_dependency "cutest"
22
+ end
@@ -0,0 +1,6 @@
1
+ desc "Run all tests"
2
+ task :test do
3
+ exec "cutest test/*.rb"
4
+ end
5
+
6
+ task :default => :test
@@ -0,0 +1,21 @@
1
+ require "mote"
2
+ require_relative "../lib/mote/debug"
3
+
4
+ setup do
5
+ "./tmp/cache/mote"
6
+ end
7
+
8
+ test do |dir|
9
+ Mote.parse("{{ ' foo bar '.strip }}").call
10
+
11
+ assert File.directory?(dir)
12
+
13
+ files = Dir[File.join(dir, "*")]
14
+
15
+ assert_equal 1, files.size
16
+
17
+ compiled = File.read(files.first)
18
+ assert files.first.include?(Digest::MD5.hexdigest(compiled))
19
+ end
20
+
21
+ FileUtils.rm_rf("./tmp")
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mote-debug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Cyril David
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mote
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: dep
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: cutest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Minimal debugging support for mote.
63
+ email:
64
+ - me@cyrildavid.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - LICENSE
70
+ - rakefile
71
+ - lib/mote/debug.rb
72
+ - mote-debug.gemspec
73
+ - test/mote-debug.rb
74
+ homepage: http://github.com/cyx/mote-debug
75
+ licenses: []
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.23
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Mote debug aid.
98
+ test_files: []