hisyo 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/Changes +4 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +2 -0
- data/README.mkd +15 -22
- data/Rakefile +11 -0
- data/data/generators/project/Gemfile +0 -1
- data/data/generators/project/app/app.rb +17 -3
- data/data/generators/project/app/controllers.rb +11 -0
- data/data/generators/project/app/helpers.rb +3 -3
- data/data/generators/project/app/views/index.str +1 -0
- data/data/generators/project/config.ru +1 -3
- data/data/generators/project/config/boot.rb +2 -1
- data/data/generators/project/spec/spec_helper.rb +0 -7
- data/hisyo.gemspec +1 -1
- data/lib/hisyo/cli.rb +3 -3
- data/lib/hisyo/generator.rb +4 -0
- data/lib/hisyo/version.rb +1 -1
- data/spec/generated_app_spec.rb +35 -15
- data/spec/generator_spec.rb +15 -17
- data/spec/spec_helper.rb +10 -1
- metadata +8 -4
- data/lib/hisyo/application.rb +0 -24
data/.travis.yml
ADDED
data/Changes
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
rack
|
11
11
|
rack-test (0.6.1)
|
12
12
|
rack (>= 1.0)
|
13
|
+
rake (0.9.2.2)
|
13
14
|
rspec (2.10.0)
|
14
15
|
rspec-core (~> 2.10.0)
|
15
16
|
rspec-expectations (~> 2.10.0)
|
@@ -40,6 +41,7 @@ PLATFORMS
|
|
40
41
|
|
41
42
|
DEPENDENCIES
|
42
43
|
rack-test
|
44
|
+
rake
|
43
45
|
rspec
|
44
46
|
simplecov
|
45
47
|
sinatra
|
data/README.mkd
CHANGED
@@ -1,34 +1,25 @@
|
|
1
|
-
|
1
|
+
[![Travis CI Build Status](https://secure.travis-ci.org/uu59/hisyo.png?branch=master)](http://travis-ci.org/uu59/hisyo)
|
2
|
+
|
3
|
+
Hisyo is a generator that for your Sinatra project to play.
|
2
4
|
|
3
5
|
$ gem install hisyo
|
4
6
|
$ rbenv rehash; rehash; # if necessary
|
5
|
-
$ hisyo -
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
create: public/
|
10
|
-
create: spec/
|
11
|
-
create: app/views/
|
12
|
-
create: app/assets/
|
13
|
-
create: db/
|
14
|
-
create: tmp/
|
15
|
-
create: log/
|
16
|
-
copy to: spec/spec_helper.rb
|
17
|
-
copy to: spec/hello_spec.rb
|
18
|
-
copy to: config.ru
|
19
|
-
copy to: config/boot.rb
|
20
|
-
copy to: Gemfile
|
21
|
-
copy to: app/helpers.rb
|
22
|
-
copy to: app/app.rb
|
7
|
+
$ hisyo -r ~/myapp
|
8
|
+
Complete.
|
9
|
+
$ cd ~/myapp
|
10
|
+
$ rackup (or `rspec spec/`, `vim app/helpers.rb`, etc)
|
23
11
|
$ cd ~/myapp
|
24
|
-
$ tree -
|
12
|
+
$ tree -Fa
|
25
13
|
.
|
14
|
+
├── .gitignore
|
26
15
|
├── Gemfile
|
27
16
|
├── app/
|
28
17
|
│ ├── app.rb
|
29
18
|
│ ├── assets/
|
19
|
+
│ ├── controllers.rb
|
30
20
|
│ ├── helpers.rb
|
31
21
|
│ └── views/
|
22
|
+
│ └── index.str
|
32
23
|
├── config/
|
33
24
|
│ └── boot.rb
|
34
25
|
├── config.ru
|
@@ -42,10 +33,12 @@ Hisyo is a thin wrapper for your Sinatra project
|
|
42
33
|
├── tmp/
|
43
34
|
└── views/
|
44
35
|
|
45
|
-
11 directories,
|
36
|
+
11 directories, 10 files
|
37
|
+
|
46
38
|
$ rackup
|
47
39
|
[2012-05-28 02:24:32] INFO WEBrick 1.3.1
|
48
40
|
[2012-05-28 02:24:32] INFO ruby 1.9.3 (2012-02-16) [x86_64-linux]
|
49
41
|
[2012-05-28 02:24:32] INFO WEBrick::HTTPServer#start: pid=11232 port=9292
|
50
42
|
|
51
|
-
|
43
|
+
Generated project(as below) is a purely Sinatra application.
|
44
|
+
That means you can `gem uninstall hisyo` after generation.
|
data/Rakefile
ADDED
@@ -1,5 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Feel free to rename from "MyApp" to anything
|
2
|
+
# if so, remember changing config.ru, config/boot.rb
|
3
|
+
class MyApp < Sinatra::Application
|
4
|
+
set :root, File.expand_path("../../", __FILE__)
|
5
|
+
set :views, File.join(root, "app/views")
|
6
|
+
set :public_folder, File.join(root, "public")
|
7
|
+
|
8
|
+
def self.controllers(&block)
|
9
|
+
instance_eval &block
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.setup
|
13
|
+
%w!config lib app!.each do |dir|
|
14
|
+
Dir.glob("#{root}/#{dir}/**/*.rb") do |file|
|
15
|
+
require file
|
16
|
+
end
|
17
|
+
end
|
4
18
|
end
|
5
19
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello, MyApp!
|
data/hisyo.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["k@uu59.org"]
|
7
7
|
gem.description = %q{Create simple Sinatra project template}
|
8
8
|
gem.summary = %q{Create simple Sinatra project template}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/uu59/hisyo"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/hisyo/cli.rb
CHANGED
@@ -9,9 +9,9 @@ module Hisyo
|
|
9
9
|
def self.parse_options(argv)
|
10
10
|
options = {}
|
11
11
|
OptionParser.new do |opts|
|
12
|
-
opts.on('-n', '--dry-run', '
|
13
|
-
opts.on('-v', '--verbose', '
|
14
|
-
opts.on('-r VAL', '--root=VAL', '
|
12
|
+
opts.on('-n', '--dry-run', 'Do not actually run'){|v| options[:dryrun] = true}
|
13
|
+
opts.on('-v', '--verbose', 'Verbose mode'){|v| options[:verbose] = true}
|
14
|
+
opts.on('-r VAL', '--root=VAL', 'Application root directory'){|v| options[:root] = v}
|
15
15
|
opts.parse!(argv)
|
16
16
|
end
|
17
17
|
options
|
data/lib/hisyo/generator.rb
CHANGED
data/lib/hisyo/version.rb
CHANGED
data/spec/generated_app_spec.rb
CHANGED
@@ -1,29 +1,49 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Hisyo
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
describe "Hisyo generated app" do
|
4
|
+
def genapp(&block)
|
5
|
+
pending "jruby does not support fork" if defined? JRUBY_VERSION
|
6
|
+
pid = fork do
|
7
|
+
generate_app(
|
8
|
+
:root => @approot,
|
9
|
+
)
|
10
|
+
@mock = Class.new
|
11
|
+
configru = "#{@approot}/config.ru"
|
12
|
+
bootrb = "#{@approot}/config/boot.rb"
|
13
|
+
@mock.class_eval do
|
14
|
+
require bootrb
|
15
|
+
|
16
|
+
include Rack::Test::Methods
|
17
|
+
@configru = configru
|
18
|
+
|
19
|
+
def self.configru
|
20
|
+
@configru
|
21
|
+
end
|
22
|
+
|
23
|
+
def app
|
24
|
+
Rack::Builder.parse_file(self.class.configru).first
|
25
|
+
end
|
15
26
|
end
|
27
|
+
@mock.new.instance_eval &block
|
16
28
|
end
|
29
|
+
Process.wait pid
|
17
30
|
end
|
18
31
|
|
19
32
|
after(:each) do
|
20
|
-
|
33
|
+
FileUtils.rm_rf @approot
|
21
34
|
end
|
22
35
|
|
23
36
|
it "should rackup" do
|
24
|
-
|
37
|
+
genapp do
|
25
38
|
get "/"
|
26
|
-
last_response.body.should == "Hello, MyApp!"
|
39
|
+
last_response.body.rstrip.should == "Hello, MyApp!"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "controllers" do
|
44
|
+
genapp do
|
45
|
+
get "/hi/uu59"
|
46
|
+
last_response.body.should == "Hi, uu59!"
|
27
47
|
end
|
28
48
|
end
|
29
49
|
end
|
data/spec/generator_spec.rb
CHANGED
@@ -2,11 +2,11 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "Hisyo.generate_project" do
|
4
4
|
after(:each) do
|
5
|
-
|
5
|
+
FileUtils.rm_rf @approot
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should same data/ and approot/" do
|
9
|
-
|
9
|
+
generate_app(
|
10
10
|
:root => @approot,
|
11
11
|
)
|
12
12
|
dest= Dir.glob("#{@approot}/**/*", File::FNM_DOTMATCH).find_all{|f| File.file?(f)}.map{|f| f.gsub(@approot, "")}
|
@@ -16,7 +16,7 @@ describe "Hisyo.generate_project" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should not create files when :dryrun option given" do
|
19
|
-
|
19
|
+
generate_app(
|
20
20
|
:root => @approot,
|
21
21
|
:dryrun => true,
|
22
22
|
)
|
@@ -24,20 +24,18 @@ describe "Hisyo.generate_project" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should skip if file exists" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
)
|
32
|
-
end
|
33
|
-
out.split("\n").map{|line| line.gsub(/\e\[\d+m/, "")}.map{|line| line.split(": ").first}.uniq.should == ["create", "copy to"]
|
27
|
+
generate_app(
|
28
|
+
:root => @approot,
|
29
|
+
:verbose => true,
|
30
|
+
)
|
34
31
|
|
35
|
-
out,err =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
out, err = generate_app(
|
33
|
+
:root => @approot,
|
34
|
+
:verbose => true,
|
35
|
+
)
|
36
|
+
messages = out.split("\n").map{|line| line.gsub(/\e\[\d+m/, "")}.map{|line| line.split(": ").first}.uniq
|
37
|
+
messages.include?("copy to").should be_false
|
38
|
+
messages.include?("create").should be_false
|
39
|
+
messages.include?("skip").should be_true
|
42
40
|
end
|
43
41
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "bundler/setup"
|
3
3
|
Bundler.require(:default, :test)
|
4
|
-
|
4
|
+
if ENV["COVERAGE"]
|
5
|
+
require "simplecov"
|
6
|
+
SimpleCov.start
|
7
|
+
end
|
5
8
|
require File.expand_path("../../lib/hisyo.rb", __FILE__)
|
6
9
|
|
7
10
|
|
@@ -35,4 +38,10 @@ RSpec.configure do |conf|
|
|
35
38
|
$stderr = orig_stderr
|
36
39
|
end
|
37
40
|
|
41
|
+
def generate_app(options = {})
|
42
|
+
capture_io do
|
43
|
+
Hisyo.generate_project(options)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
38
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hisyo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Create simple Sinatra project template
|
15
15
|
email:
|
@@ -20,22 +20,26 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- .gitignore
|
23
|
+
- .travis.yml
|
24
|
+
- Changes
|
23
25
|
- Gemfile
|
24
26
|
- Gemfile.lock
|
25
27
|
- LICENSE
|
26
28
|
- README.mkd
|
29
|
+
- Rakefile
|
27
30
|
- bin/hisyo
|
28
31
|
- data/generators/project/.gitignore
|
29
32
|
- data/generators/project/Gemfile
|
30
33
|
- data/generators/project/app/app.rb
|
34
|
+
- data/generators/project/app/controllers.rb
|
31
35
|
- data/generators/project/app/helpers.rb
|
36
|
+
- data/generators/project/app/views/index.str
|
32
37
|
- data/generators/project/config.ru
|
33
38
|
- data/generators/project/config/boot.rb
|
34
39
|
- data/generators/project/spec/hello_spec.rb
|
35
40
|
- data/generators/project/spec/spec_helper.rb
|
36
41
|
- hisyo.gemspec
|
37
42
|
- lib/hisyo.rb
|
38
|
-
- lib/hisyo/application.rb
|
39
43
|
- lib/hisyo/cli.rb
|
40
44
|
- lib/hisyo/generator.rb
|
41
45
|
- lib/hisyo/version.rb
|
@@ -43,7 +47,7 @@ files:
|
|
43
47
|
- spec/generated_app_spec.rb
|
44
48
|
- spec/generator_spec.rb
|
45
49
|
- spec/spec_helper.rb
|
46
|
-
homepage:
|
50
|
+
homepage: https://github.com/uu59/hisyo
|
47
51
|
licenses: []
|
48
52
|
post_install_message:
|
49
53
|
rdoc_options: []
|
data/lib/hisyo/application.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Hisyo
|
2
|
-
class Application < Sinatra::Base
|
3
|
-
end
|
4
|
-
|
5
|
-
def self.env
|
6
|
-
@env ||= ENV["RACK_ENV"] ||= "development"
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.setup
|
10
|
-
bootrb = caller.first.split(/:[0-9]+:/).first
|
11
|
-
approot = bootrb.gsub("/config/boot.rb", "")
|
12
|
-
%w!config lib app!.each do |dir|
|
13
|
-
Dir.glob("#{approot}/#{dir}/**/*.rb") do |file|
|
14
|
-
require file
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Hisyo::Application.instance_eval do
|
19
|
-
set :root, approot
|
20
|
-
set :views, File.join(approot, "app/views")
|
21
|
-
set :public_folder, File.join(approot, "public")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|