snfn 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ source "http://rubygems.org"
8
8
  group :development do
9
9
  # gem "shoulda", ">= 0"
10
10
  gem "bundler", "~> 1.0.0"
11
+ gem "fakefs", "~> 0.3.2"
11
12
  gem "jeweler", "~> 1.6.4"
12
13
  # gem "rcov", ">= 0"
13
14
  end
data/Gemfile.lock CHANGED
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ fakefs (0.3.2)
4
5
  git (1.2.5)
5
6
  jeweler (1.6.4)
6
7
  bundler (~> 1.0)
@@ -14,5 +15,6 @@ PLATFORMS
14
15
 
15
16
  DEPENDENCIES
16
17
  bundler (~> 1.0.0)
18
+ fakefs (~> 0.3.2)
17
19
  jeweler (~> 1.6.4)
18
20
  thor (~> 0.14.6)
data/README.mdown CHANGED
@@ -18,11 +18,11 @@ can be configured using the following options:
18
18
  Standard Heroku app, using sqlite for local development and
19
19
  PostgreSQL for production.
20
20
 
21
- snfn new my_app
21
+ snfn my_app
22
22
 
23
23
  App without Heroku options and mysql config.
24
24
 
25
- snfn new my_app -d mysql --no-heroku
25
+ snfn my_app -d mysql --no-heroku
26
26
 
27
27
  ## Architecture
28
28
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/bin/snfn CHANGED
@@ -1,73 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
4
- %w{rubygems extensions/string thor}.each do |lib|
5
- require lib
6
- end
7
-
8
- class SnfnGenerator < Thor
9
- include Thor::Actions
10
-
11
- desc "new NAME", "Creates new Snfn application"
12
- method_option :database, :aliases => "-d", :default => "sqlite", :desc => "The type of database to use. Values are \"sqlite\", \"postgres\", \"mysql\", and \"mongo\". Default is \"postgres\"."
13
- method_option :no_heroku, :type => :boolean, :desc => "Include Heroku configuration options."
14
- method_option :no_database, :type => :boolean, :desc => "Do not use any database."
15
- method_option :redis, :type => :boolean, :desc => "Include Redis configuration options."
16
- def new(name)
17
- @name = @app_path = name.file_name
18
- @database = options[:database]
19
- @no_database = options[:no_database]
20
- @redis = options[:redis]
21
- @no_heroku = options[:no_heroku]
22
-
23
- create_directories
24
- add_templates
25
- end
26
-
27
- def self.source_root
28
- File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "templates"))
29
- end
30
-
31
- protected
32
- def create_directories
33
- %w{config/initializers db/migrate lib log tmp}.each do |dir|
34
- add_app_directory dir
35
- end
36
-
37
- %w{public/css public/js public/img views}.each do |dir|
38
- directory dir, File.join(@app_path, dir)
39
- end
40
- end
41
-
42
- def add_templates
43
- copy_template "app.rb", "#{@name}.rb"
44
- copy_template "config.ru"
45
- copy_template "Gemfile"
46
- copy_static "Procfile" unless @no_heroku
47
- copy_static "Rakefile"
48
- copy_static "README.mdown"
49
- copy_template "config/unicorn.rb"
50
-
51
- copy_static "config/redis.yml" if @redis
52
- copy_template "config/db.yml" unless @no_database
53
- copy_template "config/initializers/database.rb"
54
-
55
- create_file File.join(@app_path, "lib", ".gitkeep")
56
- end
57
-
58
- def add_app_directory(name)
59
- empty_directory(File.join(@app_path, name))
60
- end
61
-
62
- def copy_template(name, new_name = nil)
63
- new_name ||= name
64
- template name, File.join(@app_path, new_name)
65
- end
66
-
67
- def copy_static(name)
68
- copy_file name, File.join(@app_path, name)
69
- end
70
- end
71
-
72
- SnfnGenerator.start
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))) unless $:.include? File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
4
+ require "snfn"
73
5
 
