straptible 0.1.2 → 0.2.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: e46a7cbb0934f2c311be1bbfbc512daa0d7333ee
4
- data.tar.gz: acb54cea21f51c3fb34da6df27d426e444c3a2d0
3
+ metadata.gz: 053811f519e96e48afe831df2e2eed2b5c97c9fc
4
+ data.tar.gz: cebb8bb2f63792be341048cb08e516f8187b1981
5
5
  SHA512:
6
- metadata.gz: 3853628e60f6c19dccb6ba19a30cd4c2b8d389e9000613036bcf19435bf5f4b795a0155f24cb3c72cd56a5c718078941051cae198e871543989d33e350f96c5f
7
- data.tar.gz: 9c47b9222ff0d36bc9391c10a6ef29b7d816e68ae44f99a14cd6510d6d8960cca671cb734f6b6dcce3caa76936a5ea969edb9bb8df960e72a94622f19013acd0
6
+ metadata.gz: 95d98f7fece344d58f2cce33ca6a5c090b01a6bd409cb33d04570690352339ffbf0cd49035a56320ff2a41fd38da1ba1ee65c25c29a90e93601e71409ad99193
7
+ data.tar.gz: a3dcf99420ddccb65ead42bf5214a8c77b875004aaf277dab14c53674cd44ed84b08bc4761ce828cdec23187b45d26bc337d3c5711924dc72f4cd639f5c85156
data/README.md CHANGED
@@ -17,7 +17,7 @@ Then, to create a new project, first choose your flavor:
17
17
  | ---------:| ------- |
18
18
  | `webapp` (*coming soon*) | Rails web app |
19
19
  | `api` | Rails API — similar to `webapp`, but tailored and stripped down for a JSON API |
20
- | `gem` (*coming soon*) | Ruby gem |
20
+ | `gem` | Ruby gem |
21
21
  | `docs` (*coming soon*) | Document repository |
22
22
 
23
23
  Then, run:
@@ -11,11 +11,15 @@ def usage(dest = $stdout)
11
11
  dest.puts 'Usage: straptible <flavor> <path> [options...]'
12
12
  end
13
13
 
14
- flavor = ARGV.shift
14
+ flavor = ARGV.first
15
15
  case flavor
16
16
  when 'api'
17
17
  require File.join('straptible', 'rails', 'generators', 'api')
18
+ ARGV.shift
18
19
  Straptible::Rails::Generators::Api.start
20
+ when 'gem'
21
+ require File.join('straptible', 'gem', 'generators', 'base')
22
+ Straptible::Gem::Generators::Base.start
19
23
  when nil
20
24
  usage($stderr)
21
25
  exit 1
