skelerl 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/History.txt +4 -0
  2. data/README.txt +48 -0
  3. data/Rakefile +11 -0
  4. data/VERSION.yml +4 -0
  5. data/bin/gen_server +17 -0
  6. data/bin/makefile +17 -0
  7. data/bin/skelerl +60 -0
  8. data/bin/skelerl-gen_server +29 -0
  9. data/bin/skelerl-makefile +29 -0
  10. data/config/jeweler.rb +41 -0
  11. data/config/requirements.rb +15 -0
  12. data/generators/appfile/USAGE +5 -0
  13. data/generators/appfile/appfile_generator.rb +61 -0
  14. data/generators/appfile/templates/appfile.app +19 -0
  15. data/generators/gen_server/USAGE +7 -0
  16. data/generators/gen_server/gen_server_generator.rb +65 -0
  17. data/generators/gen_server/templates/README.txt +1 -0
  18. data/generators/gen_server/templates/Rakefile +1 -0
  19. data/generators/gen_server/templates/gen_server.erl +107 -0
  20. data/generators/gen_server/templates/gitignore +3 -0
  21. data/generators/makefile/USAGE +5 -0
  22. data/generators/makefile/makefile_generator.rb +68 -0
  23. data/generators/makefile/templates/Emakefile +5 -0
  24. data/generators/makefile/templates/Makefile +31 -0
  25. data/generators/makefile/templates/appfile.app.erb +19 -0
  26. data/generators/makefile/templates/make_boot.erl.erb +29 -0
  27. data/generators/makefile/templates/start.sh +4 -0
  28. data/generators/skeleton/USAGE +7 -0
  29. data/generators/skeleton/skeleton_generator.rb +91 -0
  30. data/generators/skeleton/templates/README.txt +1 -0
  31. data/generators/skeleton/templates/Rakefile +1 -0
  32. data/generators/skeleton/templates/gitignore +3 -0
  33. data/script/generate +14 -0
  34. data/tasks/build.rake +152 -0
  35. data/tasks/environment.rake +7 -0
  36. data/tasks/generate.rake +5 -0
  37. data/tasks/website.rake +17 -0
  38. metadata +103 -0
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2009-01-21
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,48 @@
1
+ = skelerl
2
+
3
+ == SYNOPSIS:
4
+
5
+ Skeleton Erlang application
6
+
7
+ This is a basic skeleton for erlang applications.
8
+
9
+ This skeleton app takes care of everything you'd need in an erlang application, hopefully!
10
+
11
+ h2. Building an application
12
+ 1. Include the source code in the src/ directory.
13
+ 2. Add your .app file to the ebin/ directory.
14
+ 3. Type: ./bin/build-app [name] [version]
15
+ 4. There is no fourth step
16
+
17
+ Erlang start script in ruby
18
+
19
+ Example coming shortly
20
+
21
+ == INSTALL:
22
+
23
+ sudo gem install auser-skelerl
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2009 Ari Lerner
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ require 'config/requirements'
2
+
3
+ begin
4
+ require 'hanna/rdoctask'
5
+ rescue LoadError => e
6
+ require "rake/rdoctask"
7
+ end
8
+
9
+ require 'config/jeweler' # setup gem configuration
10
+
11
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 5
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'gen_server/version'
8
+ puts "#{File.basename($0)} #{GenServer::VERSION::STRING}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ source = RubiGen::PathSource.new(:application,
14
+ File.join(File.dirname(__FILE__), "../app_generators"))
15
+ RubiGen::Base.reset_sources
16
+ RubiGen::Base.append_sources source
17
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'gen_server')
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'makefile/version'
8
+ puts "#{File.basename($0)} #{GenServer::VERSION::STRING}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ source = RubiGen::PathSource.new(:application,
14
+ File.join(File.dirname(__FILE__), "../generators"))
15
+ RubiGen::Base.reset_sources
16
+ RubiGen::Base.append_sources source
17
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'makefile')
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ Dir[File.dirname(__FILE__) + "/../vendor/gems/*"].each {|lib| $:.unshift( File.expand_path(lib + "/lib") )}
3
+ require "git-style-binary"
4
+ require "colors"
5
+ require 'git-style-binary/command'
6
+
7
+ GitStyleBinary.primary do
8
+ @theme = :short
9
+
10
+ config = YAML.load(File.read(File.dirname(__FILE__) + '/../VERSION.yml'))
11
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
12
+
13
+ version "Skelerl release: #{version}"
14
+ banner <<-EOS
15
+ Usage: #{$0} #{all_options_string} COMMAND [ARGS]
16
+
17
+ The skelerl subcommands commands are:
18
+ \#{GitStyleBinary.pretty_known_subcommands(:short).join(" ")}
19
+
20
+ See 'skelerl help COMMAND' for more information on a specific command.
21
+ EOS
22
+
23
+ run do |command|
24
+ subcommands = GitStyleBinary.list_subcommands
25
+
26
+ puts "Usage: skelerl COMMAND [ARGS]
27
+
28
+ The skelerl subcommands commands are:
29
+ #{subcommands}
30
+
31
+ See 'skelerl help COMMAND' for more information on a specific command"
32
+ end
33
+ end
34
+
35
+ # #!/usr/bin/env ruby
36
+ # $:.unshift(File.dirname(__FILE__) + "/../lib")
37
+ #
38
+ # require 'rubygems'
39
+ # require 'rubigen'
40
+ # require "skelerl"
41
+ #
42
+ # if %w(-v --version).include? ARGV.first
43
+ # puts "#{File.basename($0)} #{Skelerl::VERSION::STRING}"
44
+ # exit(0)
45
+ # end
46
+ #
47
+ # require 'rubigen/scripts/generate'
48
+ # source = RubiGen::PathSource.new(:application,
49
+ # File.join(File.dirname(__FILE__), "../generators"))
50
+ # RubiGen::Base.reset_sources
51
+ # RubiGen::Base.append_sources source
52
+ #
53
+ # # Different generators
54
+ # if ARGV.contains_similar_elements? %w(--gen_server gen_server gs)
55
+ # RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'gen_server')
56
+ # elsif ARGV.contains_similar_elements? %w(--makefile make mf makefile)
57
+ # RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'makefile')
58
+ # else
59
+ # RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'skeleton')
60
+ # end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ Dir[File.dirname(__FILE__) + "/../vendor/gems/*"].each {|lib| $:.unshift( File.expand_path(lib + "/lib") )}
3
+ require 'git-style-binary/command'
4
+ require "rubigen"
5
+ require 'rubigen/scripts/generate'
6
+
7
+ GitStyleBinary.command do
8
+ banner <<-EOS
9
+ Usage: #{$0} #{all_options_string}
10
+
11
+ Create a gen_server skeleton
12
+ EOS
13
+
14
+ short_desc "Create a gen_server skeleton"
15
+
16
+ opt :name, "The basename of the gen_server to generate", :type => :string
17
+
18
+ run do |command|
19
+
20
+ source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../generators"))
21
+ RubiGen::Base.reset_sources
22
+ RubiGen::Base.append_sources source
23
+
24
+ argv = [command[:name]]
25
+
26
+ RubiGen::Scripts::Generate.new.run(argv, :generator => 'gen_server')
27
+
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ Dir[File.dirname(__FILE__) + "/../vendor/gems/*"].each {|lib| $:.unshift( File.expand_path(lib + "/lib") )}
3
+ require 'git-style-binary/command'
4
+ require "rubigen"
5
+ require 'rubigen/scripts/generate'
6
+
7
+ GitStyleBinary.command do
8
+ banner <<-EOS
9
+ Usage: #{$0} #{all_options_string}
10
+
11
+ Create a Makefile and application skeleton
12
+ EOS
13
+
14
+ short_desc "Create a makefile"
15
+
16
+ opt :name, "The basename of the makefile application to generate", :type => :string
17
+
18
+ run do |command|
19
+
20
+ source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../generators"))
21
+ RubiGen::Base.reset_sources
22
+ RubiGen::Base.append_sources source
23
+
24
+ argv = [command[:name]]
25
+
26
+ RubiGen::Scripts::Generate.new.run(argv, :generator => 'makefile')
27
+
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ # You also need to setup your name and email for git if you haven't already done so.
2
+ # Info at http://github.com/guides/tell-git-your-user-name-and-email-address
3
+
4
+ begin
5
+ class Array
6
+ def one_of_regex
7
+ option_list = join "|"
8
+ Regexp.new "(#{option_list})"
9
+ end
10
+ end
11
+ require 'rubygems'
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |s|
14
+ s.name = "skelerl"
15
+ s.description = "Erlang skeleton application"
16
+ s.summary = <<-EOM
17
+ The most awesomenest erlang skeleton and generator!
18
+ EOM
19
+
20
+ s.homepage = "http://poolpartyrb.com"
21
+ s.email = "arilerner@mac.com"
22
+ s.authors = ["Ari Lerner", "Michael Fairchild", "Nate Murray"]
23
+
24
+ s.test_files = Dir["test/**/test_*.rb"]
25
+
26
+ s.files = (%w(Rakefile README.rdoc License.txt VERSION.yml) + Dir["{config,tasks,script,generators,bin}/**/*"])
27
+
28
+ s.files.exclude '**/*.beam'
29
+ s.files.exclude "**/*/erl_crash.dump"
30
+
31
+ s.has_rdoc = true
32
+ s.extra_rdoc_files = ["README.txt", "License.txt", 'History.txt']
33
+ s.rdoc_options = ['--quiet', '--title', 'Skelerl documentation',
34
+ # "index.html",
35
+ "--line-numbers",
36
+ "--main", "README"
37
+ ]
38
+ end
39
+ rescue LoadError
40
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
41
+ end
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ # puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ # puts "Installation: gem install #{req_gem} -y"
11
+ # exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Create a basic .app file for erlang. This is just a quick generator to help get your .app file built
3
+
4
+ Usage:
5
+ ./script/generate appfile <name>
@@ -0,0 +1,61 @@
1
+ class AppfileGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ default_options :author => nil
7
+
8
+ attr_reader :name
9
+
10
+ def initialize(runtime_args, runtime_options = {})
11
+ super
12
+ usage if args.empty?
13
+ @app_name = args.shift
14
+ @destination_root = File.expand_path(".")
15
+ @name = base_name
16
+ extract_options
17
+ end
18
+
19
+ def manifest
20
+ record do |m|
21
+ m.template "appfile.app", "ebin/#{@app_name}.app"
22
+
23
+ # m.dependency "install_rubigen_scripts", [destination_root, 'appfile'], :shebang => options[:shebang], :collision => :force
24
+ end
25
+ end
26
+
27
+ protected
28
+ def banner
29
+ <<-EOS
30
+ Creates a basic .app file
31
+
32
+ USAGE: #{spec.name} name
33
+ EOS
34
+ end
35
+
36
+ def add_options!(opts)
37
+ opts.separator ''
38
+ opts.separator 'Options:'
39
+ # For each option below, place the default
40
+ # at the top of the file next to "default_options"
41
+ # opts.on("-a", "--author=\"Your Name\"", String,
42
+ # "Some comment about this option",
43
+ # "Default: none") { |options[:author]| }
44
+ opts.on("-n", "--name", "Name the app") { |options[:app_name]| }
45
+ opts.on("-d", "--desc", "Description of the app") { |options[:description]| }
46
+ opts.on("-m", "--modules", "Modules used in the application") { |options[:modules]| }
47
+ opts.on("-r", "--registered", "Modules registered in the application") { |options[:registered]| }
48
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
49
+ end
50
+
51
+ def extract_options
52
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
53
+ # Templates can access these value via the attr_reader-generated methods, but not the
54
+ # raw instance variable value.
55
+ # @author = options[:author]
56
+ @description = options[:desc] || "Description of your project"
57
+ @version = options[:version] || "0.1"
58
+ @modules = options[:modules] || "#{@name}_app"
59
+ @registered = options[:registered] || ""
60
+ end
61
+ end
@@ -0,0 +1,19 @@
1
+ {application, APPNAME,
2
+ [
3
+ % Quick description of the server
4
+ {description, "Description of the application"},
5
+ % Version
6
+ {vsn, "0.0.1"},
7
+ % All modules used by the application.
8
+ {modules, []},
9
+ % All the registered names in the application
10
+ {registered, []},
11
+ % These must be started for application to run
12
+ {applications, [kernel, stdlib]},
13
+ % Environment vars
14
+ {env, []},
15
+ % Module and Args used to start
16
+ {mod, {[]}},
17
+ {start_phases, []}
18
+ ]
19
+ }.
@@ -0,0 +1,7 @@
1
+ Description:
2
+
3
+ Create a skeleton erlang directory with eunit tests and config helpers
4
+
5
+ Usage:
6
+
7
+ skelerl gen_server <name>
@@ -0,0 +1,65 @@
1
+ require 'rbconfig'
2
+
3
+ class GenServerGenerator < RubiGen::Base
4
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
5
+ Config::CONFIG['ruby_install_name'])
6
+
7
+ default_options :shebang => DEFAULT_SHEBANG,
8
+ :an_option => 'some_default'
9
+
10
+ attr_reader :app_name, :module_name
11
+
12
+ def initialize(runtime_args, runtime_options = {})
13
+ super
14
+ usage if args.empty?
15
+ @destination_root = args.shift
16
+ @app_name = File.basename(File.expand_path(@destination_root))
17
+ @module_name = app_name.camelize
18
+ extract_options
19
+ end
20
+
21
+ def manifest
22
+ # Use /usr/bin/env if no special shebang was specified
23
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
24
+ windows = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
25
+
26
+ record do |m|
27
+ m.directory File.join("src")
28
+ m.template "gen_server.erl", "src/#{gen_server_file_name}"
29
+ end
30
+ end
31
+
32
+ def gen_server_file_name
33
+ "#{module_name}.erl"
34
+ end
35
+
36
+ def module_name
37
+ "#{app_name}_srv"
38
+ end
39
+
40
+ protected
41
+ def banner
42
+ <<-EOS
43
+ Create a stub for #{File.basename $0} to get started.
44
+
45
+ Usage: #{File.basename $0} gen_server_name [options]"
46
+ EOS
47
+ end
48
+
49
+ def add_options!(opts)
50
+ opts.separator ''
51
+ opts.separator "#{File.basename $0} options:"
52
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
53
+ end
54
+
55
+ def extract_options
56
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
57
+ # Templates can access these value via the attr_reader-generated methods, but not the
58
+ # raw instance variable value.
59
+ @author = options[:author]
60
+ @description = options[:desc] || "Description of your project"
61
+ end
62
+
63
+ BASEDIRS = %w()
64
+ BASEFILES = %w()
65
+ end
@@ -0,0 +1 @@
1
+ Your app description
@@ -0,0 +1 @@
1
+ require "skelerl"
@@ -0,0 +1,107 @@
1
+ %%%-------------------------------------------------------------------
2
+ %%% File : <%= gen_server_file_name %>
3
+ %%% Author : <%= ENV["USER"] %>
4
+ %%% Description : desc
5
+ %%% Created : <%= Time.now.strftime("%F") %>
6
+ %%%-------------------------------------------------------------------
7
+
8
+ -module (<%= module_name %>).
9
+ -behaviour(gen_server).
10
+
11
+ %% API
12
+ -export([start_link/0]).
13
+
14
+ %% gen_server callbacks
15
+ -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
16
+ terminate/2, code_change/3]).
17
+
18
+ -record(state, {
19
+
20
+ }).
21
+
22
+ %% Macros
23
+ -define(SERVER, ?MODULE).
24
+ -define(DEFAULT_CONFIG, {}).
25
+
26
+ %%====================================================================
27
+ %% API
28
+ %%====================================================================
29
+ %%--------------------------------------------------------------------
30
+ %% Function: start() -> {ok,Pid} | ignore | {error,Error}
31
+ %% Description: Alias for start_link
32
+ %%--------------------------------------------------------------------
33
+ start_link() ->
34
+ start_link(?DEFAULT_CONFIG).
35
+
36
+ %%--------------------------------------------------------------------
37
+ %% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
38
+ %% Description: Starts the server
39
+ %%--------------------------------------------------------------------
40
+ start_link(Config) ->
41
+ gen_server:start_link({local, ?SERVER}, ?MODULE, [Config], []).
42
+
43
+ %%====================================================================
44
+ %% gen_server callbacks
45
+ %%====================================================================
46
+
47
+ %%--------------------------------------------------------------------
48
+ %% Function: init(Args) -> {ok, State} |
49
+ %% {ok, State, Timeout} |
50
+ %% ignore |
51
+ %% {stop, Reason}
52
+ %% Description: Initiates the server
53
+ %%--------------------------------------------------------------------
54
+ init([]) ->
55
+ {ok, #state{}}.
56
+
57
+ %%--------------------------------------------------------------------
58
+ %% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
59
+ %% {reply, Reply, State, Timeout} |
60
+ %% {noreply, State} |
61
+ %% {noreply, State, Timeout} |
62
+ %% {stop, Reason, Reply, State} |
63
+ %% {stop, Reason, State}
64
+ %% Description: Handling call messages
65
+ %%--------------------------------------------------------------------
66
+ handle_call(_Request, _From, State) ->
67
+ Reply = ok,
68
+ {reply, Reply, State}.
69
+
70
+ %%--------------------------------------------------------------------
71
+ %% Function: handle_cast(Msg, State) -> {noreply, State} |
72
+ %% {noreply, State, Timeout} |
73
+ %% {stop, Reason, State}
74
+ %% Description: Handling cast messages
75
+ %%--------------------------------------------------------------------
76
+ handle_cast(_Msg, State) ->
77
+ {noreply, State}.
78
+
79
+ %%--------------------------------------------------------------------
80
+ %% Function: handle_info(Info, State) -> {noreply, State} |
81
+ %% {noreply, State, Timeout} |
82
+ %% {stop, Reason, State}
83
+ %% Description: Handling all non call/cast messages
84
+ %%--------------------------------------------------------------------
85
+ handle_info(_Info, State) ->
86
+ {noreply, State}.
87
+
88
+ %%--------------------------------------------------------------------
89
+ %% Function: terminate(Reason, State) -> void()
90
+ %% Description: This function is called by a gen_server when it is about to
91
+ %% terminate. It should be the opposite of Module:init/1 and do any necessary
92
+ %% cleaning up. When it returns, the gen_server terminates with Reason.
93
+ %% The return value is ignored.
94
+ %%--------------------------------------------------------------------
95
+ terminate(_Reason, _State) ->
96
+ ok.
97
+
98
+ %%--------------------------------------------------------------------
99
+ %% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
100
+ %% Description: Convert process state when code is changed
101
+ %%--------------------------------------------------------------------
102
+ code_change(_OldVsn, State, _Extra) ->
103
+ {ok, State}.
104
+
105
+ %%--------------------------------------------------------------------
106
+ %%% Internal functions
107
+ %%--------------------------------------------------------------------
@@ -0,0 +1,3 @@
1
+ *.beam
2
+ erl_crash.dump
3
+ test/include
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Creates a makefile project with a bootscript generator
3
+
4
+ Usage:
5
+ ./script/generate makefile <name>
@@ -0,0 +1,68 @@
1
+ class MakefileGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ default_options :author => nil
7
+
8
+ attr_reader :app_name, :version
9
+
10
+ def initialize(runtime_args, runtime_options = {})
11
+ super
12
+ usage if args.empty?
13
+ # @app_name = args.shift
14
+ # @destination_root = File.expand_path(".")
15
+ @destination_root = args.shift
16
+ @app_name = File.basename(File.expand_path(@destination_root))
17
+
18
+ @name = base_name
19
+ extract_options
20
+ end
21
+
22
+ def manifest
23
+ record do |m|
24
+ m.template "Makefile", "Makefile"
25
+ m.template "Emakefile", "Emakefile"
26
+ m.directory "ebin"
27
+ m.template "appfile.app.erb", "ebin/#{@app_name}.app"
28
+ m.template "start.sh", "start.sh", { :chmod => 0755 }
29
+ m.directory "src"
30
+ m.template "make_boot.erl.erb", "src/make_boot.erl"
31
+ end
32
+ end
33
+
34
+ protected
35
+ def banner
36
+ <<-EOS
37
+ Creates a makefile project with a bootscript generator
38
+
39
+ USAGE: #{spec.name} name
40
+ EOS
41
+ end
42
+
43
+ def add_options!(opts)
44
+ opts.separator ''
45
+ opts.separator 'Options:'
46
+ # For each option below, place the default
47
+ # at the top of the file next to "default_options"
48
+ # opts.on("-a", "--author=\"Your Name\"", String,
49
+ # "Some comment about this option",
50
+ # "Default: none") { |options[:author]| }
51
+ opts.on("-n", "--name", "Name the app") { |options[:app_name]| }
52
+ opts.on("-d", "--desc", "Description of the app") { |options[:description]| }
53
+ opts.on("-m", "--modules", "Modules used in the application") { |options[:modules]| }
54
+ opts.on("-r", "--registered", "Modules registered in the application") { |options[:registered]| }
55
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
56
+ end
57
+
58
+ def extract_options
59
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
60
+ # Templates can access these value via the attr_reader-generated methods, but not the
61
+ # raw instance variable value.
62
+ # @author = options[:author]
63
+ @description = options[:desc] || "Description of your project"
64
+ @version = options[:version] || "0.1"
65
+ @modules = options[:modules] || "#{@name}_app"
66
+ @registered = options[:registered] || ""
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ { ['./src/*', 'src/*/*', 'src/*/*/*'], [
2
+ {i, "./include"},
3
+ {outdir, "./ebin"},
4
+ debug_info
5
+ ]}.
@@ -0,0 +1,31 @@
1
+ LIBDIR = `erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell`
2
+ VERSION = <%= version -%>
3
+ CC = erlc
4
+ ERL = erl
5
+ EBIN = ebin
6
+ CFLAGS = -I include -pa $(EBIN)
7
+ COMPILE = $(CC) $(CFLAGS) -o $(EBIN)
8
+ EBIN_DIRS = $(wildcard deps/*/ebin)
9
+ WEB_DIR = web/
10
+ APP = <%= app_name %>
11
+
12
+ all: ebin compile boot
13
+
14
+ compile:
15
+ @$(ERL) -pa $(EBIN_DIRS) -noinput +B -eval 'case make:all() of up_to_date -> halt(0); error -> halt(1) end.'
16
+
17
+ edoc:
18
+ @echo Generating $(APP) documentation from srcs
19
+ @$(ERL) -noinput -eval 'edoc:application($(APP), "./", [{doc, "doc/"}, {files, "src/"}])' -s erlang halt
20
+
21
+ boot:
22
+ (cd ebin; erl -pa ebin -noshell -run make_boot write_scripts $(APP))
23
+
24
+ start_all:
25
+ (cd ebin; erl -pa ebin -noshell -boot $(APP))
26
+
27
+ ebin:
28
+ @mkdir ebin
29
+
30
+ clean:
31
+ rm -rf ebin/*.beam ebin/erl_crash.dump erl_crash.dump ebin/*.boot ebin/*.rel ebin/*.script
@@ -0,0 +1,19 @@
1
+ {application, <%= app_name %>,
2
+ [
3
+ % Quick description of the server
4
+ {description, "Description of the application"},
5
+ % Version
6
+ {vsn, "<%= version -%>"},
7
+ % All modules used by the application.
8
+ {modules, []},
9
+ % All the registered names in the application
10
+ {registered, []},
11
+ % These must be started for application to run
12
+ {applications, [kernel, stdlib]},
13
+ % Environment vars
14
+ {env, []},
15
+ % Module and Args used to start
16
+ {mod, {<%= app_name -%>, []}},
17
+ {start_phases, []}
18
+ ]
19
+ }.
@@ -0,0 +1,29 @@
1
+ -module(make_boot).
2
+ -export([write_scripts/1]).
3
+
4
+ write_scripts(Args) ->
5
+ [Name] = Args,
6
+ io:format("write_scripts for ~p~n", [Name]),
7
+ Erts = erlang:system_info(version),
8
+ application:load(sasl),
9
+ Version = "0.1",
10
+ {value, {kernel, _, Kernel}} = lists:keysearch(kernel, 1,
11
+ application:loaded_applications()),
12
+ {value, {stdlib, _, Stdlib}} = lists:keysearch(stdlib, 1,
13
+ application:loaded_applications()),
14
+ {value, {sasl, _, Sasl}} = lists:keysearch(sasl, 1,
15
+ application:loaded_applications()),
16
+
17
+ Rel = "{release, {\"~s\", \"~s\"}, {erts, \"~s\"}, ["
18
+ "{kernel, \"~s\"}, {stdlib, \"~s\"}, {sasl, \"~s\"}, {~s, \"~s\"}]}.",
19
+ Lowername = string:to_lower(Name),
20
+
21
+ Filename = lists:flatten(Lowername ++ ".rel"),
22
+ io:format("Writing to ~p (as ~s)~n", [Filename, Lowername]),
23
+ {ok, Fs} = file:open(Filename, [write]),
24
+
25
+ io:format(Fs, Rel, [Name, Version, Erts, Kernel, Stdlib, Sasl, Lowername, Version]),
26
+ file:close(Fs),
27
+
28
+ systools:make_script(Lowername, [local]),
29
+ halt().
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ # start.sh
3
+ cd `dirname $0`
4
+ erl -pa $PWD/ebin -pa $PWD/deps/*/ebin -name <%= app_name -%> -s reloader -boot <%= app_name -%> $1
@@ -0,0 +1,7 @@
1
+ Description:
2
+
3
+ Create a skeleton erlang directory with eunit tests and config helpers
4
+
5
+ Usage:
6
+
7
+ ./script/generate skeleton <name>
@@ -0,0 +1,91 @@
1
+ require 'rbconfig'
2
+
3
+ class SkeletonGenerator < RubiGen::Base
4
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
5
+ Config::CONFIG['ruby_install_name'])
6
+
7
+ default_options :shebang => DEFAULT_SHEBANG,
8
+ :an_option => 'some_default'
9
+
10
+ attr_reader :app_name, :module_name
11
+
12
+ def initialize(runtime_args, runtime_options = {})
13
+ super
14
+ usage if args.empty?
15
+ @destination_root = args.shift
16
+ @app_name = File.basename(File.expand_path(@destination_root))
17
+ @module_name = app_name.camelize
18
+ extract_options
19
+ end
20
+
21
+ def manifest
22
+ # Use /usr/bin/env if no special shebang was specified
23
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
24
+ windows = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
25
+
26
+ record do |m|
27
+ # Root directory and all subdirectories.
28
+ m.directory ''
29
+ BASEDIRS.each { |path| m.directory path }
30
+
31
+ # Root
32
+ m.template_copy_each %w( Rakefile )
33
+ m.file_copy_each %w( README.txt )
34
+
35
+ # Test helper
36
+ m.template "gitignore", ".gitignore"
37
+
38
+ # Tests
39
+ %w(ebin include src).each do |directory|
40
+ m.directory "test/#{directory}"
41
+ end
42
+
43
+ include_eunit
44
+ include_configerl
45
+
46
+ end
47
+ end
48
+
49
+ def include_eunit
50
+ cmds = [
51
+ "svn co http://svn.process-one.net/contribs/trunk/eunit #{@destination_root}/test/include/eunit",
52
+ "cd #{@destination_root}/test/include/eunit",
53
+ "make"
54
+ ]
55
+ Kernel.system cmds.join(" && ")
56
+ end
57
+ def include_configerl
58
+ cmds = [
59
+ "git submodule add git://github.com/auser/configerl.git #{@destination_root}/deps/configerl",
60
+ "git submodule init",
61
+ "git submodule update"
62
+ ]
63
+ Kernel.system cmds.join(" && ")
64
+ end
65
+
66
+ protected
67
+ def banner
68
+ <<-EOS
69
+ Create a stub for #{File.basename $0} to get started.
70
+
71
+ Usage: #{File.basename $0} /path/to/your/app [options]"
72
+ EOS
73
+ end
74
+
75
+ def add_options!(opts)
76
+ opts.separator ''
77
+ opts.separator "#{File.basename $0} options:"
78
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
79
+ end
80
+
81
+ def extract_options
82
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
83
+ # Templates can access these value via the attr_reader-generated methods, but not the
84
+ # raw instance variable value.
85
+ @author = options[:author]
86
+ @description = options[:desc] || "Description of your project"
87
+ end
88
+
89
+ BASEDIRS = %w(deps doc ebin include priv scripts src support)
90
+ BASEFILES = %w(README.txt Rakefile)
91
+ end
@@ -0,0 +1 @@
1
+ Your app description
@@ -0,0 +1 @@
1
+ require "skelerl"
@@ -0,0 +1,3 @@
1
+ *.beam
2
+ erl_crash.dump
3
+ test/include
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:appfile, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,152 @@
1
+ # modified from http://21ccw.blogspot.com/2008/04/using-rake-for-erlang-unit-testing.html
2
+ require 'rake/clean'
3
+ require 'pp'
4
+
5
+ deps_dir = Dir.pwd + "/deps"
6
+
7
+ INCLUDE = File.dirname(__FILE__) + "/include"
8
+
9
+ DEPS = Dir["#{deps_dir}/*"].select {|d| d if File.directory? d }
10
+ DEPS_FILES = DEPS.map {|d| "./deps/#{File.basename(d)}" }
11
+ EXTRA_ERLC = DEPS_FILES.map {|a| "-pa #{a}/ebin" }.join(" ")
12
+
13
+ ERLC_FLAGS = "-I#{INCLUDE} +warn_unused_vars +warn_unused_import -o ebin -W0 #{EXTRA_ERLC}"
14
+
15
+ SRC = FileList["src/**/*.erl"]
16
+ SRC_OBJ = SRC.pathmap("%{src,ebin}X.beam")
17
+
18
+ DEP = DEPS_FILES.map {|d| FileList["#{d}/src/*.erl"]}
19
+ DEP_OBJ = DEP.map {|d| d.pathmap("%{src,ebin}X.beam")}
20
+
21
+ TEST = FileList['test/src/*.erl']
22
+ TEST_OBJ = TEST.pathmap("%{src,ebin}X.beam")
23
+
24
+ CLEAN.include("ebin/*.beam", "test/ebin/*.beam")
25
+
26
+ directory 'ebin'
27
+ directory 'test/ebin'
28
+
29
+ rule( ".beam" => ["%{ebin,src}X.erl"] ) do |t|
30
+ testing = t.source =~ /test\// ? true : false
31
+ eunit = testing ? "-D EUNIT " : ""
32
+ ebin_dir = testing ? "test/ebin" : "ebin"
33
+ cmd = "erlc #{eunit}-pa ebin -W #{ERLC_FLAGS} -o #{ebin_dir} #{t.source}"
34
+ puts cmd
35
+ sh cmd
36
+ end
37
+
38
+ desc "Compile everything"
39
+ task :compile => ["src:compile", "test:compile"]
40
+ task :recompile => ["clean", "src:compile", "test:compile"]
41
+
42
+ namespace :src do
43
+ desc "Compile src"
44
+ task :compile => ['ebin'] + SRC_OBJ
45
+ end
46
+
47
+ namespace :test do
48
+ desc "Compile tests"
49
+ task :compile => ['test/ebin'] + TEST_OBJ
50
+ end
51
+
52
+ desc "Run all tests"
53
+ task :run_tests => :compile do
54
+ puts "Modules under test:"
55
+ TEST_OBJ.each do |obj|
56
+ obj[%r{.*/(.*).beam}]
57
+ mod = $1
58
+ test_cmd = "erl -pa ebin -pa test/ebin -run #{mod} test -run init stop"
59
+ test_output = `#{test_cmd}`
60
+
61
+ puts test_output if Rake.application.options.trace
62
+
63
+ if /\*failed\*/ =~ test_output
64
+ test_output[/(Failed.*Aborted.*Skipped.*Succeeded.*$)/]
65
+ else
66
+ test_output[/1>\s*(.*)\n/]
67
+ end
68
+
69
+ puts "#{mod}: #{$1}"
70
+ end
71
+ end
72
+
73
+ desc "Clean the beams from the ebin directory"
74
+ task :clean do
75
+ # cmd = "rm #{::File.dirname(__FILE__)}/ebin/*.beam"
76
+ # Kernel.system cmd
77
+ end
78
+
79
+ desc "Recompile the sources"
80
+ task :recompile => [:clean, :compile]
81
+
82
+ desc "Compile with the DEBUG flag set to true"
83
+ task :compile_debug do
84
+ Dir["#{::File.dirname(__FILE__)}/src/*.erl"].each do |t|
85
+ Kernel.system "erlc -pa ebin -W #{ERLC_FLAGS} -Ddebug -o ebin #{t}"
86
+ end
87
+ end
88
+
89
+ desc "Rebuild the boot scripts"
90
+ task :build_boot_scripts => [:recompile] do
91
+ puts "Rebuilding boot scripts"
92
+
93
+ root_dir = ::File.expand_path( ::File.join(::File.dirname(__FILE__)) )
94
+ @version = ENV["VERSION"] || ENV["V"] || "0.1"
95
+ @name = ENV["NAME"] || ::File.basename(::File.dirname( root_dir ))
96
+
97
+ cmd = "erl -pa ./ebin/ -run packager start #{@name} #{@version} -run init stop -noshell"
98
+ Kernel.system cmd
99
+ end
100
+
101
+ desc "Rebuild and repackage"
102
+ task :repackage => [:build_boot_scripts] do
103
+ cmd = "erl -pa ./ebin -s packager start -s init stop"
104
+ Kernel.system cmd
105
+ end
106
+
107
+ desc "Shell command"
108
+ task :shell do
109
+ cmd = "erl -pa ./ebin #{EXTRA_ERLC} -boot start_sasl"
110
+ puts cmd if Rake.application.options.trace
111
+ Kernel.system cmd
112
+ end
113
+
114
+ namespace(:deps) do
115
+ desc "Compile deps"
116
+ task :compile do
117
+ DEPS_FILES.each do |dir|
118
+ Kernel.system "cd #{dir} && rake compile"
119
+ end
120
+ end
121
+
122
+ desc "Update deps/"
123
+ task :update do
124
+ update_cmd = "git remote update && git merge origin/master" # "git fetch && git rebase origin/master"
125
+ DEPS_FILES.each do |dir|
126
+ cmd = "cd #{dir} && #{update_cmd}"
127
+ puts cmd if Rake.application.options.trace
128
+ Kernel.system cmd
129
+ end
130
+ end
131
+
132
+ desc "Update and compile deps/"
133
+ task :up => [:update, :compile]
134
+
135
+ desc "Clean the deps"
136
+ task :clean do
137
+ DEPS_FILES.each do |dir|
138
+ cmd = "cd #{dir}/ebin && rm *.beam"
139
+ puts cmd if Rake.application.options.trace
140
+ Kernel.system cmd
141
+ end
142
+ end
143
+ end
144
+
145
+ desc "Build eunit"
146
+ task :build_eunit do
147
+ cmd = "cd test/include/eunit && make"
148
+ Kernel.system cmd
149
+ end
150
+
151
+ desc "Compile and get a shell"
152
+ task :compile_shell => [:compile, :shell]
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
@@ -0,0 +1,5 @@
1
+ desc "Generate a basic app file"
2
+ task :appfile do
3
+ @name = ENV["NAME"].empty? ? ::File.basename(::File.dirname( root_dir )) : ENV["NAME"]
4
+ Kernel.system "#{::File.dirname(__FILE__)}/../bin/appfile #{@name}"
5
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Generate website files'
2
+ task :website_generate => :ruby_env do
3
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ end
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
+ local_dir = 'website'
13
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ desc 'Generate and upload website files'
17
+ task :website => [:website_generate, :website_upload, :publish_docs]
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skelerl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Ari Lerner
8
+ - Michael Fairchild
9
+ - Nate Murray
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-08-17 00:00:00 -07:00
15
+ default_executable:
16
+ dependencies: []
17
+
18
+ description: Erlang skeleton application
19
+ email: arilerner@mac.com
20
+ executables:
21
+ - gen_server
22
+ - makefile
23
+ - skelerl
24
+ - skelerl-gen_server
25
+ - skelerl-makefile
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - History.txt
30
+ - README.txt
31
+ files:
32
+ - Rakefile
33
+ - VERSION.yml
34
+ - bin/gen_server
35
+ - bin/makefile
36
+ - bin/skelerl
37
+ - bin/skelerl-gen_server
38
+ - bin/skelerl-makefile
39
+ - config/jeweler.rb
40
+ - config/requirements.rb
41
+ - generators/appfile/USAGE
42
+ - generators/appfile/appfile_generator.rb
43
+ - generators/appfile/templates/appfile.app
44
+ - generators/gen_server/USAGE
45
+ - generators/gen_server/gen_server_generator.rb
46
+ - generators/gen_server/templates/README.txt
47
+ - generators/gen_server/templates/Rakefile
48
+ - generators/gen_server/templates/gen_server.erl
49
+ - generators/gen_server/templates/gitignore
50
+ - generators/makefile/USAGE
51
+ - generators/makefile/makefile_generator.rb
52
+ - generators/makefile/templates/Emakefile
53
+ - generators/makefile/templates/Makefile
54
+ - generators/makefile/templates/appfile.app.erb
55
+ - generators/makefile/templates/make_boot.erl.erb
56
+ - generators/makefile/templates/start.sh
57
+ - generators/skeleton/USAGE
58
+ - generators/skeleton/skeleton_generator.rb
59
+ - generators/skeleton/templates/README.txt
60
+ - generators/skeleton/templates/Rakefile
61
+ - generators/skeleton/templates/gitignore
62
+ - script/generate
63
+ - tasks/build.rake
64
+ - tasks/environment.rake
65
+ - tasks/generate.rake
66
+ - tasks/website.rake
67
+ - History.txt
68
+ - README.txt
69
+ has_rdoc: true
70
+ homepage: http://poolpartyrb.com
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --quiet
76
+ - --title
77
+ - Skelerl documentation
78
+ - --line-numbers
79
+ - --main
80
+ - README
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.4
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: The most awesomenest erlang skeleton and generator!
102
+ test_files: []
103
+