6
+ Snfn::Generator.start
data/lib/snfn.rb CHANGED
@@ -1 +1,92 @@
1
+ %w{rubygems extensions/string thor/group}.each { |lib| require lib }
2
+
3
+ module Snfn
4
+ class Generator < Thor::Group
5
+ include Thor::Actions
6
+
7
+ desc "Creates a new snfn application"
8
+ argument :name, :type => :string, :desc => "The name of the new application"
9
+ class_option :database, :aliases => "-d", :default => "sqlite", :desc => "The type of database to use"
10
+ class_option :no_heroku, :type => :boolean, :desc => "Exclude Heroku configuration"
11
+ class_option :no_database, :type => :boolean, :desc => "Exclude all database configuration files"
12
+ class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
13
+
14
+ # Creates instance variables from options passed to snfn.
15
+ def setup
16
+ @name = @app_path = name.file_name
17
+ options.each do |key, value|
18
+ instance_variable_set "@#{key.to_s}".to_sym, value
19
+ end
20
+ end
21
+
22
+ def self.source_root
23
+ File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "templates"))
24
+ end
25
+
26
+ # Create empty directories
27
+ def create_empty_directories
28
+ %w{config/initializers db/migrate lib log tmp}.each do |dir|
29
+ empty_directory File.join(@app_path, dir)
30
+ end
31
+ end
32
+
33
+ def create_public_directory
34
+ %w{public/css public/js public/img}.each do |dir|
35
+ directory dir, File.join(@app_path, dir)
36
+ end
37
+ end
38
+
39
+ def create_view_directory
40
+ directory "views", File.join(@app_path, "views")
41
+ end
42
+
43
+ def create_app
44
+ template "app.rb", File.join(@app_path, "#{@name}.rb")
45
+ end
46
+
47
+ def create_config
48
+ template "config.ru", File.join(@app_path, "config.ru")
49
+ end
50
+
51
+ def create_gemfile
52
+ template "Gemfile", File.join(@app_path, "Gemfile")
53
+ end
54
+
55
+ def create_procfile
56
+ copy_file("Procfile", File.join(@app_path, "Procfile")) unless @no_heroku
57
+ end
58
+
59
+ def create_rakefile
60
+ copy_file "Rakefile", File.join(@app_path, "Rakefile")
61
+ end
62
+
63
+ def create_readme
64
+ copy_file "README.mdown", File.join(@app_path, "README.mdown")
65
+ end
66
+
67
+ def create_server_config
68
+ template "config/unicorn.rb", File.join(@app_path, "config/unicorn.rb")
69
+ end
70
+
71
+ def create_db_config
72
+ template("config/db.yml", File.join(@app_path, "config/db.yml")) unless @no_database
73
+ end
74
+
75
+ def create_database_initializer
76
+ template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb")) unless @no_database
77
+ end
78
+
79
+ def create_redis_config
80
+ copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml")) if @redis
81
+ end
82
+
83
+ def create_redis_initializer
84
+ template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) if @redis
85
+ end
86
+
87
+ def create_lib_gitkeep
88
+ create_file File.join(@app_path, "lib", ".gitkeep")
89
+ end
90
+ end
91
+ end
1
92
 
@@ -40,9 +40,9 @@ group :production do
40
40
  gem "pg"
41
41
  end
42
42
  <% end -%>
43
+ <% end -%>
43
44
  <% if @redis -%>
44
45
  # Redis
45
46
  gem "redis"
46
47
  <% end -%>
47
- <% end -%>
48
48
 
@@ -18,11 +18,11 @@ can be configured using the following options:
18
18
  Standard Heroku app, using sqlite for local development and
19
19
  PostgreSQL for production.
20
20
 
21
- snfn new my_app
21
+ snfn my_app
22
22
 
23
23
  App without Heroku options and mysql config.
24
24
 
25
- snfn new my_app -d mysql --no-heroku
25
+ snfn my_app -d mysql --no-heroku
26
26
 
27
27
  ## Architecture
28
28
 
@@ -11,17 +11,5 @@ settings[ENV['RACK_ENV']]["uri"] = ENV['MONGOLAB_URI']
11
11
  MongoMapper.config = settings
12
12
  MongoMapper.connect(ENV['RACK_ENV'])
13
13
  <% end -%>
14
-
15
- <% end -%>
16
- <% if @redis -%>
17
- # Redis Configuration
18
- if ENV['REDISTOGO_URL']
19
- require "uri"
20
- uri = URI.parse(ENV['REDISTOGO_URL'])
21
- REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
22
- else
23
- redis_settings = YAML::load_file("config/redis.yml")
24
- REDIS = Redis.new(redis_settings[ENV['RACK_ENV']])
25
- end
26
14
  <% end -%>
27
15
 
@@ -0,0 +1,10 @@
1
+ # Redis Configuration
2
+ if ENV['REDISTOGO_URL']
3
+ require "uri"
4
+ uri = URI.parse(ENV['REDISTOGO_URL'])
5
+ REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
6
+ else
7
+ redis_settings = YAML::load_file("config/redis.yml")
8
+ REDIS = Redis.new(redis_settings[ENV['RACK_ENV']])
9
+ end
10
+
@@ -1,7 +1,7 @@
1
1
  worker_processes 3
2
2
  timeout 30
3
3
 
4
- <% if @noheroku -%>
4
+ <% if @no_heroku -%>
5
5
  docroot = File.join(File.expand_path(File.dirname(__FILE__)), "..")
6
6
 
