dindi 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/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "activesupport", "= 2.3.8"
6
+ gem "activerecord", "=2.3.8"
7
+ gem "sinatra", ">= 0"
8
+ gem "json", ">= 0"
9
+ gem "haml", ">= 0"
10
+ gem "pony", ">= 0"
11
+
12
+ # Add dependencies to develop your gem here.
13
+ # Include everything needed to run rake, tests, features, etc.
14
+ group :development do
15
+ gem "shoulda", ">= 0"
16
+ gem "bundler", "~> 1.0.0"
17
+ gem "jeweler", "~> 1.6.4"
18
+ gem "rcov", ">= 0"
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activerecord (2.3.8)
5
+ activesupport (= 2.3.8)
6
+ activesupport (2.3.8)
7
+ git (1.2.5)
8
+ haml (3.1.3)
9
+ i18n (0.6.0)
10
+ jeweler (1.6.4)
11
+ bundler (~> 1.0)
12
+ git (>= 1.2.5)
13
+ rake
14
+ json (1.6.1)
15
+ mail (2.3.0)
16
+ i18n (>= 0.4.0)
17
+ mime-types (~> 1.16)
18
+ treetop (~> 1.4.8)
19
+ mime-types (1.16)
20
+ polyglot (0.3.2)
21
+ pony (1.3)
22
+ mail (> 2.0)
23
+ rack (1.3.3)
24
+ rake (0.9.2)
25
+ rcov (0.9.10)
26
+ shoulda (2.11.3)
27
+ sinatra (1.2.6)
28
+ rack (~> 1.1)
29
+ tilt (>= 1.2.2, < 2.0)
30
+ tilt (1.3.3)
31
+ treetop (1.4.10)
32
+ polyglot
33
+ polyglot (>= 0.3.1)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ activerecord (= 2.3.8)
40
+ activesupport (= 2.3.8)
41
+ bundler (~> 1.0.0)
42
+ haml
43
+ jeweler (~> 1.6.4)
44
+ json
45
+ pony
46
+ rcov
47
+ shoulda
48
+ sinatra
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Samuel Chandra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = dindi
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to dindi
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Samuel Chandra. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "dindi"
18
+ gem.homepage = "http://github.com/schandra/dindi"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Dindi is a hit of Sinatra}
21
+ gem.description = %Q{This gem will create a barebone base for a new Sinatra Project}
22
+ gem.email = "samuelchandra@yahoo.com"
23
+ gem.authors = ["Samuel Chandra"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "dindi #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/dindi ADDED
@@ -0,0 +1,225 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # script to automate creation of new sinatra project
4
+ require 'ostruct'
5
+ require 'optparse'
6
+ require 'fileutils'
7
+
8
+ class OptionParser
9
+
10
+ def self.parse(args)
11
+ # The options specified on the command line will be collected in *options*.
12
+ # We set the default value here
13
+ options = OpenStruct.new
14
+ options.project_name = nil
15
+
16
+ opts = OptionParser.new do |opts|
17
+ opts.banner = "Usage: dindi.rb [options]"
18
+
19
+ opts.separator " "
20
+ opts.separator "Specific options:"
21
+
22
+ # mandatory argument project directory
23
+ opts.on("-n", "--name PROJECT_NAME",
24
+ "Specify your project name PROJECT_NAME that will be created") do |lib|
25
+ options.project_name = lib
26
+ end
27
+
28
+ # No argument, shows at tail. This will print an options summary.
29
+ # Try it and see!
30
+ opts.on_tail("-h", "--help", "Show this message") do
31
+ puts opts
32
+ exit
33
+ end
34
+
35
+ end
36
+
37
+ opts.parse!(args)
38
+ options
39
+ end
40
+
41
+ end
42
+
43
+ # make sure ARGV has values
44
+ if ARGV.size == 0
45
+ puts "ERROR: Parameters needed. Run with -h to view options"
46
+ exit
47
+ end
48
+
49
+ # parse option from command line
50
+ options = OptionParser.parse(ARGV)
51
+
52
+ # make sure project name is valid
53
+ if options.project_name.nil?
54
+ puts "ERROR: PROJECT_NAME is needed. Run with -h to view options"
55
+ exit
56
+ end
57
+
58
+ project_absolute_dir = FileUtils.pwd + "/" + options.project_name
59
+
60
+ # create default directories
61
+ # lib, log, public, push, routes, tmp, views
62
+ %w(lib log public push routes tmp views db).each do |dir|
63
+ FileUtils.mkdir_p(project_absolute_dir + "/" + dir)
64
+ end
65
+
66
+ #=================
67
+ # create config.ru
68
+ #=================
69
+
70
+ config_ru_contents = <<-config_ru
71
+ # gems
72
+ %w(sinatra logger json haml csv digest pony date time activesupport).each {|lib| require lib}
73
+
74
+ # extra library
75
+ # require '#{project_absolute_dir}/lib/websocket_client'
76
+
77
+ # app files
78
+ %w(#{options.project_name}).each {|lib| require lib}
79
+
80
+ Time.zone = 'Singapore'
81
+
82
+ # server config
83
+ set :environment, :production
84
+ enable :sessions, :logging, :dump_errors, :show_exceptions
85
+ disable :run, :reload
86
+
87
+ run Sinatra::Application
88
+ config_ru
89
+
90
+ File.open("#{project_absolute_dir}/config.ru", "w") do |file|
91
+ file.puts config_ru_contents
92
+ end
93
+
94
+ #==================
95
+ # create helpers.rb
96
+ #==================
97
+
98
+ helpers_rb_contents = <<-helpers_rb
99
+ helpers do
100
+
101
+ def debug_on
102
+ $LOG.info("===== START =====> #{Time.now.strftime("%d/%m/%Y %H:%M %p")}")
103
+ $LOG.info(request.url)
104
+ $LOG.info("Params:")
105
+ params.each do |key, value|
106
+ $LOG.info("\#{key} => \#{value}")
107
+ end
108
+ end
109
+
110
+ def logger(text)
111
+ $LOG.info(text)
112
+ end
113
+
114
+ end
115
+ helpers_rb
116
+
117
+ File.open("#{project_absolute_dir}/helpers.rb", "w") do |file|
118
+ file.puts helpers_rb_contents
119
+ end
120
+
121
+ #====================
122
+ # create database.yml
123
+ #====================
124
+
125
+ database_yml_contents = <<-database_yml
126
+ login: &login
127
+ adapter: mysql
128
+ username: root
129
+ password: password
130
+ host: localhost
131
+ timezone: SGT
132
+ reconnect: true
133
+
134
+ production:
135
+ <<: *login
136
+ database: #{options.project_name}
137
+ encoding: utf8
138
+ database_yml
139
+
140
+ File.open("#{project_absolute_dir}/db/database.yml", "w") do |file|
141
+ file.puts database_yml_contents
142
+ end
143
+
144
+ #====================
145
+ # create db_config.rb
146
+ #====================
147
+
148
+ db_config_contents = <<-db_config_rb
149
+ #gem 'activerecord', '=2.3.8'
150
+ require 'activerecord'
151
+ config = YAML.load_file(File.join(File.dirname(__FILE__),'database.yml'))
152
+ ActiveRecord::Base.establish_connection(config["production"])
153
+ db_config_rb
154
+
155
+ File.open("#{project_absolute_dir}/db/db_config.rb", "w") do |file|
156
+ file.puts db_config_contents
157
+ end
158
+
159
+ #=======================
160
+ # create models.rb
161
+ #=======================
162
+
163
+ models_rb_contents = <<-models_rb
164
+ require '#{project_absolute_dir}/db/db_config'
165
+
166
+ # DB Models
167
+
168
+ # class Token < ActiveRecord::Base
169
+ # end
170
+ models_rb
171
+
172
+ File.open("#{project_absolute_dir}/models.rb", "w") do |file|
173
+ file.puts models_rb_contents
174
+ end
175
+
176
+ #=======================
177
+ # create project_name.rb
178
+ #=======================
179
+
180
+ project_name_rb_contents = <<-project_name_rb
181
+ # DB connection and data models
182
+ # require 'models'
183
+
184
+ # logger
185
+ before do
186
+ $LOG = Logger.new('log/#{options.project_name}.log')
187
+ end
188
+
189
+ require 'helpers'
190
+
191
+ # index
192
+ get '/' do
193
+ '#{options.project_name}'
194
+ end
195
+
196
+ # docs
197
+ get '/docs' do
198
+ haml :docs
199
+ end
200
+
201
+ ### Load other routes
202
+ # load 'routes/startup.rb'
203
+ project_name_rb
204
+
205
+ File.open("#{project_absolute_dir}/#{options.project_name}.rb", "w") do |file|
206
+ file.puts project_name_rb_contents
207
+ end
208
+
209
+ #=======================
210
+ # create docs.haml
211
+ #=======================
212
+
213
+ docs_haml_contents = <<-docs_haml
214
+ %h1 API Docs
215
+
216
+ %p
217
+ %b{:style=>"color: red"}
218
+ http://servername
219
+ %br
220
+ (GET) Returns app name
221
+ docs_haml
222
+
223
+ File.open("#{project_absolute_dir}/views/docs.haml", "w") do |file|
224
+ file.puts docs_haml_contents
225
+ end
data/lib/dindi.rb ADDED
File without changes
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'dindi'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestDindi < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dindi
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Samuel Chandra
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ hash: 19
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 8
32
+ version: 2.3.8
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: activerecord
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ hash: 19
44
+ segments:
45
+ - 2
46
+ - 3
47
+ - 8
48
+ version: 2.3.8
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: sinatra
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: json
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: haml
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: pony
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: shoulda
110
+ requirement: &id007 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: *id007
122
+ - !ruby/object:Gem::Dependency
123
+ name: bundler
124
+ requirement: &id008 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ hash: 23
130
+ segments:
131
+ - 1
132
+ - 0
133
+ - 0
134
+ version: 1.0.0
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: *id008
138
+ - !ruby/object:Gem::Dependency
139
+ name: jeweler
140
+ requirement: &id009 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ hash: 7
146
+ segments:
147
+ - 1
148
+ - 6
149
+ - 4
150
+ version: 1.6.4
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: *id009
154
+ - !ruby/object:Gem::Dependency
155
+ name: rcov
156
+ requirement: &id010 !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: *id010
168
+ description: This gem will create a barebone base for a new Sinatra Project
169
+ email: samuelchandra@yahoo.com
170
+ executables:
171
+ - dindi
172
+ extensions: []
173
+
174
+ extra_rdoc_files:
175
+ - LICENSE.txt
176
+ - README.rdoc
177
+ files:
178
+ - .document
179
+ - Gemfile
180
+ - Gemfile.lock
181
+ - LICENSE.txt
182
+ - README.rdoc
183
+ - Rakefile
184
+ - VERSION
185
+ - bin/dindi
186
+ - lib/dindi.rb
187
+ - test/helper.rb
188
+ - test/test_dindi.rb
189
+ homepage: http://github.com/schandra/dindi
190
+ licenses:
191
+ - MIT
192
+ post_install_message:
193
+ rdoc_options: []
194
+
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ hash: 3
203
+ segments:
204
+ - 0
205
+ version: "0"
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ hash: 3
212
+ segments:
213
+ - 0
214
+ version: "0"
215
+ requirements: []
216
+
217
+ rubyforge_project:
218
+ rubygems_version: 1.8.10
219
+ signing_key:
220
+ specification_version: 3
221
+ summary: Dindi is a hit of Sinatra
222
+ test_files: []
223
+