skellington 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb5e9473127a2b2599ce62803a607be9cc662491
4
- data.tar.gz: adde90372e7c6061d5397d2361731c1b7727e6ad
3
+ metadata.gz: ebe62e8d497b68c839729162c81cb23103697759
4
+ data.tar.gz: b459a386d94e4789cb0c8722ce34310e5884a3ce
5
5
  SHA512:
6
- metadata.gz: fe4cf9231c8a5d2425b309ed5b893125ca72e3f8eedca0e8aff90e1cbf7718b48792c81c399e41d87755fb4fc950d6aa3d16d5453faa8c0ed4cb1190e641d56b
7
- data.tar.gz: 1d6ff3d2f35c34db4bbdde3545580d05bf2721764742bf64d99d826421ab4804c7c2f4411e389944c5b88e8d9fdadf6d3955787fcafa2f373dbac49472834dba
6
+ metadata.gz: ad36570bf89289381d4b0bbe7e72d7366c2e75febfb12dd38a040a9aa6b6d981e82aad119b096b21bc4fac4451c0929dce6526fbfe6b968108d64faa3d272466
7
+ data.tar.gz: 57f8e3b4333e8aff3290b8be31cede0c3dc961a7bcb7df4d53591fb06cab687f79decbd5c7aab3f10f9f0bf5c6d55d52dfc185c8c97cb5ce615ad8d618e07a01
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/README.md CHANGED
@@ -1,31 +1,10 @@
1
- # Skellington
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'skellington'
11
- ```
12
-
13
- And then execute:
1
+ [![Build Status](http://img.shields.io/travis/pikesley/skellington.svg)](https://travis-ci.org/pikesley/skellington)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/pikesley/skellington.svg)](https://gemnasium.com/pikesley/skellington)
3
+ [![Code Climate](http://img.shields.io/codeclimate/github/pikesley/skellington.svg)](https://codeclimate.com/github/pikesley/skellington)
4
+ [![Gem Version](http://img.shields.io/gem/v/skellington.svg)](https://rubygems.org/gems/skellington)
5
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://pikesley.mit-license.org)
6
+ [![Badges](http://img.shields.io/:badges-6/6-ff6799.svg)](https://github.com/badges/badgerbadgerbadger)
14
7
 
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install skellington
20
-
21
- ## Usage
22
-
23
- TODO: Write usage instructions here
24
-
25
- ## Contributing
8
+ # Skellington
26
9
 
27
- 1. Fork it ( https://github.com/[my-github-username]/skellington/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
10
+ Zero to cuke-powered Sinatra starter app
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber/rake/task'
2
4
 
5
+ RSpec::Core::RakeTask.new
6
+ Cucumber::Rake::Task.new
7
+
8
+ task :default => [:spec, :cucumber]
@@ -0,0 +1,19 @@
1
+ Feature: Generate skellington
2
+
3
+ Scenario: generate app file
4
+ When I successfully run `skellington generate dummy_gem`
5
+ Then a directory named "dummy_gem/lib/" should exist
6
+ And a file named "dummy_gem/lib/dummy_gem.rb" should exist
7
+ And the file "dummy_gem/lib/dummy_gem.rb" should contain:
8
+ """
9
+ require 'sinatra/base'
10
+
11
+ class DummyGem < Sinatra::Base
12
+ get '/' do
13
+ 'Hello from DummyGem'
14
+ end
15
+
16
+ # start the server if ruby file executed directly
17
+ run! if app_file == $0
18
+ end
19
+ """
@@ -0,0 +1,12 @@
1
+ Feature: Generate skellington
2
+
3
+ Scenario: generate config.ru
4
+ When I successfully run `skellington generate dummy_gem`
5
+ Then a file named "dummy_gem/config.ru" should exist
6
+ And the file "dummy_gem/config.ru" should contain:
7
+ """
8
+ require 'rubygems'
9
+ require File.join(File.dirname(__FILE__), 'lib/dummy_gem.rb')
10
+
11
+ run DummyGem
12
+ """
@@ -0,0 +1,22 @@
1
+ Feature: Generate skellington
2
+
3
+ Scenario: generate feature
4
+ When I successfully run `skellington generate dummy_gem`
5
+ Then a directory named "dummy_gem/features" should exist
6
+ And a file named "dummy_gem/features/dummy_gem.feature" should exist
7
+ And the file "dummy_gem/features/dummy_gem.feature" should contain:
8
+ """
9
+ Feature: Make sure it's plumbed in correctly
10
+
11
+ Scenario: Get root
12
+ When I send a GET request to "/"
13
+ Then the response status should be "200"
14
+ """
15
+
16
+ Scenario: generate env.rb
17
+ When I successfully run `skellington generate dummy_gem`
18
+ And a file named "dummy_gem/features/support/env.rb" should exist
19
+ And the file "dummy_gem/features/support/env.rb" should contain:
20
+ """
21
+ DummyGem
22
+ """
@@ -7,7 +7,7 @@ Feature: Generate skellington
7
7
  """
8
8
  source 'https://rubygems.org'
9
9
 
10
- ruby
10
+ ruby '
11
11
  """
12
12
 
13
13
  And the file "dummy_gem/Gemfile" should contain:
File without changes
data/lib/skellington.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'thor'
2
2
  require 'yaml'
3
+ require 'fileutils'
3
4
  require 'erubis'
4
5
 
5
6
  require 'skellington/version'
6
7
  require 'skellington/generator'
7
8
  require 'skellington/cli'
9
+ require 'skellington/template'
@@ -4,33 +4,66 @@ module Skellington
4
4
  @path = path
5
5
  FileUtils.mkdir_p @path
6
6
 
7
- @config = YAML.load File.read(File.open(File.join(File.dirname(__FILE__), '..', '..', 'config/config.yaml')))
8
- gemfile
9
- rakefile
10
- procfile
11
- end
7
+ @config = YAML.load File.read File.join File.dirname(__FILE__), '..', '..', 'config/config.yaml'
12
8
 
13
- def gemfile
14
- template 'Gemfile', config: @config
15
- end
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
+ params: {},
33
+ outpath: "features/#{@path}.feature"
34
+ },
35
+ 'features/support/env.rb' => {
36
+ params: {
37
+ filename: @path,
38
+ camel_name: Skellington.camelise(@path)
39
+ }
40
+ },
41
+ 'lib/app.rb' => {
42
+ params: {
43
+ camel_name: Skellington.camelise(@path)
44
+ },
45
+ outpath: "lib/#{@path}.rb"
46
+ }
47
+ }
16
48
 
17
- def rakefile
18
- template 'Rakefile', camel_case_name: @path
49
+ generate
19
50
  end
20
51
 
21
- def procfile
22
- template 'Procfile', camel_case_name: @path
23
- end
52
+ def generate
53
+ @files.each do |k, v|
54
+ t = Template.new k
55
+ t.params = v[:params]
24
56
 
25
- def templates_dir
26
- File.join(File.dirname(__FILE__), '..', 'templates')
57
+ t.outpath = "#{@path}/#{k}"
58
+ t.outpath = "#{@path}/#{v[:outpath]}" if v[:outpath]
59
+ t.write
60
+ end
27
61
  end
62
+ end
28
63
 
29
- def template name, params = {}
30
- t = File.read(File.open("#{templates_dir}/#{name}.eruby"))
31
- f = File.open "#{@path}/#{name}", 'w'
32
- f.write Erubis::Eruby.new(t).result(params)
33
- f.close
34
- end
64
+ def self.camelise worm_case
65
+ parts = worm_case.split '_'
66
+ parts.map! { |word| "#{word[0].upcase}#{word[1..-1]}" }
67
+ parts.join ''
35
68
  end
36
69
  end
@@ -0,0 +1,27 @@
1
+ module Skellington
2
+ class Template
3
+ attr_reader :name
4
+ attr_accessor :params, :outpath
5
+
6
+ def initialize name
7
+ @name = name
8
+ @outpath = name
9
+ end
10
+
11
+ def templates_dir
12
+ File.join File.dirname(__FILE__), '..', 'templates'
13
+ end
14
+
15
+ def write
16
+ FileUtils.mkdir_p File.dirname @outpath
17
+ f = File.open @outpath, 'w'
18
+ f.write self
19
+ f.close
20
+ end
21
+
22
+ def to_s
23
+ t = File.read(File.open("#{templates_dir}/#{@name}.eruby"))
24
+ Erubis::Eruby.new(t).result(@params)
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Skellington
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby <%= RUBY_VERSION %>
3
+ ruby '<%= RUBY_VERSION %>'
4
4
 
5
5
  <% for gem in config['gems']['production'] %>
6
6
  gem '<%= gem %>'
@@ -1 +1 @@
1
- web: bundle exec ruby lib/<%= camel_case_name %>.rb
1
+ web: bundle exec ruby lib/<%= filename %>.rb
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'lib/<%= camel_case_name %>.rb')
1
+ require File.join(File.dirname(__FILE__), 'lib/<%= filename %>.rb')
2
2
 
3
3
  unless ENV['RACK_ENV'] == 'production'
4
4
  require 'rspec/core/rake_task'
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require File.join(File.dirname(__FILE__), 'lib/<%= filename %>.rb')
3
+
4
+ run <%= camel_name %>
@@ -0,0 +1,5 @@
1
+ Feature: Make sure it's plumbed in correctly
2
+
3
+ Scenario: Get root
4
+ When I send a GET request to "/"
5
+ Then the response status should be "200"
@@ -0,0 +1,24 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require File.join(File.dirname(__FILE__), '..', '..', 'lib/<%= filename %>.rb')
4
+
5
+ require 'capybara'
6
+ require 'capybara/cucumber'
7
+ require 'rspec'
8
+ require 'cucumber/api_steps'
9
+
10
+ Capybara.app = <%= camel_name %>
11
+
12
+ class <%= camel_name %>World
13
+ include Capybara::DSL
14
+ include RSpec::Expectations
15
+ include RSpec::Matchers
16
+
17
+ def app
18
+ <%= camel_name %>
19
+ end
20
+ end
21
+
22
+ World do
23
+ <%= camel_name %>World.new
24
+ end
@@ -0,0 +1,10 @@
1
+ require 'sinatra/base'
2
+
3
+ class <%= camel_name %> < Sinatra::Base
4
+ get '/' do
5
+ 'Hello from <%= camel_name %>'
6
+ end
7
+
8
+ # start the server if ruby file executed directly
9
+ run! if app_file == $0
10
+ end
data/skellington.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'thor', '~> 0.19'
22
22
  spec.add_dependency 'erubis', '~> 2.7'
23
+ spec.add_dependency 'fileutils', '~> 0.7'
23
24
 
24
25
  spec.add_development_dependency 'bundler', '~> 1.7'
25
26
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Skellington
4
- describe Generator do
5
- before :each do
6
- @g = Generator.new 'tmp/project'
4
+ describe Skellington do
5
+ it 'camelises a worm_case string' do
6
+ expect(Skellington.camelise 'worm_case').to eq 'WormCase'
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,35 @@
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skellington
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pikesley
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fileutils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.7'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +160,7 @@ extra_rdoc_files: []
146
160
  files:
147
161
  - ".gitignore"
148
162
  - ".rspec"
163
+ - ".travis.yml"
149
164
  - Gemfile
150
165
  - Guardfile
151
166
  - LICENSE.md
@@ -154,20 +169,30 @@ files:
154
169
  - Rakefile
155
170
  - bin/skellington
156
171
  - config/config.yaml
172
+ - features/app.feature
173
+ - features/config.ru.feature
174
+ - features/cukes.feature
157
175
  - features/gemfile.feature
158
176
  - features/procfile.feature
159
177
  - features/rakefile.feature
178
+ - features/support/app.feature
160
179
  - features/support/env.rb
161
180
  - lib/skellington.rb
162
181
  - lib/skellington/cli.rb
163
182
  - lib/skellington/generator.rb
183
+ - lib/skellington/template.rb
164
184
  - lib/skellington/version.rb
165
185
  - lib/templates/Gemfile.eruby
166
186
  - lib/templates/Procfile.eruby
167
187
  - lib/templates/Rakefile.eruby
188
+ - lib/templates/config.ru.eruby
189
+ - lib/templates/features/first.feature.eruby
190
+ - lib/templates/features/support/env.rb.eruby
191
+ - lib/templates/lib/app.rb.eruby
168
192
  - skellington.gemspec
169
193
  - spec/skellington_spec.rb
170
194
  - spec/spec_helper.rb
195
+ - spec/template_spec.rb
171
196
  homepage: ''
172
197
  licenses:
173
198
  - MIT
@@ -193,9 +218,14 @@ signing_key:
193
218
  specification_version: 4
194
219
  summary: Opinionated boilerplate skeleton for a cuked Sinatra app
195
220
  test_files:
221
+ - features/app.feature
222
+ - features/config.ru.feature
223
+ - features/cukes.feature
196
224
  - features/gemfile.feature
197
225
  - features/procfile.feature
198
226
  - features/rakefile.feature
227
+ - features/support/app.feature
199
228
  - features/support/env.rb
200
229
  - spec/skellington_spec.rb
201
230
  - spec/spec_helper.rb
231
+ - spec/template_spec.rb