zync-gen 0.1.0
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/.gitignore +3 -0
- data/Gemfile +3 -0
- data/README.md +0 -0
- data/Rakefile +7 -0
- data/bin/zync +7 -0
- data/lib/zync-gen.rb +3 -0
- data/lib/zync-gen/generators.rb +28 -0
- data/lib/zync-gen/generators/actions.rb +23 -0
- data/lib/zync-gen/generators/app.rb +136 -0
- data/lib/zync-gen/generators/app/templates/Gemfile +4 -0
- data/lib/zync-gen/generators/app/templates/app/controllers/application_controller.rb +3 -0
- data/lib/zync-gen/generators/app/templates/config.ru +4 -0
- data/lib/zync-gen/generators/app/templates/config/application.rb +13 -0
- data/lib/zync-gen/generators/app/templates/config/boot.rb +24 -0
- data/lib/zync-gen/generators/app/templates/config/environment.rb +5 -0
- data/lib/zync-gen/generators/app/templates/config/routes.rb +3 -0
- data/lib/zync-gen/generators/app/templates/config/settings.yml +5 -0
- data/lib/zync-gen/generators/app/templates/script/server +11 -0
- data/lib/zync-gen/generators/base.rb +52 -0
- data/lib/zync-gen/generators/cli.rb +21 -0
- data/lib/zync-gen/generators/named_base.rb +10 -0
- data/lib/zync-gen/version.rb +5 -0
- data/spec/generators/app_spec.rb +5 -0
- data/spec/spec_helper.rb +21 -0
- data/zync-gen.gemspec +27 -0
- metadata +148 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
data/bin/zync
ADDED
data/lib/zync-gen.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Zync
|
2
|
+
module Generators
|
3
|
+
extend self
|
4
|
+
|
5
|
+
autoload :Base, 'zync-gen/generators/base'
|
6
|
+
autoload :Actions, 'zync-gen/generators/actions'
|
7
|
+
autoload :NamedBase, 'zync-gen/generators/named_base'
|
8
|
+
|
9
|
+
|
10
|
+
##
|
11
|
+
# Return a ordered list of task with their class
|
12
|
+
#
|
13
|
+
def mappings
|
14
|
+
@_mappings ||= {}
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# Add a generator
|
19
|
+
#
|
20
|
+
def add_generator(name, klass)
|
21
|
+
mappings[name] = klass
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'zync-gen/generators/app'
|
28
|
+
require 'zync-gen/generators/cli'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Zync
|
4
|
+
module Generators
|
5
|
+
module Actions
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
# Tell to zync that for this Thor::Group is necessary a task to run
|
11
|
+
def require_arguments!
|
12
|
+
@require_arguments = true
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return true if we need an arguments for our Thor::Group
|
16
|
+
def require_arguments?
|
17
|
+
@require_arguments
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end # Generators
|
23
|
+
end # Zync
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module Zync
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class AppBuilder
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
def initialize(generator)
|
8
|
+
@generator = generator
|
9
|
+
@options = generator.options
|
10
|
+
end
|
11
|
+
|
12
|
+
def app
|
13
|
+
directory 'app'
|
14
|
+
end
|
15
|
+
|
16
|
+
def config
|
17
|
+
empty_directory "config"
|
18
|
+
|
19
|
+
inside "config" do
|
20
|
+
template "application.rb"
|
21
|
+
template "boot.rb"
|
22
|
+
template "environment.rb"
|
23
|
+
empty_directory "environments"
|
24
|
+
empty_directory "initializers"
|
25
|
+
template "routes.rb"
|
26
|
+
template 'settings.yml'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def configru
|
31
|
+
template "config.ru"
|
32
|
+
end
|
33
|
+
|
34
|
+
def gemfile
|
35
|
+
template "Gemfile"
|
36
|
+
end
|
37
|
+
|
38
|
+
def lib
|
39
|
+
empty_directory 'lib'
|
40
|
+
end
|
41
|
+
|
42
|
+
def log
|
43
|
+
empty_directory 'log'
|
44
|
+
|
45
|
+
inside "log" do
|
46
|
+
%w( server production development test ).each do |file|
|
47
|
+
create_file "#{file}.log"
|
48
|
+
chmod "#{file}.log", 0666, :verbose => false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def script
|
54
|
+
directory 'script'
|
55
|
+
chmod "script", 0755, :verbose => false
|
56
|
+
end
|
57
|
+
|
58
|
+
def tmp
|
59
|
+
empty_directory 'tmp'
|
60
|
+
end
|
61
|
+
|
62
|
+
def vendor
|
63
|
+
empty_directory 'vendor'
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def method_missing(meth, *args, &block)
|
69
|
+
@generator.send(meth, *args, &block)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
class AppGenerator < NamedBase
|
75
|
+
Zync::Generators.add_generator(:new, self)
|
76
|
+
|
77
|
+
def create_root
|
78
|
+
self.destination_root = File.expand_path(name, destination_root)
|
79
|
+
empty_directory '.'
|
80
|
+
FileUtils.cd(destination_root)
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_root_files
|
84
|
+
build(:configru)
|
85
|
+
build(:gemfile)
|
86
|
+
end
|
87
|
+
|
88
|
+
def create_app_files
|
89
|
+
build(:app)
|
90
|
+
end
|
91
|
+
|
92
|
+
def create_config_files
|
93
|
+
build(:config)
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_lib_files
|
97
|
+
build(:lib)
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_log_files
|
101
|
+
build(:log)
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_script_files
|
105
|
+
build(:script)
|
106
|
+
end
|
107
|
+
|
108
|
+
def create_tmp_files
|
109
|
+
build(:tmp)
|
110
|
+
end
|
111
|
+
|
112
|
+
def create_vendor_files
|
113
|
+
build(:vendor)
|
114
|
+
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
|
118
|
+
def app_const_base
|
119
|
+
@app_const_base ||= name.gsub(/\W/, '_').squeeze('_').camelize
|
120
|
+
end
|
121
|
+
|
122
|
+
def app_const
|
123
|
+
@app_const ||= "#{app_const_base}::Application"
|
124
|
+
end
|
125
|
+
|
126
|
+
def builder
|
127
|
+
@builder ||= AppBuilder.new(self)
|
128
|
+
end
|
129
|
+
|
130
|
+
def build(meth, *args)
|
131
|
+
builder.send(meth, *args) if builder.respond_to?(meth)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
end # Generators
|
136
|
+
end # Zync
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Load Zync framework:
|
4
|
+
require 'zync'
|
5
|
+
|
6
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
7
|
+
# you've limited to :test, :development, or :production.
|
8
|
+
Bundler.require(:default) if defined?(Bundler)
|
9
|
+
|
10
|
+
module <%= app_const_base %>
|
11
|
+
class Application < Zync::Application
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
ZYNC_ROOT = File.expand_path('../../', __FILE__)
|
4
|
+
|
5
|
+
# Set up gems listed in the Gemfile.
|
6
|
+
gemfile = "#{ZYNC_ROOT}/Gemfile"
|
7
|
+
begin
|
8
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
9
|
+
require 'bundler'
|
10
|
+
Bundler.setup
|
11
|
+
rescue Bundler::GemNotFound => e
|
12
|
+
STDERR.puts e.message
|
13
|
+
STDERR.puts "Try running `bundle install`."
|
14
|
+
exit!
|
15
|
+
end if File.exist?(gemfile)
|
16
|
+
|
17
|
+
# Load libraries in the vendor directory
|
18
|
+
vendor_path = "#{ZYNC_ROOT}/vendor"
|
19
|
+
Dir.entries(vendor_path).each do |vendor|
|
20
|
+
vendor_lib = "#{vendor_path}/#{vendor}/lib"
|
21
|
+
if File.directory?(vendor_lib) && vendor != '..'
|
22
|
+
$:.unshift vendor_lib
|
23
|
+
end
|
24
|
+
end if File.exists?(vendor_path)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
begin
|
2
|
+
require 'thor/group'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Thor is not available"
|
5
|
+
exit
|
6
|
+
end
|
7
|
+
|
8
|
+
module Zync
|
9
|
+
module Generators
|
10
|
+
|
11
|
+
class Error < Thor::Error
|
12
|
+
end
|
13
|
+
|
14
|
+
class Base < Thor::Group
|
15
|
+
include Thor::Actions
|
16
|
+
include Zync::Generators::Actions
|
17
|
+
|
18
|
+
# Returns the base root for a common set of generators.
|
19
|
+
def self.base_root
|
20
|
+
File.dirname(__FILE__)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the source root for this generator
|
24
|
+
def self.source_root(path=nil)
|
25
|
+
@_source_root = path if path
|
26
|
+
@_source_root ||= default_source_root
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the default source root for a given generator.
|
30
|
+
def self.default_source_root
|
31
|
+
return unless generator_name
|
32
|
+
path = File.expand_path(File.join(generator_name, 'templates'), base_root)
|
33
|
+
path if File.exists?(path)
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
# Removes the namespaces and get the generator name. For example,
|
39
|
+
# Zync::Generators::ModelGenerator will return "model" as generator name.
|
40
|
+
#
|
41
|
+
def self.generator_name
|
42
|
+
@generator_name ||= begin
|
43
|
+
if generator = name.to_s.split('::').last
|
44
|
+
generator.sub!(/Generator$/, '')
|
45
|
+
generator.underscore
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end # Generators
|
52
|
+
end #Zync
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Zync
|
2
|
+
module Generators
|
3
|
+
class Cli < Thor::Group
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
def setup
|
7
|
+
generator_kind = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0].present?
|
8
|
+
generator_class = Zync::Generators.mappings[generator_kind]
|
9
|
+
|
10
|
+
if generator_class
|
11
|
+
args = ARGV.empty? && generator_class.require_arguments? ? ["-h"] : ARGV
|
12
|
+
generator_class.start(args)
|
13
|
+
else
|
14
|
+
puts "FAIL"
|
15
|
+
# TODO: specify generators
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end # Generators
|
21
|
+
end # Zync
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
rescue LoadError => e
|
5
|
+
# Fall back on doing an unlocked resolve at runtime.
|
6
|
+
STDERR.puts e.message
|
7
|
+
STDERR.puts "Try running `bundle install`."
|
8
|
+
exit!
|
9
|
+
end
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
|
14
|
+
require 'zync-gen'
|
15
|
+
require 'rspec'
|
16
|
+
|
17
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.mock_with :rspec
|
21
|
+
end
|
data/zync-gen.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "zync-gen/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "zync-gen"
|
7
|
+
s.version = Zync::Generators::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Peter Kieltyka", "Kevin Faustino"]
|
10
|
+
s.email = ["kevin.faustino@nulayer.com"]
|
11
|
+
s.homepage = "http://github.com/nulayer/zync"
|
12
|
+
s.summary = %q{Generators for Zync}
|
13
|
+
s.description = %q{A Collection of generators for the Zync Web Framework}
|
14
|
+
|
15
|
+
s.rubyforge_project = "zync-gen"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency("thor", ["~> 0.14.6"])
|
23
|
+
s.add_dependency("activesupport", ["~> 3.0.3"])
|
24
|
+
s.add_dependency("i18n")
|
25
|
+
|
26
|
+
s.add_development_dependency("rspec", ["~> 2.3.0"])
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zync-gen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Peter Kieltyka
|
13
|
+
- Kevin Faustino
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-14 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thor
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 14
|
32
|
+
- 6
|
33
|
+
version: 0.14.6
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 3
|
46
|
+
- 0
|
47
|
+
- 3
|
48
|
+
version: 3.0.3
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: i18n
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: rspec
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 2
|
74
|
+
- 3
|
75
|
+
- 0
|
76
|
+
version: 2.3.0
|
77
|
+
type: :development
|
78
|
+
version_requirements: *id004
|
79
|
+
description: A Collection of generators for the Zync Web Framework
|
80
|
+
email:
|
81
|
+
- kevin.faustino@nulayer.com
|
82
|
+
executables:
|
83
|
+
- zync
|
84
|
+
extensions: []
|
85
|
+
|
86
|
+
extra_rdoc_files: []
|
87
|
+
|
88
|
+
files:
|
89
|
+
- .gitignore
|
90
|
+
- Gemfile
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- bin/zync
|
94
|
+
- lib/zync-gen.rb
|
95
|
+
- lib/zync-gen/generators.rb
|
96
|
+
- lib/zync-gen/generators/actions.rb
|
97
|
+
- lib/zync-gen/generators/app.rb
|
98
|
+
- lib/zync-gen/generators/app/templates/Gemfile
|
99
|
+
- lib/zync-gen/generators/app/templates/app/controllers/application_controller.rb
|
100
|
+
- lib/zync-gen/generators/app/templates/config.ru
|
101
|
+
- lib/zync-gen/generators/app/templates/config/application.rb
|
102
|
+
- lib/zync-gen/generators/app/templates/config/boot.rb
|
103
|
+
- lib/zync-gen/generators/app/templates/config/environment.rb
|
104
|
+
- lib/zync-gen/generators/app/templates/config/routes.rb
|
105
|
+
- lib/zync-gen/generators/app/templates/config/settings.yml
|
106
|
+
- lib/zync-gen/generators/app/templates/script/server
|
107
|
+
- lib/zync-gen/generators/base.rb
|
108
|
+
- lib/zync-gen/generators/cli.rb
|
109
|
+
- lib/zync-gen/generators/named_base.rb
|
110
|
+
- lib/zync-gen/version.rb
|
111
|
+
- spec/generators/app_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
- zync-gen.gemspec
|
114
|
+
has_rdoc: true
|
115
|
+
homepage: http://github.com/nulayer/zync
|
116
|
+
licenses: []
|
117
|
+
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
139
|
+
requirements: []
|
140
|
+
|
141
|
+
rubyforge_project: zync-gen
|
142
|
+
rubygems_version: 1.3.7
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: Generators for Zync
|
146
|
+
test_files:
|
147
|
+
- spec/generators/app_spec.rb
|
148
|
+
- spec/spec_helper.rb
|