hazel 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source :rubygems
2
2
 
3
+ gemspec
4
+
3
5
  group :development do
4
- gem "bundler", "~> 1.1"
6
+ gem "rake", "~> 0.9"
7
+ gem "fakefs", "~> 0.4"
5
8
  end
6
-
7
- gem "thor", "~> 0.15.3"
data/Gemfile.lock CHANGED
@@ -1,11 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hazel (0.0.6)
5
+ thor (~> 0.16)
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
4
- thor (0.15.3)
10
+ minitest (4.2.0)
11
+ rake (0.9.2.2)
12
+ thor (0.16.0)
5
13
 
6
14
  PLATFORMS
7
15
  ruby
8
16
 
9
17
  DEPENDENCIES
10
- bundler (~> 1.1)
11
- thor (~> 0.15.3)
18
+ bundler (~> 1.2)
19
+ hazel!
20
+ minitest (~> 4.2)
21
+ rake (~> 0.9)
data/lib/hazel/cli.rb CHANGED
@@ -10,6 +10,7 @@ module Hazel
10
10
 
11
11
  desc "Creates a new Sinatra application"
12
12
  argument :name, :type => :string, :desc => "The name of the new application"
13
+ class_option :capistrano, :type => :boolean, :desc => "Include Capistrano configuration"
13
14
  class_option :database, :aliases => "-d", :default => "sqlite", :desc => "The type of database to use"
14
15
  class_option :no_database, :type => :boolean, :desc => "Exclude all database configuration files"
15
16
  class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
@@ -82,6 +83,15 @@ module Hazel
82
83
  copy_file "README.md", File.join(@app_path, "README.md")
83
84
  end
84
85
 
86
+ def create_capistrano_config
87
+ if @capistrano
88
+ copy_file "Capfile", File.join(@app_path, "Capfile")
89
+ empty_directory File.join(@app_path, 'config/deploy')
90
+ template "config/deploy.rb", File.join(@app_path, "config/deploy.rb")
91
+ template "config/deploy/production.rb", File.join(@app_path, "config/deploy/production.rb")
92
+ end
93
+ end
94
+
85
95
  def create_db_config
86
96
  template("config/db.yml", File.join(@app_path, "config/db.yml")) unless @no_database
87
97
  end
@@ -101,22 +111,23 @@ module Hazel
101
111
  def create_rvm_gemset
102
112
  if @rvm_gemset
103
113
  rvm_path = File.expand_path(ENV['rvm_path'] || '~/.rvm')
104
- $LOAD_PATH.unshift File.join(rvm_path, 'lib')
105
114
  require 'rvm'
106
115
 
107
- rvm_ruby = "#{ENV['RUBY_VERSION']}@#{@app_path}"
108
- data = "rvm --create use #{rvm_ruby}"
116
+ rvm_env = RVM::Environment.new(ENV['RUBY_VERSION'])
109
117
 
110
- create_file(File.join(@app_path, '.rvmrc'), data)
111
- run("rvm rvmrc trust #{@app_path}")
118
+ rvm_env.gemset_create(@app_path)
119
+ rvm_env.gemset_use(@app_path)
120
+
121
+ gemset = "#{ENV['RUBY_VERSION']}@#{@app_path}"
112
122
 
113
- rvm_env = RVM::Environment.new(rvm_ruby)
123
+ create_file(File.join(@app_path, '.rvmrc'), "rvm use #{gemset}")
124
+ run("rvm rvmrc trust #{@app_path}")
114
125
 
115
126
  unless @no_bundle_install
116
127
  rvm_env.chdir(@app_path) do
117
- say_status :installing, "All dependencies into #{rvm_ruby}"
128
+ say_status :installing, "All dependencies into #{gemset}"
118
129
  rvm_env.system "gem install bundler"
119
- rvm_env.system "bundle install"
130
+ rvm_env.run_command 'bundle install'
120
131
  end
121
132
 
122
133
  @no_bundle_install = true
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 = 5
5
+ TINY = 6
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,3 @@
1
+ load 'deploy'
2
+ Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
3
+ load 'config/deploy'
@@ -1,7 +1,7 @@
1
1
  source :rubygems
2
2
 
3
3
  # App Stack
4
- gem "sinatra", "~> 1.3.2"
4
+ gem "sinatra", "~> 1.3"
5
5
 
6
6
  <% unless @no_database -%>
7
7
  # Database Stack
@@ -25,10 +25,17 @@ gem "mongodb_model", "~> 2.1"
25
25
  gem "hiredis", "~> 0.4"
