Skip to content

Commit 7f9b8f2

Browse files
author
Thiru Njuguna
authored
version 0.0.4 release (#4)
* Update dependencies
1 parent e7d7286 commit 7f9b8f2

File tree

24 files changed

+132
-321
lines changed

24 files changed

+132
-321
lines changed

Gemfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
source 'https://rubygems.org/'
2-
32
gemspec
4-
53
gem 'active_model_serializers', '~> 0.10.0.rc1'
6-
gem 'coveralls', '~> 0'
4+
gem 'coveralls'
75
group :development do
8-
gem "rake", '~> 0'
9-
gem "pry"
6+
gem 'rake'
7+
gem 'pry'
108
gem 'guard'
119
gem 'rspec'
1210
gem 'guard-rubocop'
1311
gem 'guard-rspec', require: false
14-
end
12+
end

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
natra (0.0.3)
4+
natra (0.0.4)
55
activesupport (~> 5.0)
66
thor (~> 0.18)
77

@@ -91,7 +91,7 @@ GEM
9191
nenv (~> 0.1)
9292
shellany (~> 0.0)
9393
parallel (1.12.1)
94-
parser (2.5.1.2)
94+
parser (2.5.3.0)
9595
ast (~> 2.4.0)
9696
powerpack (0.1.2)
9797
pry (0.11.3)
@@ -106,7 +106,7 @@ GEM
106106
rails-html-sanitizer (1.0.4)
107107
loofah (~> 2.2, >= 2.2.2)
108108
rainbow (3.0.0)
109-
rake (0.9.6)
109+
rake (12.3.1)
110110
rb-fsevent (0.10.3)
111111
rb-inotify (0.9.10)
112112
ffi (>= 0.5.0, < 2)
@@ -154,13 +154,13 @@ PLATFORMS
154154
DEPENDENCIES
155155
active_model_serializers (~> 0.10.0.rc1)
156156
bundler (~> 1.16)
157-
coveralls (~> 0)
157+
coveralls
158158
guard
159159
guard-rspec
160160
guard-rubocop
161161
natra!
162162
pry
163-
rake (~> 0)
163+
rake
164164
rspec
165165

166166
BUNDLED WITH

Guardfile

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
# A sample Guardfile
2-
# More info at https://github.com/guard/guard#readme
3-
4-
## Uncomment and set this to only include directories you want to watch
5-
# directories %w(app lib config test spec features) \
6-
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7-
8-
## Note: if you are using the `directories` clause above and you are not
9-
## watching the project directory ('.'), then you will want to move
10-
## the Guardfile to a watched dir and symlink it back, e.g.
11-
#
12-
# $ mkdir config
13-
# $ mv Guardfile config/
14-
# $ ln -s config/Guardfile .
15-
#
16-
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17-
18-
# Note: The cmd option is now required due to the increasing number of ways
19-
# rspec may be run, below are examples of the most common uses.
20-
# * bundler: 'bundle exec rspec'
21-
# * bundler binstubs: 'bin/rspec'
22-
# * spring: 'bin/rspec' (This will use spring if running and you have
23-
# installed the spring binstubs per the docs)
24-
# * zeus: 'zeus rspec' (requires the server to be started separately)
25-
# * 'just' rspec: 'rspec'
26-
271
guard :rspec, cmd: "bundle exec rspec" do
282
require "guard/rspec/dsl"
293
dsl = Guard::RSpec::Dsl.new(self)

Rakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ require "bundler/gem_tasks"
22
require "rspec/core/rake_task"
33

44
RSpec::Core::RakeTask.new(:spec)
5-
6-
task :default => :spec
5+
task default: :spec

bin/console

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
2-
3-
require "bundler/setup"
4-
require "natra"
5-
require "pry"
2+
require 'bundler/setup'
3+
require 'natra'
4+
require 'pry'
65
Pry.start

bin/natra

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/usr/bin/env bash
2-
32
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4-
53
require "natra"
6-
74
Natra::CLI.start

bin/setup

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44
set -vx
5-
65
bundle install

lib/extensions/string.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ module String
44
def camel_case
55
return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
66
altered_self = self.downcase.capitalize
7-
altered_self.scan(/[_-][a-zA-Z]/).each do |match|
8-
altered_self.gsub!(match, match[1].upcase)
9-
end
10-
7+
altered_self.scan(/[_-][a-zA-Z]/).each { |match| altered_self.gsub!(match, match[1].upcase) }
118
altered_self
129
end
1310

lib/natra.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
require "extensions/string"
2-
require "natra/generators/app/app_generator"
3-
require "natra/generators/model/model_generator"
4-
require "natra/generators/scaffold/scaffold_generator"
5-
require "natra/generators/controller/controller_generator"
6-
require "natra/version"
7-
require "natra/cli"
8-
9-
module Natra; end
1+
require 'extensions/string'
2+
require 'natra/generators/app/app_generator'
3+
require 'natra/generators/model/model_generator'
4+
require 'natra/generators/scaffold/scaffold_generator'
5+
require 'natra/generators/controller/controller_generator'
6+
require 'natra/version'
7+
require 'natra/cli'
8+
module Natra; end

lib/natra/cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ module Natra
33
class CLI < Thor
44
desc '-v', 'Show Natra version number'
55
map %w[-v --version] => :version
6-
# USAGE: Natra -v
6+
77
def version
88
say "Natra #{Natra::VERSION}"
99
end
10-
# register(class_name, subcommand_alias, usage_list_string, description_string)
10+
1111
register Natra::Generators::AppGenerator, 'new', 'new APP_PATH', 'Creates a new Sinatra application'
1212
register Natra::Generators::ModelGenerator, 'model', 'model NAME', 'Generate a model'
1313
register Natra::Generators::ControllerGenerator, 'controller', 'controller NAME', 'Generate a controller'

lib/natra/generators/app/app_generator.rb

Lines changed: 48 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,127 @@
1-
# encoding: UTF-8
2-
require "thor/group"
3-
1+
require 'thor/group'
42
module Natra
53
module Generators
64
class AppGenerator < Thor::Group
75
include Thor::Actions
6+
desc 'Creates a new Sinatra application'
7+
argument :name, type: :string, desc: 'The name of the new application'
8+
class_option :capistrano, type: :boolean, desc: 'Include Capistrano configuration'
9+
class_option :redis, type: :boolean, desc: 'Include Redis configuration'
10+
class_option :rvm, type: :boolean, desc: 'Create .ruby-version (ruby-2.1.0) and .ruby-gemset'
11+
class_option :bundle, type: :boolean, desc: 'Run bundle after generating the app'
12+
class_option :git, type: :boolean, desc: 'Initialize a Git repository'
813

9-
desc "Creates a new Sinatra application"
10-
argument :name, :type => :string, :desc => "The name of the new application"
11-
class_option :capistrano, :type => :boolean, :desc => "Include Capistrano configuration"
12-
class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
13-
class_option :rvm, :type => :boolean, :desc => "Create .ruby-version (ruby-2.1.0) and .ruby-gemset"
14-
class_option :bundle, :type => :boolean, :desc => "Run bundle after generating the app"
15-
class_option :git, :type => :boolean, :desc => "Initialize a Git repository"
16-
17-
# Creates instance variables from options passed to natra.
1814
def setup
1915
@app_path = name.directory_name
2016
@name = name.file_name
21-
22-
options.each do |key, value|
23-
instance_variable_set "@#{key.to_s}".to_sym, value
24-
end
17+
options.each {|key, value| instance_variable_set "@#{key}".to_sym, value}
2518
end
2619

2720
def self.source_root
28-
File.expand_path(File.join(File.dirname(__FILE__), "templates"))
21+
File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
2922
end
3023

31-
# Create empty directories
3224
def create_empty_directories
33-
%w{config/initializers lib spec}.each do |dir|
34-
empty_directory File.join(@app_path, dir)
35-
end
36-
25+
%w[config/initializers lib spec].each {|dir| empty_directory File.join(@app_path, dir)}
3726
empty_directory File.join(@app_path, 'db/migrate')
38-
39-
create_file File.join(@app_path, "lib", ".keep")
40-
template "config/environment.rb", File.join(@app_path, "config/environment.rb")
27+
create_file File.join(@app_path, 'lib', '.keep')
28+
template 'config/environment.rb', File.join(@app_path, 'config/environment.rb')
4129
end
42-
30+
4331
def create_seeds_file
44-
create_file File.join(@app_path, "db", "seeds.rb")
32+
create_file File.join(@app_path, 'db', 'seeds.rb')
4533
end
4634

4735
def initialize_db
48-
copy_file('bin/setup', File.join(@app_path, "bin/setup"))
36+
copy_file('bin/setup', File.join(@app_path, 'bin/setup'))
4937
end
50-
38+
5139
def uuid_setup
52-
template 'db/migrate/add_extensions.rb', File.join(@app_path,"db/migrate/#{Time.now.strftime('%Y%m%d')}0000_add_extensions.rb")
40+
template 'db/migrate/add_extensions.rb', File.join(@app_path, "db/migrate/#{Time.now.strftime('%Y%m%d')}0000_add_extensions.rb")
5341
end
54-
42+
5543
def create_public_directory
56-
template "public/favicon.ico", File.join(@app_path, "public/favicon.ico")
44+
template 'public/favicon.ico', File.join(@app_path, 'public/favicon.ico')
5745
end
5846

5947
def create_app_directory
60-
%w{app/controllers app/views app/models}.each do |dir|
61-
directory dir, File.join(@app_path, dir)
62-
end
48+
%w[app/controllers app/views app/models].each {|dir| directory dir, File.join(@app_path, dir)}
6349
end
6450

6551
def create_app_spec
66-
template "spec/application_controller_spec.rb", File.join(@app_path, "spec/application_controller_spec.rb")
52+
template 'spec/application_controller_spec.rb', File.join(@app_path, 'spec/application_controller_spec.rb')
6753
end
6854

6955
def create_spec_helper
70-
template "spec/spec_helper.rb", File.join(@app_path, "spec/spec_helper.rb")
56+
template 'spec/spec_helper.rb', File.join(@app_path, 'spec/spec_helper.rb')
7157
end
7258

7359
def create_config
74-
template "config.ru", File.join(@app_path, "config.ru")
60+
template 'config.ru', File.join(@app_path, 'config.ru')
7561
end
7662

7763
def create_gemfile
78-
template "Gemfile", File.join(@app_path, "Gemfile")
64+
template 'Gemfile', File.join(@app_path, 'Gemfile')
7965
end
8066

8167
def create_rakefile
82-
template "Rakefile", File.join(@app_path, "Rakefile")
68+
template 'Rakefile', File.join(@app_path, 'Rakefile')
8369
end
8470

8571
def create_readme
86-
template("README.md", File.join(@app_path, "README.md"))
72+
template('README.md', File.join(@app_path, 'README.md'))
8773
end
8874

8975
def create_db_config
90-
template("config/db.yml", File.join(@app_path, "config/db.yml"))
76+
template('config/db.yml', File.join(@app_path, 'config/db.yml'))
9177
end
9278

9379
def create_database_initializer
94-
template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb"))
80+
template('config/initializers/database.rb', File.join(@app_path, 'config/initializers/database.rb'))
9581
end
9682

9783
def create_redis_config
98-
copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml")) if @redis
84+
copy_file('config/redis.yml', File.join(@app_path, 'config/redis.yml')) if @redis
9985
end
10086

10187
def create_redis_initializer
102-
template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) if @redis
88+
template('config/initializers/redis.rb', File.join(@app_path, 'config/initializers/redis.rb')) if @redis
10389
end
10490

