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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3522841c64dc34852076206b046951aac9b870f6
4
- data.tar.gz: b4b1ffd015816cd77e9b38bf26a1289b18f1b6a5
3
+ metadata.gz: b61da3dc18d12f004cc34351e6df3f755d33150f
4
+ data.tar.gz: bb4dfcf7f7d8f3782168dc510bb45d19b545b058
5
5
  SHA512:
6
- metadata.gz: f88d6242f94bed2ca1038d7d3e16265de3c10ca1d5ec6d84c315c5849372fdb673bd8dc1d6ccca6c3f8563689315ce3b372bf16c70afe5b8a4e707c4ba9f0795
7
- data.tar.gz: c2b40ca3940b2c15ae6dc1f595ed045ff3c961ce2c1bb49c85f41e40935a8561a71e61ccd7d55723b4eb7786e1acce4ee2694a76999fe63b95ad644fe0aa13f0
6
+ metadata.gz: ef0f292d992a6a91aa586b02018ed9a3b5a414871e5bb51fc5378b668d32984f77da2b3d79586d77f5ba481f9c659fe9455ad41700f5d6981e719a7b6ae24c2a
7
+ data.tar.gz: 94004172d90944fbc2b344569799afdf7039e973370bbce876735f7dae0a8eb104cad894ca4b711375e395bc446c951b2e28797e0af7c339661580133387e52d
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in cronies.gemspec
3
+ # Specify your gem's dependencies in dindi.gemspec
4
4
  gemspec
data/README.rdoc CHANGED
@@ -17,9 +17,9 @@ To view all options
17
17
 
18
18
  == Example
19
19
 
20
- To create a new Sinatra app called 'convore'
20
+ To create a new Sinatra app called 'lelong'
21
21
 
22
- dindi -n convore
22
+ dindi -n lelong
23
23
 
24
24
  == Contributing to dindi
25
25
 
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
- puts "Running 'bundle install --path vendor/bundle' ......."
40
- bundler_result = system("cd #{options.project_absolute_dir}; bundle install --path vendor/bundle")
41
- if bundler_result
42
- puts "passed".green + " bundler install"
43
- else
44
- puts "failed".red + " bundler install"
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
@@ -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 |lib|
25
- options.project_name = lib.downcase
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.
@@ -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" => File.join(project_absolute_dir, 'helpers', 'debug_on.rb'),
49
- "deploy_setting.rb" => File.join(project_absolute_dir, 'configs', 'deploy_setting.rb'),
50
- "docs.haml" => File.join(project_absolute_dir, 'views', 'docs.haml'),
51
- "project_name.rb" => File.join(project_absolute_dir, "#{options.project_name}.rb")
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]
@@ -12,3 +12,4 @@ gem "activesupport"
12
12
  gem "redis"
13
13
  gem "pony"
14
14
  gem "rest-client"
15
+ gem "thin"
@@ -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
- # we use bundler
4
- require 'bundler/setup'
4
+ # App Router
5
+ app = Rack::Builder.new do
5
6
 
6
- # modular sinatra app
7
- require 'sinatra/base'
8
-
9
- # gems
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 <%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>
17
+ run app
@@ -0,0 +1,5 @@
1
+ config = YAML.load_file(File.join(File.dirname(__FILE__), 'database.yml'))
2
+ env = DeploySetting.environment.to_s
3
+
4
+ ActiveRecord::Base.establish_connection(config[env])
5
+ ActiveRecord::Base.include_root_in_json = false
@@ -0,0 +1,8 @@
1
+ class DocsController < Sinatra::Base
2
+
3
+ get '/' do
4
+ protected!
5
+ haml :docs, :layout => false
6
+ end
7
+
8
+ end
@@ -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
@@ -0,0 +1,7 @@
1
+ class MainController < Sinatra::Base
2
+
3
+ get '/' do
4
+ '<h1><%= options.project_name %></h1>'
5
+ end
6
+
7
+ end
data/lib/dindi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dindi
2
- VERSION = "0.7.1"
2
+ VERSION = "1.0"
3
3
  end
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.7.1
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: 2015-01-11 00:00:00.000000000 Z
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/latest/database.yml.erb
62
- - lib/dindi/file_templates/latest/models.rb.erb
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/project_name.rb.erb
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