26
26
  gem "redis", "~> 3.0", :require => ["redis/connection/hiredis", "redis"]
27
27
  gem "fakeredis", "~> 0.4"
28
- <% end -%>
29
28
 
29
+ <% end -%>
30
30
  group :development do
31
31
  gem "rake", "~> 0.9"
32
- gem "minitest", "~> 3.2"
32
+ gem "minitest", "~> 4.2"
33
33
  gem "rack-test", "~> 0.6"
34
+ <% if @capistrano -%>
35
+ gem "capistrano", "~> 2.13"
36
+ gem "capistrano-ext", "~> 1.2"
37
+ <% if @rvm_gemset -%>
38
+ gem "rvm-capistrano", "~> 1.2"
39
+ <% end -%>
40
+ <% end -%>
34
41
  end
@@ -7,14 +7,6 @@ Rake::TestTask.new(:spec) do |t|
7
7
  t.ruby_opts = ['-rubygems'] if defined? Gem
8
8
  end
9
9
 
10
- task :kicker do
11
- exec 'kicker -r ruby -e "clear && bundle exec rake" spec lib'
12
- end
13
-
14
- task :sass do
15
- exec 'sass --watch --scss --style compressed sass/main.scss:public/stylesheets/main.css'
16
- end
17
-
18
10
  <% unless @no_database -%>
19
11
  namespace :db do
20
12
  desc "Run all migrations in db/migrate"
data/lib/templates/app.rb CHANGED
@@ -3,9 +3,6 @@ class <%= @name.camel_case %> < Sinatra::Base
3
3
  set :public_folder => "public", :static => true
4
4
 
5
5
  get "/" do
6
- @version = RUBY_VERSION
7
- @environment = ENV['RACK_ENV']
8
-
9
6
  erb :welcome
10
7
  end
11
8
  end
@@ -0,0 +1,87 @@
1
+ <% if @rvm_gemset -%>
2
+ require "rvm/capistrano"
3
+
4
+ set :rvm_ruby_string, "ruby-1.9.3"
5
+ set :rvm_type, :system
6
+
7
+ <% end -%>
8
+ require "bundler/capistrano"
9
+ require "capistrano/ext/multistage"
10
+
11
+ #############################################################
12
+ # Stages
13
+ #############################################################
14
+
15
+ set :default_stage, "production"
16
+ set :stages, %w(production)
17
+
18
+ #############################################################
19
+ # Application
20
+ #############################################################
21
+
22
+ set :application, "<%= @name %>"
23
+ set :deploy_to, "/var/www/apps/#{application}"
24
+ set :keep_releases, 2
25
+
26
+ after "deploy:update", "deploy:cleanup"
27
+
28
+ #############################################################
29
+ # Settings
30
+ #############################################################
31
+
32
+ set :user, "deploy"
33
+ set :use_sudo, false
34
+
35
+ ssh_options[:forward_agent] = true
36
+
37
+ #############################################################
38
+ # Git
39
+ #############################################################
40
+
41
+ set :scm, :git
42
+ set :deploy_via, :remote_cache
43
+
44
+ set :repository, "git@github.com:/GITHUB_USER/#{application}.git"
45
+
46
+ namespace :deploy do
47
+ task :set_branch do
48
+ set(:branch) { Capistrano::CLI.ui.ask("Branch to deploy (or press ENTER to deploy from master): ") }
49
+
50
+ if branch.empty?
51
+ set :branch, "master"
52
+ end
53
+ end
54
+
55
+ before "deploy:update" , "deploy:set_branch"
56
+ end
57
+
58
+ <% if @rvm_gemset -%>
59
+ #############################################################
60
+ # RVM
61
+ #############################################################
62
+
63
+ after "deploy", "rvm:trust_rvmrc"
64
+
65
+ namespace :rvm do
66
+ task :trust_rvmrc do
67
+ run "rvm rvmrc trust #{current_release}"
68
+ run "rvm rvmrc trust /var/www/apps/#{application}/current"
69
+ end
70
+ end
71
+
72
+ <% end -%>
73
+ #############################################################
74
+ # Passenger
75
+ #############################################################
76
+
77
+ namespace :deploy do
78
+ task :start do
79
+ end
80
+
81
+ task :stop do
82
+ end
83
+
84
+ task :restart, :roles => :app, :except => { :no_release => true } do
85
+ run "touch #{File.join(current_path,'tmp','restart.txt')}"
86
+ end
87
+ end
@@ -0,0 +1,3 @@
1
+ role :web, "<%= @name %>.tld"
2
+ role :app, "<%= @name %>.tld"
3
+ role :db, "<%= @name %>.tld", :primary => true
@@ -9,8 +9,8 @@
9
9
  <div class="sidebar">
