hazel 0.0.3 → 0.0.4

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/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :rubygems
2
2
 
3
3
  group :development do
4
- gem "bundler", "~> 1.0.0"
4
+ gem "bundler", "~> 1.1"
5
5
  end
6
6
 
7
7
  gem "thor", "~> 0.14.6"
data/Gemfile.lock CHANGED
@@ -7,5 +7,5 @@ PLATFORMS
7
7
  ruby
8
8
 
9
9
  DEPENDENCIES
10
- bundler (~> 1.0.0)
10
+ bundler (~> 1.1)
11
11
  thor (~> 0.14.6)
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A simple Sinatra app generator, heavily based on [snfn](https://github.com/zachpendleton/snfn).
4
4
 
5
+ ![Using Hazel](http://c7.github.com/hazel/images/using_hazel.gif)
6
+
5
7
  ## Installation
6
8
 
7
9
  gem install hazel
@@ -15,15 +15,16 @@ module Hazel
15
15
  self.replace camel_case
16
16
  end
17
17
 
18
- def file_name
19
- return self.gsub(/-/, "_") if !match(/[A-Z]/)
20
- altered_self = self.strip
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
- altered_self.sub(/^_/, "").gsub(/_{2,}+/, "_").downcase
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
- @name = @app_path = name.file_name
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(@name) do
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(@name) do
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
@@ -2,7 +2,7 @@ module Hazel
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -27,6 +27,7 @@ gem "redis", "~> 2.2", :require => ["redis/connection/hiredis", "redis"]
27
27
  <% end -%>
28
28
 
29
29
  group :development do
30
+ gem "rake", "~> 0.9.2"
30
31
  gem "minitest", "~> 2.10"
31
32
  gem "rack-test", "~> 0.6.1"
32
33
  end
@@ -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.3
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-01-17 00:00:00.000000000Z
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: &70323813142520 !ruby/object:Gem::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: *70323813142520
24
+ version_requirements: *70174817115060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70323813142020 !ruby/object:Gem::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.0'
32
+ version: '1.1'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70323813142020
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
- - bin/hazel
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.6
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: