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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfa66b986d9be4a562441f4a8cefa037157fa1d1
4
- data.tar.gz: fb7ca6b80c97db13a2c4c5599d47048af6dd25e5
3
+ metadata.gz: 2d634770520823637117d32942c84f29cd15740e
4
+ data.tar.gz: 618f117c5bb039b5e5dcc1fed4dcfec5de815ada
5
5
  SHA512:
6
- metadata.gz: cd83409985e59042d6a9b7523597e3c80c3d58476a901e18deee2bf8666b5ce358fc2629028ad20855f8e9209b85be80fc97fdeb7a5c3c70f0a58af9e855e6e1
7
- data.tar.gz: b1aebf7cf96b7a5880c930f8ed16bbcc9d2c9bf3e10d7d83c31e14ea95d87aeb5beb919be989b6d2a1aa7dbcc9618daa4bfeb835c603253707a8ce59f323512e
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
 
@@ -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']
@@ -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
@@ -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"
@@ -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
- FileUtils.mkdir_p @path
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
@@ -1,11 +1,17 @@
1
1
  module Skellington
2
2
  class Template
3
- attr_reader :name
4
- attr_accessor :params, :outpath
5
-
6
- def initialize name
3
+ def initialize name, generator
7
4
  @name = name
8
- @outpath = name
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
- FileUtils.mkdir_p File.dirname @outpath
17
- f = File.open @outpath, 'w'
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).result(@params)
32
+ Erubis::Eruby.new(t).evaluate(gen: @generator)
25
33
  end
26
34
  end
27
35
  end
@@ -1,3 +1,3 @@
1
1
  module Skellington
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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/<%= filename %>.rb
1
+ web: bundle exec ruby lib/<%= @gen.path %>.rb
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'lib/<%= filename %>.rb')
1
+ require File.join(File.dirname(__FILE__), 'lib/<%= @gen.path %>.rb')
2
2
 
3
3
  unless ENV['RACK_ENV'] == 'production'
4
4
  require 'rspec/core/rake_task'
@@ -1,4 +1,4 @@
1
1
  require 'rubygems'
2
- require File.join(File.dirname(__FILE__), 'lib/<%= filename %>.rb')
2
+ require File.join(File.dirname(__FILE__), 'lib/<%= @gen.path %>.rb')
3
3
 
4
- run <%= camel_name %>
4
+ run <%= @gen.camelname %>
@@ -1,24 +1,24 @@
1
1
  ENV['RACK_ENV'] = 'test'
2
2
 
3
- require File.join(File.dirname(__FILE__), '..', '..', 'lib/<%= filename %>.rb')
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 = <%= camel_name %>
10
+ Capybara.app = <%= @gen.camelname %>
11
11
 
12
- class <%= camel_name %>World
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
- <%= camel_name %>
18
+ <%= @gen.camelname %>
19
19
  end
20
20
  end
21
21
 
22
22
  World do
23
- <%= camel_name %>World.new
23
+ <%= @gen.camelname %>World.new
24
24
  end
@@ -1,8 +1,8 @@
1
1
  require 'sinatra/base'
2
2
 
3
- class <%= camel_name %> < Sinatra::Base
3
+ class <%= @gen.camelname %> < Sinatra::Base
4
4
  get '/' do
5
- 'Hello from <%= camel_name %>'
5
+ 'Hello from <%= @gen.camelname %>'
6
6
  end
7
7
 
8
8
  # start the server if ruby file executed directly
@@ -1,7 +1,7 @@
1
1
 
2
2
  Now do
3
3
 
4
- cd <%= path %>
4
+ cd <%= @gen.path %>
5
5
  bundle
6
6
  rake
7
7
 
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.7
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-18 00:00:00.000000000 Z
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
@@ -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