hazel 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/extensions/string.rb +9 -8
- data/lib/hazel/cli.rb +32 -3
- data/lib/hazel/version.rb +1 -1
- data/lib/templates/Gemfile +1 -0
- data/spec/string_extension_spec.rb +5 -0
- metadata +13 -11
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/extensions/string.rb
CHANGED
@@ -15,15 +15,16 @@ module Hazel
|
|
15
15
|
self.replace camel_case
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
altered_self.scan(/[A-Z]/).each do |match|
|
23
|
-
altered_self.gsub!(match, "_#{match.downcase}")
|
24
|
-
end
|
18
|
+
def directory_name
|
19
|
+
self.downcase.gsub(/[^a-z|\-|\_]/, '')
|
20
|
+
end
|
25
21
|
|
26
|
-
|
22
|
+
def file_name
|
23
|
+
self.gsub(/[\-| ]/, '_').
|
24
|
+
gsub(/([A-Z]+|[A-Z][a-z])/) { |x| "_#{x}" }.
|
25
|
+
sub(/^_/, "").
|
26
|
+
gsub(/_{2,}+/, "_").
|
27
|
+
downcase
|
27
28
|
end
|
28
29
|
|
29
30
|
def file_name!
|
data/lib/hazel/cli.rb
CHANGED
@@ -13,12 +13,15 @@ module Hazel
|
|
13
13
|
class_option :database, :aliases => "-d", :default => "sqlite", :desc => "The type of database to use"
|
14
14
|
class_option :no_database, :type => :boolean, :desc => "Exclude all database configuration files"
|
15
15
|
class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
|
16
|
+
class_option :rvm_gemset, :type => :boolean, :desc => "Create a new RVM Gemset under the current Ruby"
|
16
17
|
class_option :no_bundle_install, :type => :boolean, :desc => "Don’t run bundle install after generating the app"
|
17
18
|
class_option :no_git_repo, :type => :boolean, :desc => "Don’t initialize a Git repository"
|
18
19
|
|
19
20
|
# Creates instance variables from options passed to hazel.
|
20
21
|
def setup
|
21
|
-
@
|
22
|
+
@app_path = name.directory_name
|
23
|
+
@name = name.file_name
|
24
|
+
|
22
25
|
options.each do |key, value|
|
23
26
|
instance_variable_set "@#{key.to_s}".to_sym, value
|
24
27
|
end
|
@@ -95,14 +98,40 @@ module Hazel
|
|
95
98
|
template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) if @redis
|
96
99
|
end
|
97
100
|
|
101
|
+
def create_rvm_gemset
|
102
|
+
if @rvm_gemset
|
103
|
+
rvm_path = File.expand_path(ENV['rvm_path'] || '~/.rvm')
|
104
|
+
$LOAD_PATH.unshift File.join(rvm_path, 'lib')
|
105
|
+
require 'rvm'
|
106
|
+
|
107
|
+
rvm_ruby = "#{ENV['RUBY_VERSION']}@#{@app_path}"
|
108
|
+
data = "rvm --create use #{rvm_ruby}"
|
109
|
+
|
110
|
+
create_file(File.join(@app_path, '.rvmrc'), data)
|
111
|
+
run("rvm rvmrc trust #{@app_path}")
|
112
|
+
|
113
|
+
rvm_env = RVM::Environment.new(rvm_ruby)
|
114
|
+
|
115
|
+
unless @no_bundle_install
|
116
|
+
rvm_env.chdir(@app_path) do
|
117
|
+
puts "\n Installing dependencies into #{rvm_ruby}\n\n"
|
118
|
+
rvm_env.system "gem install bundler"
|
119
|
+
rvm_env.system "bundle install"
|
120
|
+
end
|
121
|
+
|
122
|
+
@no_bundle_install = true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
98
127
|
def install_dependencies
|
99
|
-
inside(@
|
128
|
+
inside(@app_path) do
|
100
129
|
run('bundle install') unless @no_bundle_install
|
101
130
|
end
|
102
131
|
end
|
103
132
|
|
104
133
|
def initialize_git_repo
|
105
|
-
inside(@
|
134
|
+
inside(@app_path) do
|
106
135
|
run('git init .') unless @no_git_repo
|
107
136
|
end
|
108
137
|
end
|
data/lib/hazel/version.rb
CHANGED
data/lib/templates/Gemfile
CHANGED
@@ -45,4 +45,9 @@ describe String do
|
|
45
45
|
it "should_underscore_a_string_with_a_hyphen_preceding_a_capital_letter" do
|
46
46
|
"my_App".file_name.must_equal "my_app"
|
47
47
|
end
|
48
|
+
|
49
|
+
it "should allow dashes in directory names, but not in filenames" do
|
50
|
+
"my-App".directory_name.must_equal "my-app"
|
51
|
+
"my-App".file_name.must_equal "my_app"
|
52
|
+
end
|
48
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hazel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70174817115060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,18 +21,18 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70174817115060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70174817114020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.1'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70174817114020
|
36
36
|
description: Hazel is a generator for Sinatra apps, heavily based on snfn
|
37
37
|
email: peter@c7.se
|
38
38
|
executables:
|
@@ -51,10 +51,8 @@ files:
|
|
51
51
|
- lib/templates/config.ru
|
52
52
|
- lib/templates/Gemfile
|
53
53
|
- lib/templates/public/favicon.ico
|
54
|
-
- lib/templates/public/images/.gitkeep
|
55
54
|
- lib/templates/public/images/hazel_icon.png
|
56
55
|
- lib/templates/public/images/hazel_small.png
|
57
|
-
- lib/templates/public/javascripts/.gitkeep
|
58
56
|
- lib/templates/public/stylesheets/main.css
|
59
57
|
- lib/templates/Rakefile
|
60
58
|
- lib/templates/README.md
|
@@ -62,6 +60,8 @@ files:
|
|
62
60
|
- lib/templates/spec/spec_helper.rb
|
63
61
|
- lib/templates/views/layout.erb.tt
|
64
62
|
- lib/templates/views/welcome.erb
|
63
|
+
- lib/templates/public/images/.gitkeep
|
64
|
+
- lib/templates/public/javascripts/.gitkeep
|
65
65
|
- spec/spec_helper.rb
|
66
66
|
- spec/string_extension_spec.rb
|
67
67
|
- Gemfile
|
@@ -69,7 +69,8 @@ files:
|
|
69
69
|
- MIT-LICENSE
|
70
70
|
- README.md
|
71
71
|
- Rakefile
|
72
|
-
-
|
72
|
+
- !binary |-
|
73
|
+
YmluL2hhemVs
|
73
74
|
homepage: http://c7.github.com/hazel/
|
74
75
|
licenses:
|
75
76
|
- MIT-LICENSE
|
@@ -91,8 +92,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
94
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.8.
|
95
|
+
rubygems_version: 1.8.15
|
95
96
|
signing_key:
|
96
97
|
specification_version: 3
|
97
98
|
summary: A simple Sinatra app generator.
|
98
99
|
test_files: []
|
100
|
+
has_rdoc:
|