@@ -0,0 +1,101 @@
1
+ require 'thor'
2
+
3
+ module Straptible
4
+ module Gem
5
+ module Generators
6
+ class Base < Thor
7
+ include Thor::Actions
8
+
9
+ attr_accessor :name, :opts
10
+
11
+ def self.start
12
+ tmpl_path = File.join('..', 'templates')
13
+ source_root File.expand_path(tmpl_path, File.dirname(__FILE__))
14
+
15
+ super
16
+ end
17
+
18
+ no_commands do
19
+ def git_name
20
+ `git config user.name`.chomp
21
+ end
22
+
23
+ def author
24
+ git_name.empty? ? 'TODO: Write your name' : git_name
25
+ end
26
+
27
+ def git_email
28
+ `git config user.email`.chomp
29
+ end
30
+
31
+ def email
32
+ git_email.empty? ? 'TODO: Write your email address' : git_email
33
+ end
34
+
35
+ def namespaced_path
36
+ name.tr('-', '/')
37
+ end
38
+
39
+ def constant_name
40
+ cn = name.split('_').map(&:capitalize).join
41
+ if cn =~ /-/
42
+ cn.split('-').map { |q| q[0..0].upcase + q[1..-1] }.join('::')
43
+ else
44
+ cn
45
+ end
46
+ end
47
+
48
+ def constant_array
49
+ constant_name.split('::')
50
+ end
51
+
52
+ def commit_message
53
+ "Initial commit (Straptible #{Straptible::VERSION})"
54
+ end
55
+
56
+ def git_init
57
+ inside destination_root do
58
+ run 'git init .'
59
+ run 'git add .'
60
+ run "git commit -m '#{commit_message}'"
61
+ end
62
+ end
63
+ end
64
+
65
+ # rubocop:disable MethodLength
66
+ desc 'gem NAME', 'Creates an Aptible-configured Ruby gem'
67
+ def gem(name_or_path)
68
+ self.destination_root = File.expand_path(name_or_path, Dir.pwd)
69
+ self.name = File.basename(name_or_path)
70
+
71
+ self.opts = {
72
+ name: name,
73
+ namespaced_path: namespaced_path,
74
+ constant_name: constant_name,
75
+ constant_array: constant_array,
76
+ author: author,
77
+ email: email
78
+ }
79
+
80
+ template 'Gemfile.tt', opts
81
+ template 'LICENSE.md.tt', opts
82
+ template 'README.md.tt', opts
83
+ template 'newgem.gemspec.tt', "#{name}.gemspec", opts
84
+ template 'spec/spec_helper.rb.tt', 'spec/spec_helper.rb', opts
85
+
86
+ template 'lib/newgem.rb.tt', "lib/#{namespaced_path}.rb", opts
87
+ template 'lib/newgem/version.rb.tt',
88
+ "lib/#{namespaced_path}/version.rb", opts
89
+
90
+ copy_file 'Rakefile'
91
+ copy_file 'gitignore', '.gitignore'
92
+ copy_file 'rspec', '.rspec'
93
+ copy_file 'travis.yml', '.travis.yml'
94
+
95
+ git_init
96
+ end
97
+ # rubocop:enable MethodLength
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rubocop', github: 'bbatsov/rubocop'
4
+
5
+ # Specify your gem's dependencies in <%=config[:name]%>.gemspec
6
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) <%=Time.now.year%> Aptible, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # ![](https://raw.github.com/aptible/straptible/master/lib/straptible/rails/templates/public.api/icon-72-cropped.png) <%= config[:constant_name] %>
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/<%= config[:name] %>.png)](https://rubygems.org/gems/<%= config[:name] %>)
4
+ [![Build Status](https://travis-ci.org/aptible/<%= config[:name] %>.png?branch=master)](https://travis-ci.org/aptible/<%= config[:name] %>)
5
+ [![Dependency Status](https://gemnasium.com/aptible/<%= config[:name] %>.png)](https://gemnasium.com/aptible/<%= config[:name] %>)
6
+
7
+ TODO: Add description.
8
+
9
+ ## Installation
10
+
11
+ Add the following line to your application's Gemfile.
12
+
13
+ gem <%= config[:name] %>
14
+
15
+ And then run `bundle install`.
16
+
17
+ ## Usage
18
+
19
+ TODO: Add usage notes.
20
+
21
+ ## Contributing
22
+
23
+ 1. Fork the project.
24
+ 1. Commit your changes, with specs.
25
+ 1. Ensure that your code passes specs (`rake spec`) and meets Aptible's Ruby style guide (`rake rubocop`).
26
+ 1. Create a new pull request on GitHub.
27
+
28
+ ## Copyright and License
29
+
30
+ MIT License, see [LICENSE](LICENSE.md) for details.
31
+
32
+ Copyright (c) <%=Time.now.year%> [Aptible](https://www.aptible.com), <%= config[:author] %>, and contributors.
@@ -0,0 +1,4 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'aptible/tasks'
4
+ Aptible::Tasks.load_tasks
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,9 @@
1
+ require '<%=config[:namespaced_path]%>/version'
2
+
3
+ <%- config[:constant_array].each_with_index do |c,i| -%>
4
+ <%= ' '*i %>module <%= c %>
5
+ <%- end -%>
6
+ <%= ' '*config[:constant_array].size %># Your code goes here...
7
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
8
+ <%= ' '*i %>end
9
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ <%- config[:constant_array].each_with_index do |c,i| -%>
2
+ <%= ' '*i %>module <%= c %>
3
+ <%- end -%>
4
+ <%= ' '*config[:constant_array].size %>VERSION = '0.1.0'
5
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
6
+ <%= ' '*i %>end
7
+ <%- end -%>
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'English'
6
+ require '<%= config[:namespaced_path] %>/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = '<%= config[:name] %>'
10
+ spec.version = <%= config[:constant_name] %>::VERSION
11
+ spec.authors = ['<%= config[:author] %>']
12
+ spec.email = ['<%= config[:email] %>']
13
+ spec.description = %q{TODO: Write a gem description}
14
+ spec.summary = %q{TODO: Write a gem summary}
15
+ spec.homepage = 'https://github.com/aptible/<%= config[:name] %>'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split($RS)
19
+ spec.test_files = spec.files.grep(/^spec\//)
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> <%= Bundler::VERSION.split('.')[0..1].join('.') %>'
23
+ spec.add_development_dependency 'aptible-tasks'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_dependency 'rspec', '~> 2.0'
26
+ end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ # Load shared spec files
5
+ Dir["#{File.dirname(__FILE__)}/shared/**/*.rb"].each do |file|
6
+ require file
7
+ end
8
+
9
+ # Require library up front
10
+ require '<%= config[:namespaced_path] %>'
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - jruby
@@ -1,3 +1,3 @@
1
1
  module Straptible
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,61 @@
1
+ describe 'straptible gem' do
2
+ before :all do
3
+ rel_tmp = '../../tmp/spec'
4
+ @tmpdir = File.expand_path(rel_tmp, File.dirname(__FILE__))
5
+ FileUtils.mkdir_p @tmpdir
6
+ FileUtils.rm_rf File.join(@tmpdir, 'foobar')
7
+
8
+ rel_straptible = '../../bin/straptible'
9
+ @straptible = File.expand_path(rel_straptible, File.dirname(__FILE__))
10
+ end
11
+
12
+ context 'with a simple gem name' do
13
+ before :all do
14
+ `#{@straptible} gem #{File.join(@tmpdir, 'foobar')}`
15
+ end
16
+
17
+ after :all do
18
+ FileUtils.rm_r File.join(@tmpdir, 'foobar')
19
+ end
20
+
21
+ it 'includes an appropriate README.md' do
22
+ readme = File.join(@tmpdir, 'foobar', 'README.md')
23
+ File.exist?(readme).should be_true
24
+ File.read(readme).should match /\#.*icon-72-cropped.png.*Foobar/
25
+ end
26
+ end
27
+
28
+ context 'with a complex gem name' do
29
+ before :all do
30
+ `#{@straptible} gem #{File.join(@tmpdir, 'foobar/foo_bar-baz')}`
31
+ end
32
+
33
+ after :all do
34
+ FileUtils.rm_r File.join(@tmpdir, 'foobar')
35
+ end
36
+
37
+ it 'includes an appropriate gemspec' do
38
+ gemdir = File.join(@tmpdir, 'foobar', 'foo_bar-baz')
39
+ gemspec = File.join(gemdir, 'foo_bar-baz.gemspec')
40
+ File.exist?(gemspec).should be_true
41
+ File.read(gemspec).should match /FooBar::Baz/
42
+ end
43
+ end
44
+
45
+ context 'executing bundle install' do
46
+ before :all do
47
+ # TODO: Figure out how to do this offline
48
+ `#{@straptible} gem #{File.join(@tmpdir, 'foobar')}`
49
+ `cd #{File.join(@tmpdir, 'foobar')} && bundle install`
50
+ end
51
+
52
+ after :all do
53
+ FileUtils.rm_rf File.join(@tmpdir, 'foobar')
54
+ end
55
+
56
+ it 'passes Rubocop muster' do
57
+ `cd #{File.join(@tmpdir, 'foobar')} && bundle exec rake rubocop`
58
+ $CHILD_STATUS.exitstatus.should == 0
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: straptible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -111,6 +111,18 @@ files:
111
111
  - Rakefile
112
112
  - bin/straptible
113
113
  - lib/straptible.rb
114
+ - lib/straptible/gem/generators/base.rb
115
+ - lib/straptible/gem/templates/Gemfile.tt
116
+ - lib/straptible/gem/templates/LICENSE.md.tt
117
+ - lib/straptible/gem/templates/README.md.tt
118
+ - lib/straptible/gem/templates/Rakefile
119
+ - lib/straptible/gem/templates/gitignore
120
+ - lib/straptible/gem/templates/lib/newgem.rb.tt
121
+ - lib/straptible/gem/templates/lib/newgem/version.rb.tt
122
+ - lib/straptible/gem/templates/newgem.gemspec.tt
123
+ - lib/straptible/gem/templates/rspec
124
+ - lib/straptible/gem/templates/spec/spec_helper.rb.tt
125
+ - lib/straptible/gem/templates/travis.yml
114
126
  - lib/straptible/rails/builders/api.rb
115
127
  - lib/straptible/rails/builders/base.rb
116
128
  - lib/straptible/rails/generators/api.rb
@@ -138,6 +150,7 @@ files:
138
150
  - lib/straptible/rails/templates/travis.yml.api
139
151
  - lib/straptible/version.rb
140
152
  - spec/integration/api_spec.rb
153
+ - spec/integration/gem_spec.rb
141
154
  - spec/spec_helper.rb
142
155
  - straptible.gemspec
143
156
  homepage: https://github.com/aptible/straptible
@@ -166,4 +179,5 @@ specification_version: 4
166
179
  summary: A tool for bootstrapping new Aptible projects
167
180
  test_files:
168
181
  - spec/integration/api_spec.rb
182
+ - spec/integration/gem_spec.rb
169
183
  - spec/spec_helper.rb