10
10
  <h3>Environment</h3>
11
11
  <ul>
12
- <li><b>Ruby:</b> <%= @version %></li>
13
- <li><b>Environment:</b> <%= @environment %></li>
12
+ <li><b>Ruby:</b> <%= RUBY_VERSION %></li>
13
+ <li><b>Environment:</b> <%= ENV["RACK_ENV"] %></li>
14
14
  <li><b>Server:</b> <%= @env["SERVER_SOFTWARE"] %></li>
15
15
  <li><b>Port:</b> <%= @env["SERVER_PORT"] %></li>
16
16
  </ul>
@@ -0,0 +1,15 @@
1
+ require 'fakefs'
2
+ require_relative "../spec_helper"
3
+ require_relative "../../lib/hazel/cli"
4
+
5
+ describe Hazel::VERSION do
6
+ subject { Hazel::CLI }
7
+
8
+ describe "source_root" do
9
+ it "should return with a full path" do
10
+ pwd = File.dirname(__FILE__)
11
+ template_path = pwd.sub 'spec/hazel', 'lib/templates'
12
+ subject.source_root.must_equal template_path
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "../spec_helper"
2
+ require_relative "../../lib/hazel/version"
3
+
4
+ describe Hazel::VERSION do
5
+ subject { Hazel::VERSION }
6
+
7
+ let(:major) { subject::MAJOR }
8
+ let(:minor) { subject::MINOR }
9
+ let(:tiny) { subject::TINY }
10
+ let(:string) { subject::STRING }
11
+
12
+ it "should have a major version" do
13
+ major.must_be_kind_of Fixnum
14
+ end
15
+
16
+ it "should have a minor version" do
17
+ minor.must_be_kind_of Fixnum
18
+ end
19
+
20
+ it "should have a tiny version" do
21
+ tiny.must_be_kind_of Fixnum
22
+ end
23
+
24
+ it "should have a string representation of the version number" do
25
+ string.must_equal "#{major}.#{minor}.#{tiny}"
26
+ end
27
+ 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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-28 00:00:00.000000000 Z
12
+ date: 2012-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70344124506980 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.14.6
21
+ version: '0.16'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70344124506980
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.16'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: bundler
27
- requirement: &70344124505380 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
31
36
  - !ruby/object:Gem::Version
32
- version: '1.1'
37
+ version: '1.2'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70344124505380
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: minitest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '4.2'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '4.2'
36
62
  description: Hazel is a generator for Sinatra apps, heavily based on snfn
37
63
  email: peter@c7.se
38
64
  executables:
@@ -44,7 +70,10 @@ files:
44
70
  - lib/hazel/cli.rb
45
71
  - lib/hazel/version.rb
46
72
  - lib/templates/app.rb
73
+ - lib/templates/Capfile
47
74
  - lib/templates/config/db.yml
75
+ - lib/templates/config/deploy/production.rb
76
+ - lib/templates/config/deploy.rb
48
77
  - lib/templates/config/initializers/database.rb
49
78
  - lib/templates/config/initializers/redis.rb
50
79
  - lib/templates/config/redis.yml
@@ -62,6 +91,8 @@ files:
62
91
  - lib/templates/views/welcome.erb
63
92
  - lib/templates/public/images/.gitkeep
64
93
  - lib/templates/public/javascripts/.gitkeep
94
+ - spec/hazel/cli_spec.rb
95
+ - spec/hazel/version_spec.rb
65
96
  - spec/spec_helper.rb
66
97
  - spec/string_extension_spec.rb
67
98
  - Gemfile
@@ -69,8 +100,7 @@ files:
69
100
  - MIT-LICENSE
70
101
  - README.md
71
102
  - Rakefile
72
- - !binary |-
73
- YmluL2hhemVs
103
+ - bin/hazel
74
104
  homepage: http://c7.github.com/hazel/
75
105
  licenses:
76
106
  - MIT-LICENSE
@@ -92,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
122
  version: '0'
93
123
  requirements: []
94
124
  rubyforge_project:
95
- rubygems_version: 1.8.15
125
+ rubygems_version: 1.8.24
96
126
  signing_key:
97
127
  specification_version: 3
98
128
  summary: A simple Sinatra app generator.