auser-skelerl 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +7 -3
- data/VERSION.yml +4 -0
- data/bin/gen_server +0 -0
- data/bin/makefile +17 -0
- data/bin/skelerl +55 -12
- data/bin/skelerl-gen_server +29 -0
- data/bin/skelerl-makefile +29 -0
- data/config/jeweler.rb +41 -0
- data/generators/gen_server/USAGE +3 -3
- data/generators/gen_server/gen_server_generator.rb +36 -22
- data/generators/gen_server/templates/README.txt +1 -0
- data/generators/gen_server/templates/Rakefile +1 -0
- data/generators/gen_server/templates/gen_server.erl +107 -0
- data/generators/gen_server/templates/gitignore +3 -0
- data/generators/makefile/USAGE +5 -0
- data/generators/makefile/makefile_generator.rb +68 -0
- data/generators/makefile/templates/Emakefile +5 -0
- data/generators/makefile/templates/Makefile +31 -0
- data/{ebin/packager.app → generators/makefile/templates/appfile.app.erb} +6 -6
- data/generators/makefile/templates/make_boot.erl.erb +29 -0
- data/generators/makefile/templates/start.sh +4 -0
- data/generators/skeleton/skeleton_generator.rb +2 -0
- data/generators/skeleton/templates/Rakefile +2 -1
- data/generators/skeleton/templates/gitignore +15 -1
- data/script/generate +1 -1
- data/tasks/build.rake +97 -5
- metadata +41 -48
- data/Manifest.txt +0 -43
- data/config/hoe.rb +0 -73
- data/examples/example_runner.rb +0 -24
- data/include/empty +0 -0
- data/lib/skelerl.rb +0 -22
- data/lib/skelerl/core/object.rb +0 -27
- data/lib/skelerl/erlpers/core/array.rb +0 -10
- data/lib/skelerl/erlpers/core/object.rb +0 -34
- data/lib/skelerl/erlpers/erl_mapper.rb +0 -70
- data/lib/skelerl/erlpers/mappers/command.rb +0 -13
- data/lib/skelerl/erlpers/mappers/context.rb +0 -39
- data/lib/skelerl/erlpers/mappers/namespace.rb +0 -8
- data/lib/skelerl/init.rb +0 -3
- data/setup.rb +0 -1585
- data/skelerl.gemspec +0 -36
- data/src/packager.erl +0 -75
- data/tasks/deployment.rake +0 -43
- data/test/erlpers/erl_mapper_spec.rb +0 -113
- data/test/erlpers/object_spec.rb +0 -26
- data/test/helper.rb +0 -10
data/Rakefile
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
require 'config/requirements'
|
2
|
+
|
1
3
|
begin
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
4
|
+
require 'hanna/rdoctask'
|
5
|
+
rescue LoadError => e
|
6
|
+
require "rake/rdoctask"
|
5
7
|
end
|
6
8
|
|
9
|
+
require 'config/jeweler' # setup gem configuration
|
10
|
+
|
7
11
|
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
data/VERSION.yml
ADDED
data/bin/gen_server
CHANGED
File without changes
|
data/bin/makefile
ADDED
@@ -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')
|
data/bin/skelerl
CHANGED
@@ -1,17 +1,60 @@
|
|
1
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'
|
2
6
|
|
3
|
-
|
4
|
-
|
5
|
-
|
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]
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
10
33
|
end
|
11
34
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
data/config/jeweler.rb
ADDED
@@ -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
|
data/generators/gen_server/USAGE
CHANGED
@@ -1,51 +1,65 @@
|
|
1
|
-
|
1
|
+
require 'rbconfig'
|
2
2
|
|
3
|
+
class GenServerGenerator < RubiGen::Base
|
3
4
|
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
5
|
Config::CONFIG['ruby_install_name'])
|
5
|
-
|
6
|
-
default_options
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
|
7
|
+
default_options :shebang => DEFAULT_SHEBANG,
|
8
|
+
:an_option => 'some_default'
|
9
|
+
|
10
|
+
attr_reader :app_name, :module_name
|
11
|
+
|
10
12
|
def initialize(runtime_args, runtime_options = {})
|
11
13
|
super
|
12
14
|
usage if args.empty?
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
15
|
+
@destination_root = args.shift
|
16
|
+
@app_name = File.basename(File.expand_path(@destination_root))
|
17
|
+
@module_name = app_name.camelize
|
16
18
|
extract_options
|
17
19
|
end
|
18
|
-
|
20
|
+
|
19
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
|
+
|
20
26
|
record do |m|
|
21
|
-
m.
|
27
|
+
m.directory File.join("src")
|
28
|
+
m.template "gen_server.erl", "src/#{gen_server_file_name}"
|
22
29
|
end
|
23
30
|
end
|
24
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
|
+
|
25
40
|
protected
|
26
41
|
def banner
|
27
42
|
<<-EOS
|
28
|
-
|
43
|
+
Create a stub for #{File.basename $0} to get started.
|
29
44
|
|
30
|
-
|
45
|
+
Usage: #{File.basename $0} gen_server_name [options]"
|
31
46
|
EOS
|
32
47
|
end
|
33
48
|
|
34
49
|
def add_options!(opts)
|
35
50
|
opts.separator ''
|
36
|
-
opts.separator
|
37
|
-
# For each option below, place the default
|
38
|
-
# at the top of the file next to "default_options"
|
39
|
-
# opts.on("-a", "--author=\"Your Name\"", String,
|
40
|
-
# "Some comment about this option",
|
41
|
-
# "Default: none") { |options[:author]| }
|
51
|
+
opts.separator "#{File.basename $0} options:"
|
42
52
|
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
43
53
|
end
|
44
|
-
|
54
|
+
|
45
55
|
def extract_options
|
46
56
|
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
47
57
|
# Templates can access these value via the attr_reader-generated methods, but not the
|
48
58
|
# raw instance variable value.
|
49
|
-
|
59
|
+
@author = options[:author]
|
60
|
+
@description = options[:desc] || "Description of your project"
|
50
61
|
end
|
51
|
-
|
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(Args) ->
|
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
|
+
%%--------------------------------------------------------------------
|