7
7
  listen "#{docroot}/tmp/sockets/unicorn.sock"
@@ -24,9 +24,10 @@
24
24
  -moz-box-shadow: 0 0 10px rgba(0,0,0,.3);
25
25
  -webkit-box-shadow: 0 0 10px rgba(0,0,0,.3);
26
26
  box-shadow: 0 0 10px rgba(0,0,0,.3);
27
- margin: 20px auto;
28
- padding: 18px;
29
- width: 764px;
27
+ margin: 16px auto;
28
+ max-width: 960px;
29
+ padding: 2.25%; /* 18px / 800px */
30
+ width: 85%;
30
31
  }
31
32
 
32
33
  h1 {
@@ -56,15 +57,15 @@
56
57
 
57
58
  .content {
58
59
  float: left;
59
- width: 480px;
60
+ width: 60%; /* 480px / 800px */
60
61
  }
61
62
 
62
63
  .sidebar {
63
64
  background: #eee;
64
65
  border: 1px solid #ccc;
65
66
  float: right;
66
- padding: 9px;
67
- width: 240px;
67
+ padding: 3.75%; /* 9px / 240px */
68
+ width: 30%; /* 240px / 800px */
68
69
  }
69
70
 
70
71
  .sidebar ul {
@@ -82,6 +83,34 @@
82
83
  }
83
84
  }
84
85
 
85
- @media print {
86
+ @media screen and (max-width: 480px) {
87
+ .wrapper {
88
+ -moz-box-shadow: none;
89
+ -webkit-box-shadow: none;
90
+ box-shadow: none;
91
+ width: auto;
92
+ }
93
+
94
+ .content, .sidebar {
95
+ float: none;
96
+ width: 100%;
97
+ }
98
+
99
+ .sidebar {
100
+ background: transparent;
101
+ border: none;
102
+ border-top: 2px solid #ccc;
103
+ padding: 0;
104
+ }
86
105
 
106
+ h1 {
107
+ font-size: 24px;
108
+ line-height: 36px;
109
+ }
110
+
111
+ h2 {
112
+ font-size: 18px;
113
+ line-height: 24px;
114
+ }
87
115
  }
116
+
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Application-specific JavaScript goes here.
3
+ *
4
+ */
5
+
6
+ (function(){
7
+ var <%= @name.camel_case %> = {
8
+ init : function(){
9
+ return this;
10
+ }
11
+ }
12
+
13
+ return <%= @name.camel_case %>.init();
14
+ })();
@@ -7,28 +7,28 @@
7
7
  <meta charset="utf-8" />
8
8
  <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
9
9
 
10
- <title>Template</title>
10
+ <title><%= @name.camel_case %></title>
11
11
 
12
- <meta name="author" content="Zach Pendleton" />
13
- <meta name="description" content="Template Description" />
12
+ <meta name="author" content="Me" />
13
+ <meta name="description" content="Site Description" />
14
14
 
15
15
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
16
16
 
17
17
  <script src="/js/lib/modernizr-2.0.6.js"></script>
18
- <link rel="stylesheet" href="/css/main.css" />
18
+ <link rel="stylesheet" href="/css/scaffold.css" />
19
19
  </head>
20
20
  <body>
21
21
  <div class="wrapper">
22
22
  <header class="branding">
23
- <h1>My Application Title</h1>
23
+ <h1><%= @name.camel_case %></h1>
24
24
  </header>
25
25
 
26
26
  <div class="main">
27
- <%= yield %>
27
+ <%%= yield %>
28
28
  </div>
29
29
 
30
30
  <footer class="branding">
31
- <small>&copy; <%= Time.now.year %>, Zach Pendleton.</small>
31
+ <small>&copy; <%%= Time.now.year %>, Me.</small>
32
32
  </footer>
33
33
  </div>
34
34
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div class="content">
4
4
  <p>Welcome to the Sinatra Template! If you're seeing this page, then everything is working
5
- as expected. To get started, delete this file (<code>views/welcome.erb</code> and begin adding
5
+ as expected. To get started, delete this file (<code>views/welcome.erb)</code> and begin adding
6
6
  your own actions to <code>app.rb</code>. For more information, see the README.</p>
7
7
  </div>
8
8
 
data/snfn.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{snfn}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Zach Pendleton}]
12
- s.date = %q{2011-08-15}
12
+ s.date = %q{2011-08-24}
13
13
  s.description = %q{An app generator for Sinatra apps with an eye towards easy Heroku setup and deployment.}
14
14
  s.email = %q{zachpendleton@gmail.com}
15
15
  s.executables = [%q{snfn}]
@@ -36,18 +36,20 @@ Gem::Specification.new do |s|
36
36
  "lib/templates/config.ru",
37
37
  "lib/templates/config/db.yml",