10591
def create_gitignore
106-
copy_file "gitignore", File.join(@app_path, '.gitignore')
92+
copy_file 'gitignore', File.join(@app_path, '.gitignore')
10793
end
94+
10895
def create_rspec
10996
copy_file 'rspec', File.join(@app_path, '.rspec')
11097
end
98+
11199
def create_rubocop
112-
copy_file 'rubocop.yml', File.join(@app_path, '.rubocop.yml')
100+
copy_file 'rubocop.yml', File.join(@app_path, '.rubocop.yml')
113101
end
102+
114103
def create_docker
115104
copy_file 'Dockerfile', File.join(@app_path, 'Dockerfile')
116105
end
106+
117107
def create_docker_compose
118-
template('docker-compose.yml', File.join(@app_path, "docker-compose.yml"))
108+
template('docker-compose.yml', File.join(@app_path, 'docker-compose.yml'))
119109
end
110+
120111
def create_guardfile
121-
copy_file 'Guardfile',File.join(@app_path, 'Guardfile')
112+
copy_file 'Guardfile', File.join(@app_path, 'Guardfile')
122113
end
114+
123115
def create_spec_support
124-
create_file File.join(@app_path, "spec/support/", ".keep")
116+
create_file File.join(@app_path, 'spec/support/', '.keep')
125117
end
118+
126119
def create_secrets
127-
template('secrets.env',File.join(@app_path, "secrets.env"))
120+
template('secrets.env', File.join(@app_path, 'secrets.env'))
128121
end
129-
122+
130123
def create_capistrano_config
131-
if @capistrano
132-
inside(@app_path) do
133-
run('cap install')
134-
end
135-
end
124+
inside(@app_path) {run('cap install')} if @capistrano
136125
end
137126

138127
def create_rvm_gemset
@@ -146,15 +135,11 @@ def create_rvm_gemset
146135
end
147136

148137
def initialize_git_repo
149-
inside(@app_path) do
150-
run('git init .') if @git
151-
end
138+
inside(@app_path) {run('git init .') if @git}
152139
end
153140

154141
def install_dependencies
155-
inside(@app_path) do
156-
run('bundle') if @bundle
157-
end
142+
inside(@app_path) {run('bundle') if @bundle}
158143
end
159144
end
160145
end

lib/natra/generators/app/templates/public/images/.gitkeep

Whitespace-only changes.
Binary file not shown.

lib/natra/generators/app/templates/public/javascripts/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)