skellington 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile.ffs +10 -0
- data/config/config.yaml +15 -0
- data/features/cli.feature +4 -0
- data/lib/skellington/cli.rb +6 -1
- data/lib/skellington/generator.rb +6 -50
- data/lib/skellington/template.rb +16 -8
- data/lib/skellington/version.rb +1 -1
- data/lib/templates/Gemfile.eruby +3 -3
- data/lib/templates/Procfile.eruby +1 -1
- data/lib/templates/Rakefile.eruby +1 -1
- data/lib/templates/config.ru.eruby +2 -2
- data/lib/templates/features/support/env.rb.eruby +5 -5
- data/lib/templates/lib/app.rb.eruby +2 -2
- data/lib/templates/post-run.eruby +1 -1
- metadata +3 -6
- data/features/support/app.feature +0 -0
- data/spec/template_spec.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d634770520823637117d32942c84f29cd15740e
|
4
|
+
data.tar.gz: 618f117c5bb039b5e5dcc1fed4dcfec5de815ada
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2bb033889136de1c888617453e28a2ec16f781baa00915e0487a243a7c049d728ff9542947e8839a5c8c004a5a75cead4cf13915199d07dae152b7599c4f81d
|
7
|
+
data.tar.gz: 47991b1a4baf4518c5741e1dacdb9d66c5da2384c6e0cd7ef75735c8a452c4e3a83d655a72689eee948728d2a2378e23195f9a50b234f617453a293a04ab8e79
|
data/README.md
CHANGED
@@ -20,6 +20,7 @@ Generate tedious [Cucumber](http://cukes.info/) and [Sinatra](http://www.sinatra
|
|
20
20
|
Generating naming_things_is_hard/features/naming_things_is_hard.feature...done
|
21
21
|
Generating naming_things_is_hard/features/support/env.rb...done
|
22
22
|
Generating naming_things_is_hard/lib/naming_things_is_hard.rb...done
|
23
|
+
Generating naming_things_is_hard/.ruby-version...done
|
23
24
|
|
24
25
|
Your new Sinatra app 'NamingThingsIsHard' has been created
|
25
26
|
|
data/Rakefile.ffs
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
require 'coveralls/rake/task'
|
5
|
+
|
6
|
+
Coveralls::RakeTask.new
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
Cucumber::Rake::Task.new
|
9
|
+
|
10
|
+
task :default => [:spec, :cucumber, 'coveralls:push']
|
data/config/config.yaml
CHANGED
@@ -11,3 +11,18 @@ gems:
|
|
11
11
|
|
12
12
|
test_require_false:
|
13
13
|
- cucumber-api-steps
|
14
|
+
|
15
|
+
files:
|
16
|
+
Gemfile:
|
17
|
+
Rakefile:
|
18
|
+
Procfile:
|
19
|
+
.ruby-version:
|
20
|
+
config.ru:
|
21
|
+
# the template has this name
|
22
|
+
features/first.feature:
|
23
|
+
# but the output file substitutes it like this, where path is an attribute
|
24
|
+
# on the Generator object
|
25
|
+
outpath: first/path
|
26
|
+
features/support/env.rb:
|
27
|
+
lib/app.rb:
|
28
|
+
outpath: app/path
|
data/features/cli.feature
CHANGED
@@ -5,3 +5,7 @@ Feature: Generate skellington
|
|
5
5
|
Then the output should contain "Generating dummy_gem/Gemfile"
|
6
6
|
And the output should contain "bundle"
|
7
7
|
And the output should contain "rake"
|
8
|
+
|
9
|
+
Scenario: get the version
|
10
|
+
When I successfully run `skellington -v`
|
11
|
+
Then the output should contain "skellington version"
|
data/lib/skellington/cli.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
module Skellington
|
2
2
|
class CLI < Thor
|
3
|
+
desc 'version', 'Print the version'
|
4
|
+
def version
|
5
|
+
puts "skellington version #{VERSION}"
|
6
|
+
end
|
7
|
+
map %w(-v --version) => :version
|
8
|
+
|
3
9
|
desc 'generate PATH', 'Generate a skeleton Sinatra app at PATH'
|
4
10
|
def generate path
|
5
11
|
@g = Generator.new path
|
6
12
|
@g.run
|
7
|
-
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
@@ -1,50 +1,12 @@
|
|
1
1
|
module Skellington
|
2
2
|
class Generator
|
3
|
+
attr_accessor :config, :path, :camelname, :files
|
4
|
+
|
3
5
|
def initialize path
|
4
6
|
@path = path
|
5
|
-
|
6
|
-
|
7
|
+
@camelname = Skellington.camelise(@path)
|
7
8
|
@config = YAML.load File.read File.join File.dirname(__FILE__), '..', '..', 'config/config.yaml'
|
8
|
-
|
9
|
-
@files = {
|
10
|
-
'Gemfile'=> {
|
11
|
-
params: {
|
12
|
-
config: @config
|
13
|
-
}
|
14
|
-
},
|
15
|
-
'Rakefile' => {
|
16
|
-
params: {
|
17
|
-
filename: @path
|
18
|
-
}
|
19
|
-
},
|
20
|
-
'Procfile' => {
|
21
|
-
params: {
|
22
|
-
filename: @path
|
23
|
-
}
|
24
|
-
},
|
25
|
-
'config.ru' => {
|
26
|
-
params: {
|
27
|
-
filename: @path,
|
28
|
-
camel_name: Skellington.camelise(@path)
|
29
|
-
}
|
30
|
-
},
|
31
|
-
'features/first.feature' => {
|
32
|
-
outpath: "features/#{@path}.feature"
|
33
|
-
},
|
34
|
-
'features/support/env.rb' => {
|
35
|
-
params: {
|
36
|
-
filename: @path,
|
37
|
-
camel_name: Skellington.camelise(@path)
|
38
|
-
}
|
39
|
-
},
|
40
|
-
'lib/app.rb' => {
|
41
|
-
params: {
|
42
|
-
camel_name: Skellington.camelise(@path)
|
43
|
-
},
|
44
|
-
outpath: "lib/#{@path}.rb"
|
45
|
-
},
|
46
|
-
'.ruby-version' => {}
|
47
|
-
}
|
9
|
+
@files = @config['files']
|
48
10
|
end
|
49
11
|
|
50
12
|
def run
|
@@ -56,13 +18,8 @@ module Skellington
|
|
56
18
|
def generate
|
57
19
|
puts ''
|
58
20
|
@files.each do |k, v|
|
59
|
-
t = Template.new k
|
60
|
-
t.params = v[:params]
|
61
|
-
t.outpath = "#{@path}/#{k}"
|
62
|
-
t.outpath = "#{@path}/#{v[:outpath]}" if v[:outpath]
|
63
|
-
print "Generating #{t.outpath}..."
|
21
|
+
t = Template.new k, self
|
64
22
|
t.write
|
65
|
-
puts 'done'
|
66
23
|
end
|
67
24
|
end
|
68
25
|
|
@@ -73,8 +30,7 @@ module Skellington
|
|
73
30
|
def post_run
|
74
31
|
puts ''
|
75
32
|
puts "Your new Sinatra app '#{Skellington.camelise(@path)}' has been created"
|
76
|
-
t = Template.new 'post-run'
|
77
|
-
t.params = { path: @path }
|
33
|
+
t = Template.new 'post-run', self
|
78
34
|
puts t.to_s
|
79
35
|
puts ''
|
80
36
|
end
|
data/lib/skellington/template.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
module Skellington
|
2
2
|
class Template
|
3
|
-
|
4
|
-
attr_accessor :params, :outpath
|
5
|
-
|
6
|
-
def initialize name
|
3
|
+
def initialize name, generator
|
7
4
|
@name = name
|
8
|
-
@
|
5
|
+
@generator = generator
|
6
|
+
end
|
7
|
+
|
8
|
+
def outpath
|
9
|
+
@outpath ||= begin
|
10
|
+
subs = @generator.files[@name]['outpath'].split '/'
|
11
|
+
@outpath = "#{@generator.send(subs[1].to_sym)}/#{@name.sub(subs[0], @generator.send(subs[1].to_sym))}"
|
12
|
+
rescue NoMethodError
|
13
|
+
@outpath = "#{@generator.path}/#{@name}"
|
14
|
+
end
|
9
15
|
end
|
10
16
|
|
11
17
|
def templates_dir
|
@@ -13,15 +19,17 @@ module Skellington
|
|
13
19
|
end
|
14
20
|
|
15
21
|
def write
|
16
|
-
|
17
|
-
|
22
|
+
print "Generating #{outpath}..."
|
23
|
+
FileUtils.mkdir_p File.dirname outpath
|
24
|
+
f = File.open outpath, 'w'
|
18
25
|
f.write self
|
19
26
|
f.close
|
27
|
+
puts 'done'
|
20
28
|
end
|
21
29
|
|
22
30
|
def to_s
|
23
31
|
t = File.read(File.open("#{templates_dir}/#{@name}.eruby"))
|
24
|
-
Erubis::Eruby.new(t).
|
32
|
+
Erubis::Eruby.new(t).evaluate(gen: @generator)
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
data/lib/skellington/version.rb
CHANGED
data/lib/templates/Gemfile.eruby
CHANGED
@@ -2,15 +2,15 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
ruby '<%= RUBY_VERSION %>'
|
4
4
|
|
5
|
-
<% for gem in config['gems']['production'] %>
|
5
|
+
<% for gem in @gen.config['gems']['production'] %>
|
6
6
|
gem '<%= gem %>'
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
<% for gem in config['gems']['test'] %>
|
10
|
+
<% for gem in @gen.config['gems']['test'] %>
|
11
11
|
gem '<%= gem %>'
|
12
12
|
<% end %>
|
13
|
-
<% for gem in config['gems']['test_require_false'] %>
|
13
|
+
<% for gem in @gen.config['gems']['test_require_false'] %>
|
14
14
|
gem '<%= gem %>', require: false
|
15
15
|
<% end %>
|
16
16
|
end
|
@@ -1 +1 @@
|
|
1
|
-
web: bundle exec ruby lib/<%=
|
1
|
+
web: bundle exec ruby lib/<%= @gen.path %>.rb
|
@@ -1,24 +1,24 @@
|
|
1
1
|
ENV['RACK_ENV'] = 'test'
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/<%=
|
3
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'lib/<%= @gen.path %>.rb')
|
4
4
|
|
5
5
|
require 'capybara'
|
6
6
|
require 'capybara/cucumber'
|
7
7
|
require 'rspec'
|
8
8
|
require 'cucumber/api_steps'
|
9
9
|
|
10
|
-
Capybara.app = <%=
|
10
|
+
Capybara.app = <%= @gen.camelname %>
|
11
11
|
|
12
|
-
class <%=
|
12
|
+
class <%= @gen.camelname %>World
|
13
13
|
include Capybara::DSL
|
14
14
|
include RSpec::Expectations
|
15
15
|
include RSpec::Matchers
|
16
16
|
|
17
17
|
def app
|
18
|
-
<%=
|
18
|
+
<%= @gen.camelname %>
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
World do
|
23
|
-
<%=
|
23
|
+
<%= @gen.camelname %>World.new
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skellington
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pikesley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- LICENSE.txt
|
182
182
|
- README.md
|
183
183
|
- Rakefile
|
184
|
+
- Rakefile.ffs
|
184
185
|
- bin/skellington
|
185
186
|
- config/config.yaml
|
186
187
|
- features/app.feature
|
@@ -192,7 +193,6 @@ files:
|
|
192
193
|
- features/procfile.feature
|
193
194
|
- features/rakefile.feature
|
194
195
|
- features/rbenv.feature
|
195
|
-
- features/support/app.feature
|
196
196
|
- features/support/env.rb
|
197
197
|
- lib/skellington.rb
|
198
198
|
- lib/skellington/cli.rb
|
@@ -212,7 +212,6 @@ files:
|
|
212
212
|
- skellington.gemspec
|
213
213
|
- spec/skellington_spec.rb
|
214
214
|
- spec/spec_helper.rb
|
215
|
-
- spec/template_spec.rb
|
216
215
|
homepage: ''
|
217
216
|
licenses:
|
218
217
|
- MIT
|
@@ -247,8 +246,6 @@ test_files:
|
|
247
246
|
- features/procfile.feature
|
248
247
|
- features/rakefile.feature
|
249
248
|
- features/rbenv.feature
|
250
|
-
- features/support/app.feature
|
251
249
|
- features/support/env.rb
|
252
250
|
- spec/skellington_spec.rb
|
253
251
|
- spec/spec_helper.rb
|
254
|
-
- spec/template_spec.rb
|
File without changes
|
data/spec/template_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Skellington
|
4
|
-
describe Template do
|
5
|
-
before :each do
|
6
|
-
@t = Template.new 'Rakefile'
|
7
|
-
@t.params = { filename: 'dummy_gem' }
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'has a name' do
|
11
|
-
expect(@t.name).to eq 'Rakefile'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'takes variables' do
|
15
|
-
expect(@t.params[:filename]).to eq 'dummy_gem'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'produces output' do
|
19
|
-
expect(@t.to_s).to match /require File.join\(File.dirname\(__FILE__\), 'lib\/dummy_gem.rb'\)/
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'writes to a file' do
|
23
|
-
@t.outpath = 'tmp/Rakefile'
|
24
|
-
@t.write
|
25
|
-
expect(File).to exist 'tmp/Rakefile'
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'behaves well with a more complex name' do
|
29
|
-
@t = Template.new 'features/first.feature'
|
30
|
-
@t.outpath = 'tmp/features/dummy_gem.feature'
|
31
|
-
@t.write
|
32
|
-
expect(File).to exist 'tmp/features/dummy_gem.feature'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|