Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added config files

  • Loading branch information...
commit 1d5d4511e58b441b3b1c15365edb55706637cb60 1 parent f84264c
@pusewicz authored
View
2  .gitignore
@@ -0,0 +1,2 @@
+*.beam
+.eunit
View
4 Gemfile
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem "watchr"
+gem "rake", "0.9.2"
View
12 Gemfile.lock
@@ -0,0 +1,12 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ rake (0.9.2)
+ watchr (0.7)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rake (= 0.9.2)
+ watchr
View
114 Rakefile
@@ -0,0 +1,114 @@
+require 'rake/clean'
+
+ERL_VER = 'R14B03'
+ERL_HOME = "/usr/local/Cellar/erlang/#{ERL_VER}/bin"
+
+abort "Please install Erlang #{ERL_VER}: brew update; brew install erlang" unless File.exist?(ERL_HOME)
+
+# Set PATH to use newer Erlang
+ENV["PATH"] = ERL_HOME + ":" + ENV["PATH"]
+
+APPS_EBINS = Dir["ebin"]
+LIBS_EBINS = Dir["/usr/local/lib/erlang/lib/*/ebin"]
+
+ALL_EBINS = APPS_EBINS + LIBS_EBINS
+
+INCLUDE_DIRS = Dir["include"] unless defined?(INCLUDE_DIRS)
+
+CLEAN.include("ebin/*.beam")
+CLEAN.include("*/.eunit")
+CLOBBER.include("ebin/*.beam")
+
+FLAGS = %w(
++warn_unused_vars
++warn_export_all
++warn_shadow_vars
++warn_unused_import
++warn_unused_function
++warn_bif_clash
++warn_unused_record
++warn_deprecated_function
++warn_obsolete_guard
++strict_validation
++warn_export_vars
++warn_exported_vars
++warn_missing_spec
++warn_untyped_record
++debug_info
+).join(' ') unless defined?(FLAGS)
+
+ERLC_FLAGS = INCLUDE_DIRS.map { |i| "-I#{i}" }.join(' ') + " -Ideps #{FLAGS}" unless defined?(ERLC_FLAGS)
+
+SRC = FileList['src/*.erl']
+OBJ = SRC.pathmap("%{src,ebin}X.beam")
+
+rule ".beam" => ["%{ebin,src}X.erl"] do |t|
+ ebin = File.dirname(t.name)
+ sh "erlc -W #{ERLC_FLAGS} -o #{ebin} #{t.source}"
+end
+
+task :default => :compile
+
+desc "Watch files for changes and compile them"
+task :watch do
+ sh("bundle exec watchr Watchfile")
+end
+
+desc "Get deps and compile"
+task :compile => ['rebar:get_deps', 'rebar:compile']
+
+task :default => :compile
+
+desc "Run tests"
+task :test => ['rebar:eunit']
+
+namespace :rebar do
+ task :compile do
+ rebar :compile
+ end
+
+ task :clean do
+ rebar :clean
+ end
+
+ task :build_plt do
+ rebar 'build-plt', { skip_deps: true }
+ end
+
+ task :check_plt do
+ rebar 'check_plt', { skip_deps: true }
+ end
+
+ task :dialyze do
+ rebar :dialyze, { skip_deps: true }
+ end
+
+ task :xref do
+ rebar :xref, { skip_deps: true }
+ end
+
+ task :get_deps do
+ rebar 'get-deps'
+ end
+
+ task :update_deps do
+ rebar 'update-deps'
+ end
+
+ task :delete_deps do
+ rebar 'delete-deps'
+ end
+
+ task :generate do
+ rebar :generate
+ end
+
+ task :eunit do
+ rebar :eunit, { skip_deps: true }
+ end
+
+ def rebar(cmd, opts = {})
+ rebar_opts = opts.map { |k, v| "#{k}=#{v}" }.join(' ')
+ sh "./bin/colorize ./rebar #{cmd} #{rebar_opts}"
+ end
+end
View
43 Watchfile
@@ -0,0 +1,43 @@
+RED = "\x1b[31m" unless defined?(RED)
+GREEN = "\x1b[32m" unless defined?(GREEN)
+RESET = "\x1b[0m" unless defined?(RESET)
+
+FILES = [] unless defined?(FILES)
+
+watch('(src|test)/.*\.erl') do |md|
+ FILES << file = md[0].gsub('src', 'ebin').gsub('.erl','.beam')
+
+ compile(file)
+
+ if $?.success?
+ FILES.delete(file)
+ FILES.each do |f|
+ compile(f)
+ end
+ puts GREEN + "Success compiling `#{md[0]}'" + RESET
+ cmd("rake test")
+ else
+ puts RED + "Error compiling `#{md[0]}'" + RESET
+ end
+end
+
+watch('include/.*\.hrl') do |md|
+ cmd("rake clean")
+ cmd("rake compile")
+
+ if $?.success?
+ puts GREEN + "Success compiling `#{md[0]}'" + RESET
+ cmd("rake test")
+ else
+ puts RED + "Error compiling `#{md[0]}'" + RESET
+ end
+end
+
+def compile(file)
+ cmd "rake #{file}"
+end
+
+def cmd(command)
+ puts command
+ system "./bin/colorize #{command}"
+end
View
51 bin/colorize
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+
+command = ARGV.join(' ')
+
+RED = 31
+GREEN = 32
+YELLOW = 33
+BOLD_YELLOW = "1;33"
+GREY = 37
+MAGENTA = 35
+
+BG_YELLOW = 43
+BG_BLUE = 44
+BG_RED = 41
+BG_MAGENTA = 45
+
+def set_color(fg, bg)
+ print "\x1b[#{fg}m" if fg
+ print "\x1b[#{bg}m" if bg
+end
+
+def reset_color
+ print "\x1b[0m"
+end
+
+def print_color(txt, fg, bg = nil)
+ set_color(fg, bg)
+ print txt.chomp
+ reset_color
+ print "\n" if txt =~ /\n$/
+end
+
+output = %x{#{command}}
+exit_status = $?.exitstatus
+
+output.each_line do |line|
+ case line
+ when /Warning/ then print_color(line, YELLOW)
+ when /\*failed\*/, /context setup failed/, /error/i, /function (.*) undefined/ then print_color(line, RED)
+ when /={3,}/ then print_color(line, GREEN)
+ when /Failed: (\d+)\. Skipped: (\d+)\. Passed: (\d+)\./ then print_color("Failed: #{$1}. ", RED); print_color("Skipped: #{$2}. ", YELLOW); print_color("Passed: #{$3}\n", GREEN)
+ when /One or more tests were cancelled./ then print_color(line, YELLOW)
+ when /One or more eunit tests failed./ then print_color(line, RED)
+ when /There were no tests to run./ then print_color(line, MAGENTA)
+ when /tests? passed./i then print_color(line, GREEN)
+ else
+ print line
+ end
+end
+
+exit exit_status
View
BIN  rebar
Binary file not shown
View
2  rebar.config
@@ -0,0 +1,2 @@
+{cover_enabled, true}.
+{erl_opts, [debug_info, warnings_as_errors]}.
Please sign in to comment.
Something went wrong with that request. Please try again.