2
0

Added automatic .go.erb compilation

fixes #16
This commit is contained in:
Jack Christensen
2013-05-02 09:23:26 -05:00
parent 36e4d74d30
commit 3fef18bf38
8 changed files with 81 additions and 2 deletions
+48
View File
@@ -0,0 +1,48 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
context = Struct.new(:path) # default
=begin Context Object
context = Class.new do
def initialize(path)
end
# custom behaviour
end
=end
locals = Hash.new({}) # default
=begin Local Variables
require 'yaml'
locals, path = {}, 'locals.yml'
def locals.reload
update YAML.load_file(path)
end
locals.reload
=end
guard 'tilt', :context => context, :locals => locals do
# watch files with two extnames like index.html.erb
watch %r'.+go.erb'
end
# Guard::Tilt.root = Dir.getwd # (default: Dir.getwd)
=begin Output Path
class OuputPath < Guard::Tilt::OutputPath
BASE = File.expand_path 'views'
ROOT = File.expand_path 'public'
# By default Path#sanitize only strips an extname from itself.
#
# If you want to write the rendered output to another folder you can
# overwrite this method to return another Path object, like this:
def sanitize
super.sub BASE, ROOT
end
# ... then set the OutputPath class.
Guard::Tilt.output_path = self
end
=end
+23
View File
@@ -3,6 +3,29 @@ pgx
Experimental PostgreSQL client library for Go
Usage
=====
TODO
Development
===========
ERB Templating
--------------
Sometimes Go code can be repetitive especially with dealing with functions that only differ in the type (e.g. ReadInt16, ReadInt32, ReadInt64). Some of this repetition can be eliminated by using a template preprocessor. pgx uses Ruby erb templates. Files that end in .go.erb are used to produce the corresponding .go files. These files can be automatically processed with guard -- a Ruby file and directory watcher.
Prerequisites:
* Ruby
* guard
* guard-tilt
To automatically process .go.erb files open a shell in the pgx directory and run:
jack@hk-47~/dev/pgx$ guard
Testing
-------
+2
View File
@@ -107,6 +107,7 @@ func TestSelectAllInt16(t *testing.T) {
}
}
func TestSelectAllFloat64(t *testing.T) {
conn := getSharedConnection()
@@ -142,3 +143,4 @@ func TestSelectAllFloat32(t *testing.T) {
t.Error("Should have received error on null")
}
}
+2
View File
@@ -51,6 +51,7 @@ func TestSelectAllInt<%= size %>(t *testing.T) {
t.Error("Should have received error on null")
}
}
<% end %>
<% [64, 32].each do |size| %>
@@ -71,4 +72,5 @@ func TestSelectAllFloat<%= size %>(t *testing.T) {
t.Error("Should have received error on null")
}
}
<% end %>
+2
View File
@@ -105,6 +105,7 @@ func TestSelectInt16(t *testing.T) {
}
}
func TestSelectFloat64(t *testing.T) {
conn := getSharedConnection()
@@ -140,3 +141,4 @@ func TestSelectFloat32(t *testing.T) {
t.Error("Should have received error on null")
}
}
+2
View File
@@ -49,6 +49,7 @@ func TestSelectInt<%= size %>(t *testing.T) {
t.Error("Should have received error on null")
}
}
<% end %>
<% [64, 32].each do |size| %>
@@ -69,4 +70,5 @@ func TestSelectFloat<%= size %>(t *testing.T) {
t.Error("Should have received error on null")
}
}
<% end %>
-2
View File
@@ -22,7 +22,6 @@ func TestDataRowReaderReadString(t *testing.T) {
}
}
func TestDataRowReaderReadInt64(t *testing.T) {
conn := getSharedConnection()
@@ -78,7 +77,6 @@ func TestDataRowReaderReadInt16(t *testing.T) {
}
func TestDataRowReaderReadFloat64(t *testing.T) {
conn := getSharedConnection()
+2
View File
@@ -40,6 +40,7 @@ func TestDataRowReaderReadInt<%= size %>(t *testing.T) {
t.Error("Wrong value returned")
}
}
<% end %>
<% [64, 32].each do |size| %>
@@ -60,4 +61,5 @@ func TestDataRowReaderReadFloat<%= size %>(t *testing.T) {
t.Error("Wrong value returned")
}
}
<% end %>