dindi 0.7.1 → 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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.rdoc +2 -2
- data/bin/dindi +9 -6
- data/lib/dindi/command_parser.rb +7 -2
- data/lib/dindi/file_helper.rb +8 -4
- data/lib/dindi/file_templates/latest/Gemfile.erb +1 -0
- data/lib/dindi/file_templates/latest/README.erb +18 -0
- data/lib/dindi/file_templates/latest/config.ru.erb +12 -47
- data/lib/dindi/file_templates/shared/active_record_setting.rb.erb +5 -0
- data/lib/dindi/file_templates/{latest → shared}/database.yml.erb +0 -0
- data/lib/dindi/file_templates/shared/docs_controller.rb.erb +8 -0
- data/lib/dindi/file_templates/shared/initializer.rb.erb +49 -0
- data/lib/dindi/file_templates/shared/main_controller.rb.erb +7 -0
- data/lib/dindi/version.rb +1 -1
- metadata +8 -5
- data/lib/dindi/file_templates/latest/models.rb.erb +0 -14
- data/lib/dindi/file_templates/shared/project_name.rb.erb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b61da3dc18d12f004cc34351e6df3f755d33150f
|
4
|
+
data.tar.gz: bb4dfcf7f7d8f3782168dc510bb45d19b545b058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0f292d992a6a91aa586b02018ed9a3b5a414871e5bb51fc5378b668d32984f77da2b3d79586d77f5ba481f9c659fe9455ad41700f5d6981e719a7b6ae24c2a
|
7
|
+
data.tar.gz: 94004172d90944fbc2b344569799afdf7039e973370bbce876735f7dae0a8eb104cad894ca4b711375e395bc446c951b2e28797e0af7c339661580133387e52d
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
data/bin/dindi
CHANGED
@@ -36,10 +36,13 @@ Dindi::FileHelper.copy_file_templates(options)
|
|
36
36
|
# Completion
|
37
37
|
puts "Your project folder #{options.project_name} was successfully created".green
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
# Optional steps
|
40
|
+
if options.with_bundle_install
|
41
|
+
puts "Running 'bundle install --path vendor/bundle' ......."
|
42
|
+
bundler_result = system("cd #{options.project_absolute_dir}; bundle install --path vendor/bundle")
|
43
|
+
if bundler_result
|
44
|
+
puts "passed".green + " bundler install"
|
45
|
+
else
|
46
|
+
puts "failed".red + " bundler install"
|
47
|
+
end
|
45
48
|
end
|
data/lib/dindi/command_parser.rb
CHANGED
@@ -13,6 +13,7 @@ module Dindi
|
|
13
13
|
#
|
14
14
|
# We set the default value here
|
15
15
|
options.project_name = nil
|
16
|
+
options.with_bundle_install = false
|
16
17
|
|
17
18
|
opts = OptionParser.new do |opts|
|
18
19
|
opts.banner = "Usage: dindi [options]"
|
@@ -21,8 +22,12 @@ module Dindi
|
|
21
22
|
opts.separator "Specific options:"
|
22
23
|
|
23
24
|
opts.on("-n", "--name PROJECT_NAME",
|
24
|
-
"Specify your project name PROJECT_NAME that will be created") do |
|
25
|
-
options.project_name =
|
25
|
+
"Specify your project name PROJECT_NAME that will be created") do |project_name|
|
26
|
+
options.project_name = project_name.downcase
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-b", "--[no-]bundle-install", "Run bundler install after project creation") do |b|
|
30
|
+
options.with_bundle_install = b
|
26
31
|
end
|
27
32
|
|
28
33
|
# No argument, shows at tail. This will print an options summary.
|
data/lib/dindi/file_helper.rb
CHANGED
@@ -45,10 +45,14 @@ module Dindi
|
|
45
45
|
project_absolute_dir = options.project_absolute_dir
|
46
46
|
|
47
47
|
# copy location for not common template files
|
48
|
-
special_location_hash = {"debug_on.rb"
|
49
|
-
"deploy_setting.rb"
|
50
|
-
"
|
51
|
-
"
|
48
|
+
special_location_hash = {"debug_on.rb" => File.join(project_absolute_dir, 'helpers', 'debug_on.rb'),
|
49
|
+
"deploy_setting.rb" => File.join(project_absolute_dir, 'configs', 'deploy_setting.rb'),
|
50
|
+
"database.yml" => File.join(project_absolute_dir, 'configs', 'database.yml'),
|
51
|
+
"active_record_setting.rb" => File.join(project_absolute_dir, 'configs', 'active_record_setting.rb'),
|
52
|
+
"initializer.rb" => File.join(project_absolute_dir, 'configs', 'initializer.rb'),
|
53
|
+
"docs.haml" => File.join(project_absolute_dir, 'views', 'docs.haml'),
|
54
|
+
"docs_controller.rb" => File.join(project_absolute_dir, 'routes', 'docs_controller.rb'),
|
55
|
+
"main_controller.rb" => File.join(project_absolute_dir, 'routes', 'main_controller.rb')
|
52
56
|
}
|
53
57
|
|
54
58
|
if special_location_hash[filename]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>
|
2
|
+
|
3
|
+
## Install Required Gems
|
4
|
+
|
5
|
+
In the project root directory run:
|
6
|
+
$ bundle install --path vendor/bundle
|
7
|
+
|
8
|
+
## Running Thin
|
9
|
+
|
10
|
+
In the project root directory run:
|
11
|
+
$ bundle exec thin start -a 0.0.0.0 -p 3000 -R config.ru -e production
|
12
|
+
|
13
|
+
## Debugging code in IRB
|
14
|
+
|
15
|
+
In the project root directory run:
|
16
|
+
$ bundle exec irb
|
17
|
+
irb> require_relative 'configs/initializer'
|
18
|
+
|
@@ -1,52 +1,17 @@
|
|
1
|
-
|
1
|
+
# Main initializer to load required libraries
|
2
|
+
require_relative 'configs/initializer'
|
2
3
|
|
3
|
-
#
|
4
|
-
|
4
|
+
# App Router
|
5
|
+
app = Rack::Builder.new do
|
5
6
|
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
%w(logger json haml digest date time yaml).each {|gem| require gem}
|
11
|
-
|
12
|
-
# load app config
|
13
|
-
Dir.glob("./configs/*.rb").each {|config| require config}
|
14
|
-
|
15
|
-
# load db config and models
|
16
|
-
require 'models'
|
17
|
-
|
18
|
-
# helpers
|
19
|
-
Dir.glob("./helpers/*.rb").each {|helper| require helper}
|
20
|
-
|
21
|
-
# external library
|
22
|
-
Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
|
23
|
-
|
24
|
-
# controllers
|
25
|
-
Dir.glob("./routes/*.rb").each {|route| require route}
|
26
|
-
|
27
|
-
# app file
|
28
|
-
require '<%= options.project_name %>'
|
29
|
-
|
30
|
-
class Sinatra::Base
|
31
|
-
# helpers
|
32
|
-
include DebugOn
|
33
|
-
|
34
|
-
# set sinatra's variables
|
35
|
-
set :app_name, "<%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>"
|
36
|
-
set :app_logger, ::Logger.new(File.join(File.dirname(__FILE__), 'log', "<%= options.project_name %>.log"))
|
37
|
-
set :root, File.dirname(__FILE__)
|
38
|
-
set :environment, DeploySetting.environment
|
39
|
-
|
40
|
-
if settings.environment == :production
|
41
|
-
enable :sessions, :logging, :dump_errors
|
42
|
-
disable :run, :reload, :show_exceptions
|
43
|
-
# set :redis, Redis.new(:db => 2)
|
44
|
-
else
|
45
|
-
enable :sessions, :logging, :dump_errors, :show_exceptions
|
46
|
-
disable :run, :reload
|
47
|
-
# set :redis, Redis.new(:db => 15)
|
48
|
-
end
|
7
|
+
# CMS
|
8
|
+
# map "/cms" do
|
9
|
+
# map("/") {run CmsController.new }
|
10
|
+
# end
|
49
11
|
|
12
|
+
map("/docs") {run DocsController.new }
|
13
|
+
map("/") {run MainController.new }
|
14
|
+
|
50
15
|
end
|
51
16
|
|
52
|
-
run
|
17
|
+
run app
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# base
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'sinatra/base'
|
4
|
+
|
5
|
+
# gems
|
6
|
+
require 'logger'
|
7
|
+
require 'json'
|
8
|
+
require 'haml'
|
9
|
+
require 'digest'
|
10
|
+
require 'date'
|
11
|
+
require 'time'
|
12
|
+
require 'yaml'
|
13
|
+
require 'mysql2'
|
14
|
+
require 'active_record'
|
15
|
+
|
16
|
+
# configs
|
17
|
+
require_relative 'deploy_setting'
|
18
|
+
require_relative 'active_record_setting'
|
19
|
+
|
20
|
+
$root_path = File.join(File.dirname(__FILE__), '..')
|
21
|
+
|
22
|
+
['helpers', 'extlibs', 'models', 'routes'].each do |dir_name|
|
23
|
+
dir_path = File.join($root_path, dir_name, '*.rb')
|
24
|
+
Dir.glob(dir_path).each do |file|
|
25
|
+
require file
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Sinatra::Base
|
30
|
+
# helpers
|
31
|
+
include DebugOn
|
32
|
+
|
33
|
+
# set sinatra's variables
|
34
|
+
set :app_name, "<%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>"
|
35
|
+
set :app_logger, Logger.new(File.join($root_path, 'log', "<%= options.project_name %>.log"), 'daily')
|
36
|
+
set :root, $root_path
|
37
|
+
set :environment, DeploySetting.environment
|
38
|
+
|
39
|
+
if settings.environment == :production
|
40
|
+
enable :sessions, :logging, :dump_errors
|
41
|
+
disable :run, :reload, :show_exceptions
|
42
|
+
# set :redis, Redis.new(:db => 2)
|
43
|
+
else
|
44
|
+
enable :sessions, :logging, :dump_errors, :show_exceptions
|
45
|
+
disable :run, :reload
|
46
|
+
# set :redis, Redis.new(:db => 15)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/dindi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dindi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Chandra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,13 +57,16 @@ files:
|
|
57
57
|
- lib/dindi/command_parser.rb
|
58
58
|
- lib/dindi/file_helper.rb
|
59
59
|
- lib/dindi/file_templates/latest/Gemfile.erb
|
60
|
+
- lib/dindi/file_templates/latest/README.erb
|
60
61
|
- lib/dindi/file_templates/latest/config.ru.erb
|
61
|
-
- lib/dindi/file_templates/
|
62
|
-
- lib/dindi/file_templates/
|
62
|
+
- lib/dindi/file_templates/shared/active_record_setting.rb.erb
|
63
|
+
- lib/dindi/file_templates/shared/database.yml.erb
|
63
64
|
- lib/dindi/file_templates/shared/debug_on.rb.erb
|
64
65
|
- lib/dindi/file_templates/shared/deploy_setting.rb.erb
|
65
66
|
- lib/dindi/file_templates/shared/docs.haml.erb
|
66
|
-
- lib/dindi/file_templates/shared/
|
67
|
+
- lib/dindi/file_templates/shared/docs_controller.rb.erb
|
68
|
+
- lib/dindi/file_templates/shared/initializer.rb.erb
|
69
|
+
- lib/dindi/file_templates/shared/main_controller.rb.erb
|
67
70
|
- lib/dindi/version.rb
|
68
71
|
homepage: http://github.com/samchandra/dindi
|
69
72
|
licenses:
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'mysql2'
|
2
|
-
require 'active_record'
|
3
|
-
|
4
|
-
config = YAML.load_file(File.join(File.dirname(__FILE__), 'database.yml'))
|
5
|
-
|
6
|
-
if DeploySetting.environment == :production
|
7
|
-
ActiveRecord::Base.establish_connection(config["production"])
|
8
|
-
else
|
9
|
-
ActiveRecord::Base.establish_connection(config["development"])
|
10
|
-
end
|
11
|
-
|
12
|
-
ActiveRecord::Base.include_root_in_json = false
|
13
|
-
|
14
|
-
Dir.glob(File.join(File.dirname(__FILE__), "models", "*.rb")).each {|model| require model}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class <%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %> < Sinatra::Base
|
2
|
-
|
3
|
-
# Routes
|
4
|
-
# use Cms
|
5
|
-
|
6
|
-
# index
|
7
|
-
get '/' do
|
8
|
-
'<%= options.project_name %>'
|
9
|
-
end
|
10
|
-
|
11
|
-
# docs
|
12
|
-
get '/docs' do
|
13
|
-
protected!
|
14
|
-
haml :docs, :layout => false
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|