38
38
  "lib/templates/config/initializers/database.rb",
39
+ "lib/templates/config/initializers/redis.rb",
39
40
  "lib/templates/config/redis.yml",
40
41
  "lib/templates/config/unicorn.rb",
41
- "lib/templates/public/css/main.css",
42
+ "lib/templates/public/css/scaffold.css",
42
43
  "lib/templates/public/img/.gitkeep",
43
- "lib/templates/public/js/app.js",
44
+ "lib/templates/public/js/app.js.tt",
44
45
  "lib/templates/public/js/lib/modernizr-2.0.6.js",
45
- "lib/templates/views/layout.erb",
46
+ "lib/templates/views/layout.erb.tt",
46
47
  "lib/templates/views/welcome.erb",
47
48
  "snfn.gemspec",
48
49
  "test/helper.rb",
49
50
  "test/test_extension_string.rb",
50
51
  "test/test_snfn.rb",
52
+ "vendor/cache/fakefs-0.3.2.gem",
51
53
  "vendor/cache/git-1.2.5.gem",
52
54
  "vendor/cache/jeweler-1.6.4.gem",
53
55
  "vendor/cache/rake-0.9.2.gem",
@@ -65,15 +67,18 @@ Gem::Specification.new do |s|
65
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
68
  s.add_runtime_dependency(%q<thor>, ["~> 0.14.6"])
67
69
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
70
+ s.add_development_dependency(%q<fakefs>, ["~> 0.3.2"])
68
71
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
69
72
  else
70
73
  s.add_dependency(%q<thor>, ["~> 0.14.6"])
71
74
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_dependency(%q<fakefs>, ["~> 0.3.2"])
72
76
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
73
77
  end
74
78
  else
75
79
  s.add_dependency(%q<thor>, ["~> 0.14.6"])
76
80
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
81
+ s.add_dependency(%q<fakefs>, ["~> 0.3.2"])
77
82
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
78
83
  end
79
84
  end
data/test/test_snfn.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'fakefs'
1
2
  require 'helper'
2
3
 
3
4
  class TestSnfn < Test::Unit::TestCase
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snfn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
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: 2011-08-15 00:00:00.000000000Z
12
+ date: 2011-08-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70096437864820 !ruby/object:Gem::Requirement
16
+ requirement: &70096299160060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70096437864820
24
+ version_requirements: *70096299160060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70096437861960 !ruby/object:Gem::Requirement
27
+ requirement: &70096299158960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70096437861960
35
+ version_requirements: *70096299158960
36
+ - !ruby/object:Gem::Dependency
37
+ name: fakefs
38
+ requirement: &70096299157900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70096299157900
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: jeweler
38
- requirement: &70096437859720 !ruby/object:Gem::Requirement
49
+ requirement: &70096299157020 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,7 +54,7 @@ dependencies:
43
54
  version: 1.6.4
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70096437859720
57
+ version_requirements: *70096299157020
47
58
  description: An app generator for Sinatra apps with an eye towards easy Heroku setup
48
59
  and deployment.
49
60
  email: zachpendleton@gmail.com
@@ -72,18 +83,20 @@ files:
72
83
  - lib/templates/config.ru
73
84
  - lib/templates/config/db.yml
74
85
  - lib/templates/config/initializers/database.rb
86
+ - lib/templates/config/initializers/redis.rb
75
87
  - lib/templates/config/redis.yml
76
88
  - lib/templates/config/unicorn.rb
77
- - lib/templates/public/css/main.css
89
+ - lib/templates/public/css/scaffold.css
78
90
  - lib/templates/public/img/.gitkeep
79
- - lib/templates/public/js/app.js
91
+ - lib/templates/public/js/app.js.tt
80
92
  - lib/templates/public/js/lib/modernizr-2.0.6.js
81
- - lib/templates/views/layout.erb
93
+ - lib/templates/views/layout.erb.tt
82
94
  - lib/templates/views/welcome.erb
83
95
  - snfn.gemspec
84
96
  - test/helper.rb
85
97
  - test/test_extension_string.rb
86
98
  - test/test_snfn.rb
99
+ - vendor/cache/fakefs-0.3.2.gem
87
100
  - vendor/cache/git-1.2.5.gem
88
101
  - vendor/cache/jeweler-1.6.4.gem
89
102
  - vendor/cache/rake-0.9.2.gem
@@ -103,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
116
  version: '0'
104
117
  segments:
105
118
  - 0
106
- hash: 1803279801753176280
119
+ hash: -2169240317479195428
107
120
  required_rubygems_version: !ruby/object:Gem::Requirement
108
121
  none: false
109
122
  requirements:
@@ -1,4 +0,0 @@
1
- /**
2
- * Application-specific JavaScript goes here.
3
- *
4
- */