dohruby 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/check_syntax.rb +8 -0
- data/bin/create_skeleton_dohruby_project.rb +42 -0
- data/lib/doh/app/options.rb +11 -1
- data/lib/doh/util/http_helper.rb +2 -2
- metadata +7 -2
data/bin/check_syntax.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'doh/app/options'
|
3
|
+
|
4
|
+
opts = DohApp::Options.new({}, 1, 'Pass in the name of the project you want to create.', 'project')
|
5
|
+
|
6
|
+
def create_dir(dir)
|
7
|
+
puts "creating directory: #{dir}"
|
8
|
+
Dir.mkdir(dir)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_file(filename, &block)
|
12
|
+
puts "creating file: #{filename}"
|
13
|
+
File.open(filename, 'w') do |file|
|
14
|
+
if (block)
|
15
|
+
yield(file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
project = opts.varargs[0]
|
21
|
+
puts "creating dohruby project: #{project}"
|
22
|
+
create_dir(project)
|
23
|
+
create_dir(File.join(project, 'bin'))
|
24
|
+
create_dir(File.join(project, 'lib'))
|
25
|
+
create_dir(File.join(project, 'database'))
|
26
|
+
create_dir(File.join(project, 'database', project))
|
27
|
+
create_dir(File.join(project, 'config'))
|
28
|
+
create_file("#{project}/dohapp_home")
|
29
|
+
create_file("#{project}/config/active_runnable.rb") do |file|
|
30
|
+
file << <<INPUT
|
31
|
+
DohApp::use_default_runnable_development_config
|
32
|
+
db_cfg = {}
|
33
|
+
db_cfg['host'] = '127.0.0.1'
|
34
|
+
db_cfg['port'] = 3306
|
35
|
+
db_cfg['username'] = 'root'
|
36
|
+
db_cfg['password'] = ''
|
37
|
+
db_cfg['database'] = '#{project}'
|
38
|
+
|
39
|
+
DohApp::config['database'] = db_cfg
|
40
|
+
INPUT
|
41
|
+
end
|
42
|
+
|
data/lib/doh/app/options.rb
CHANGED
@@ -16,7 +16,7 @@ class Options
|
|
16
16
|
# set allow_unknown_options to true to allow for filename specification, etc..
|
17
17
|
# if the default value is :required for a field, then if that field isn't
|
18
18
|
# specified, an exception will be raised
|
19
|
-
def initialize(param_definition_hash_or_array, allow_unknown_options = false, explanation_text = '')
|
19
|
+
def initialize(param_definition_hash_or_array, allow_unknown_options = false, explanation_text = '', unknown_options_name = 'file')
|
20
20
|
@vals = OpenStruct.new
|
21
21
|
|
22
22
|
@opts = OptionParser.new
|
@@ -73,6 +73,16 @@ class Options
|
|
73
73
|
exception = ''
|
74
74
|
exception << "Required options not specified: #{unset_vars.inspect}\n" unless unset_vars.size == 0
|
75
75
|
exception << "Unknown options specified: #{varargs.inspect}\n" unless allow_unknown_options || (varargs.size == 0)
|
76
|
+
exception << "You must specify #{allow_unknown_options} #{unknown_options_name}#{allow_unknown_options > 1 ? 's' : ''}" if allow_unknown_options.class == Fixnum && varargs.size != allow_unknown_options
|
77
|
+
if allow_unknown_options.class == Range
|
78
|
+
if (allow_unknown_options.min == allow_unknown_options.max)
|
79
|
+
if (varargs.size < allow_unknown_options.min)
|
80
|
+
exception << "You must specify at least #{allow_unknown_options.min} #{unknown_options_name}#{allow_unknown_options.min > 1 ? 's' : ''}"
|
81
|
+
end
|
82
|
+
elsif !allow_unknown_options.include?(varargs.size)
|
83
|
+
exception << "You must specify between #{allow_unknown_options.min} and #{allow_unknown_options.max} #{unknown_options_name}s"
|
84
|
+
end
|
85
|
+
end
|
76
86
|
if exception != ''
|
77
87
|
puts @opts
|
78
88
|
raise exception
|
data/lib/doh/util/http_helper.rb
CHANGED
@@ -14,7 +14,7 @@ class HttpHelper
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def post(data, get_body_only = true)
|
17
|
-
dohlog.debug("posting to url #@url")
|
17
|
+
dohlog.debug("posting to url #@url data: #{data.inspect}")
|
18
18
|
response = if data.is_a?(Hash)
|
19
19
|
post_hash(data)
|
20
20
|
else
|
@@ -69,7 +69,7 @@ class HttpHelper
|
|
69
69
|
|
70
70
|
#shortcut method
|
71
71
|
def self.load(url, use_ssl = true)
|
72
|
-
helper = HttpHelper.new(url)
|
72
|
+
helper = HttpHelper.new(URI.escape(url))
|
73
73
|
helper.nossl if !use_ssl
|
74
74
|
helper.get
|
75
75
|
end
|
metadata
CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Makani & Kem Mason
|
@@ -13,15 +14,17 @@ autorequire:
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-
|
17
|
+
date: 2010-06-16 00:00:00 +12:00
|
17
18
|
default_executable:
|
18
19
|
dependencies: []
|
19
20
|
|
20
21
|
description:
|
21
22
|
email: makani.and.kem.mason@gmail.com
|
22
23
|
executables:
|
24
|
+
- check_syntax.rb
|
23
25
|
- config.rb
|
24
26
|
- create_database.rb
|
27
|
+
- create_skeleton_dohruby_project.rb
|
25
28
|
- gendata.rb
|
26
29
|
- migrate.rb
|
27
30
|
- rcov_preprocess_files.rb
|
@@ -33,8 +36,10 @@ extra_rdoc_files:
|
|
33
36
|
- MIT-LICENSE
|
34
37
|
- CHANGELOG
|
35
38
|
files:
|
39
|
+
- bin/check_syntax.rb
|
36
40
|
- bin/config.rb
|
37
41
|
- bin/create_database.rb
|
42
|
+
- bin/create_skeleton_dohruby_project.rb
|
38
43
|
- bin/gendata.rb
|
39
44
|
- bin/migrate.rb
|
40
45
|
- bin/rcov_preprocess_files.rb
|