snfn 0.1.2 → 0.2.0
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 +1 -1
- data/Gemfile.lock +1 -1
- data/README.mdown +22 -11
- data/VERSION +1 -1
- data/bin/snfn +1 -1
- data/lib/extensions/string.rb +6 -5
- data/lib/templates/README.mdown +27 -11
- data/lib/templates/Rakefile +3 -1
- data/snfn.gemspec +5 -4
- data/test/helper.rb +1 -1
- data/test/test_extension_string.rb +47 -0
- data/test/test_snfn.rb +0 -3
- metadata +11 -10
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.mdown
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
Snfn is an opinionated generator for Sinatra projects. It
|
4
4
|
can be configured using the following options:
|
5
5
|
|
6
|
-
*
|
6
|
+
* `-d` Database. Options are "postgres," "mysql," "sqlite",
|
7
7
|
and "mongo." Default is "sqlite."
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
8
|
+
* `--redis` Include Redis configuration options.
|
9
|
+
* `--no-database` Don't include any database config options.
|
10
|
+
* `--no-heroku` Don't include Heroku config options.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -30,19 +30,30 @@ The template autoloads files in config/initializers and
|
|
30
30
|
/lib. Database configuration options are stored in `config/db.yml`
|
31
31
|
and are loaded via `config/initializers/database.rb`.
|
32
32
|
|
33
|
-
Right now Snfn only
|
34
|
-
stored at config/unicorn.rb
|
33
|
+
Right now Snfn only comes out of the box with support for Unicorn, (the
|
34
|
+
config file is stored at config/unicorn.rb), but changing it out for
|
35
|
+
thin or mongrel is pretty trivial.
|
35
36
|
|
36
37
|
## DB Setup
|
37
38
|
|
38
|
-
Sequel is used as an ORM for
|
39
|
-
and migrations are stored in db/migrate.
|
40
|
-
run using the rake command `rake migrate`.
|
39
|
+
[Sequel](http://sequel.rubyforge.org) is used as an ORM for
|
40
|
+
relational databases, and migrations are stored in db/migrate.
|
41
|
+
Migrations can be run using the rake command `rake rb:migrate`.
|
41
42
|
|
42
43
|
MongoMapper is used for Mongo apps, with the config options
|
43
44
|
stored in the same files as relational databases (`config/db.yml`
|
44
45
|
and `config/initializers/database.rb`).
|
45
46
|
|
47
|
+
### More information
|
48
|
+
|
49
|
+
* [Sequel Migrations](http://sequel.rubyforge.org/rdoc/files/doc/migration_rdoc.html)
|
50
|
+
* [Sequel Models](http://sequel.rubyforge.org/rdoc/classes/Sequel/Model.html)
|
51
|
+
* [MongoMapper](http://mongomapper.com)
|
52
|
+
|
53
|
+
If there is any interest in supporting other ORMs like DataMapper or
|
54
|
+
ActiveRecord, either please let me know or implement it yourself and
|
55
|
+
send a pull request.
|
56
|
+
|
46
57
|
## Set up on Heroku
|
47
58
|
|
48
59
|
By default, Snfn creates an app with the proper options for deployment
|
@@ -59,8 +70,8 @@ on Heroku. To get Snfn up and running on Heroku:
|
|
59
70
|
To use PostgreSQL, MongoDB, or Redis on Heroku, you'll need to add
|
60
71
|
the proper Heroku add-ons. The commands to do this are, respectively:
|
61
72
|
|
62
|
-
heroku addons:add
|
63
|
-
heroku addons:add mongolab:starter
|
73
|
+
heroku addons:add shared-database # PostgreSQL
|
74
|
+
heroku addons:add mongolab:starter # MongoDB
|
64
75
|
heroku addons:add redistogo:nano # Redis
|
65
76
|
|
66
77
|
## Contributing to snfn
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/snfn
CHANGED
@@ -9,7 +9,7 @@ class SnfnGenerator < Thor
|
|
9
9
|
include Thor::Actions
|
10
10
|
|
11
11
|
desc "new NAME", "Creates new Snfn application"
|
12
|
-
method_option :database, :aliases => "-d", :default => "
|
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
13
|
method_option :no_heroku, :type => :boolean, :desc => "Include Heroku configuration options."
|
14
14
|
method_option :no_database, :type => :boolean, :desc => "Do not use any database."
|
15
15
|
method_option :redis, :type => :boolean, :desc => "Include Redis configuration options."
|
data/lib/extensions/string.rb
CHANGED
@@ -2,9 +2,9 @@ module Snfn
|
|
2
2
|
module Extensions
|
3
3
|
module String
|
4
4
|
def camel_case
|
5
|
-
return self if !match(/_/)
|
6
|
-
altered_self = self.capitalize
|
7
|
-
altered_self.scan(/_[a-zA-Z]/).each do |match|
|
5
|
+
return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
|
6
|
+
altered_self = self.downcase.capitalize
|
7
|
+
altered_self.scan(/[_-][a-zA-Z]/).each do |match|
|
8
8
|
altered_self.gsub!(match, match[1].upcase)
|
9
9
|
end
|
10
10
|
|
@@ -16,13 +16,14 @@ module Snfn
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def file_name
|
19
|
-
return self if !match(/[A-Z]/)
|
19
|
+
return self.gsub(/-/, "_") if !match(/[A-Z]/)
|
20
20
|
altered_self = self.strip
|
21
|
+
|
21
22
|
altered_self.scan(/[A-Z]/).each do |match|
|
22
23
|
altered_self.gsub!(match, "_#{match.downcase}")
|
23
24
|
end
|
24
25
|
|
25
|
-
altered_self.sub(/^_/, "")
|
26
|
+
altered_self.sub(/^_/, "").gsub(/_{2,}+/, "_").downcase
|
26
27
|
end
|
27
28
|
|
28
29
|
def file_name!
|
data/lib/templates/README.mdown
CHANGED
@@ -3,11 +3,15 @@
|
|
3
3
|
Snfn is an opinionated generator for Sinatra projects. It
|
4
4
|
can be configured using the following options:
|
5
5
|
|
6
|
-
*
|
6
|
+
* `-d` Database. Options are "postgres," "mysql," "sqlite",
|
7
7
|
and "mongo." Default is "sqlite."
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
8
|
+
* `--redis` Include Redis configuration options.
|
9
|
+
* `--no-database` Don't include any database config options.
|
10
|
+
* `--no-heroku` Don't include Heroku config options.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
gem install snfn
|
11
15
|
|
12
16
|
## Example
|
13
17
|
|
@@ -26,19 +30,30 @@ The template autoloads files in config/initializers and
|
|
26
30
|
/lib. Database configuration options are stored in `config/db.yml`
|
27
31
|
and are loaded via `config/initializers/database.rb`.
|
28
32
|
|
29
|
-
Right now Snfn only
|
30
|
-
stored at config/unicorn.rb
|
33
|
+
Right now Snfn only comes out of the box with support for Unicorn, (the
|
34
|
+
config file is stored at config/unicorn.rb), but changing it out for
|
35
|
+
thin or mongrel is pretty trivial.
|
31
36
|
|
32
37
|
## DB Setup
|
33
38
|
|
34
|
-
Sequel is used as an ORM for
|
35
|
-
and migrations are stored in db/migrate.
|
36
|
-
run using the rake command `rake migrate`.
|
39
|
+
[Sequel](http://sequel.rubyforge.org) is used as an ORM for
|
40
|
+
relational databases, and migrations are stored in db/migrate.
|
41
|
+
Migrations can be run using the rake command `rake rb:migrate`.
|
37
42
|
|
38
43
|
MongoMapper is used for Mongo apps, with the config options
|
39
44
|
stored in the same files as relational databases (`config/db.yml`
|
40
45
|
and `config/initializers/database.rb`).
|
41
46
|
|
47
|
+
### More information
|
48
|
+
|
49
|
+
* [Sequel Migrations](http://sequel.rubyforge.org/rdoc/files/doc/migration_rdoc.html)
|
50
|
+
* [Sequel Models](http://sequel.rubyforge.org/rdoc/classes/Sequel/Model.html)
|
51
|
+
* [MongoMapper](http://mongomapper.com)
|
52
|
+
|
53
|
+
If there is any interest in supporting other ORMs like DataMapper or
|
54
|
+
ActiveRecord, either please let me know or implement it yourself and
|
55
|
+
send a pull request.
|
56
|
+
|
42
57
|
## Set up on Heroku
|
43
58
|
|
44
59
|
By default, Snfn creates an app with the proper options for deployment
|
@@ -55,6 +70,7 @@ on Heroku. To get Snfn up and running on Heroku:
|
|
55
70
|
To use PostgreSQL, MongoDB, or Redis on Heroku, you'll need to add
|
56
71
|
the proper Heroku add-ons. The commands to do this are, respectively:
|
57
72
|
|
58
|
-
heroku addons:add
|
59
|
-
heroku addons:add mongolab:starter
|
73
|
+
heroku addons:add shared-database # PostgreSQL
|
74
|
+
heroku addons:add mongolab:starter # MongoDB
|
60
75
|
heroku addons:add redistogo:nano # Redis
|
76
|
+
|
data/lib/templates/Rakefile
CHANGED
@@ -15,6 +15,8 @@ end
|
|
15
15
|
task :environment, [:env] do |cmd, args|
|
16
16
|
Bundler.require
|
17
17
|
ENV['RACK_ENV'] = args[:env] || "development"
|
18
|
-
|
18
|
+
%w{ ./config/initializers ./lib }.each do
|
19
|
+
Find.find(lib) { |f| require f unless f.match(/\/\..+$/) || File.directory?(f) }
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
data/snfn.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{snfn}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.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}]
|
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
"lib/templates/views/welcome.erb",
|
47
47
|
"snfn.gemspec",
|
48
48
|
"test/helper.rb",
|
49
|
+
"test/test_extension_string.rb",
|
49
50
|
"test/test_snfn.rb",
|
50
51
|
"vendor/cache/git-1.2.5.gem",
|
51
52
|
"vendor/cache/jeweler-1.6.4.gem",
|
@@ -62,16 +63,16 @@ Gem::Specification.new do |s|
|
|
62
63
|
s.specification_version = 3
|
63
64
|
|
64
65
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
-
s.add_runtime_dependency(%q<thor>, ["
|
66
|
+
s.add_runtime_dependency(%q<thor>, ["~> 0.14.6"])
|
66
67
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
67
68
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
68
69
|
else
|
69
|
-
s.add_dependency(%q<thor>, ["
|
70
|
+
s.add_dependency(%q<thor>, ["~> 0.14.6"])
|
70
71
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
71
72
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
72
73
|
end
|
73
74
|
else
|
74
|
-
s.add_dependency(%q<thor>, ["
|
75
|
+
s.add_dependency(%q<thor>, ["~> 0.14.6"])
|
75
76
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
76
77
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
77
78
|
end
|
data/test/helper.rb
CHANGED
@@ -8,11 +8,11 @@ rescue Bundler::BundlerError => e
|
|
8
8
|
exit e.status_code
|
9
9
|
end
|
10
10
|
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
11
|
|
13
12
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
14
|
require 'snfn'
|
15
|
+
require 'extensions/string'
|
16
16
|
|
17
17
|
class Test::Unit::TestCase
|
18
18
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestExtensionString < Test::Unit::TestCase
|
4
|
+
def test_should_ignore_an_already_camel_cased_string
|
5
|
+
assert_equal "MyApp", "MyApp".camel_case
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_should_capitalize_an_all_lower_case_string
|
9
|
+
assert_equal "Myapp", "myapp".camel_case
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_camel_case_a_lower_case_string_with_underscores
|
13
|
+
assert_equal "MyApp", "my_app".camel_case
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_camel_case_a_lower_case_string_with_hyphens
|
17
|
+
assert_equal "MyApp", "my-app".camel_case
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_camel_case_an_uppercase_string_with_underscores
|
21
|
+
assert_equal "MyApp", "MY_APP".camel_case
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_camel_case_an_uppercase_string_with_hyphens
|
25
|
+
assert_equal "MyApp", "MY-APP".camel_case
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_camel_case_a_string_with_a_hyphen_preceding_a_capital_letter
|
29
|
+
assert_equal "MyApp", "my_App".camel_case
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_underscore_a_camel_cased_string
|
33
|
+
assert_equal "my_app", "MyApp".file_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_underscore_a_hypenated_string
|
37
|
+
assert_equal "my_app", "my-app".file_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_ignore_an_already_underscored_string
|
41
|
+
assert_equal "my_app", "my_app".file_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_should_underscore_a_string_with_a_hyphen_preceding_a_capital_letter
|
45
|
+
assert_equal "my_app", "my_App".file_name
|
46
|
+
end
|
47
|
+
end
|
data/test/test_snfn.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,18 +13,18 @@ date: 2011-08-15 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70096437864820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70096437864820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70096437861960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70096437861960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70096437859720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70096437859720
|
47
47
|
description: An app generator for Sinatra apps with an eye towards easy Heroku setup
|
48
48
|
and deployment.
|
49
49
|
email: zachpendleton@gmail.com
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/templates/views/welcome.erb
|
83
83
|
- snfn.gemspec
|
84
84
|
- test/helper.rb
|
85
|
+
- test/test_extension_string.rb
|
85
86
|
- test/test_snfn.rb
|
86
87
|
- vendor/cache/git-1.2.5.gem
|
87
88
|
- vendor/cache/jeweler-1.6.4.gem
|
@@ -102,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
103
|
version: '0'
|
103
104
|
segments:
|
104
105
|
- 0
|
105
|
-
hash:
|
106
|
+
hash: 1803279801753176280
|
106
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
108
|
none: false
|
108
109
|
requirements:
|