p 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- p (0.1.3)
4
+ p (0.1.4)
5
5
  thor (~> 0.18.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,26 +1,22 @@
1
1
  # p [![Gem Version](https://badge.fury.io/rb/p.png)](http://badge.fury.io/rb/p) [![Build Status](https://travis-ci.org/Lytol/p.png)](https://travis-ci.org/Lytol/p)
2
2
 
3
- `p` is a project generator
3
+ `p` is a project generator - for anything!
4
4
 
5
5
 
6
6
  Usage
7
7
  -----
8
8
 
9
- `p <project-type> [project-name]`
9
+ `p <project-type> <project-name>`
10
10
 
11
- If `project-name` is omitted, it will use the current directory; otherwise, it will create the project in a new directory also called `project-name`.
11
+ The command will create a new directory called `project-name` and use the specified template to create a default project within it.
12
12
 
13
13
 
14
- Design
15
- ------
14
+ ### Rubygem
16
15
 
17
- - Templates are defined in `templates/*.rb`
18
- - Definitions should include `options` and `actions`
19
- - `options` should be able to have defaults and can be required or optional
20
- - `actions` can inherit from other actions types
16
+ `p gem <gem-name>` - See <https://github.com/Lytol/p/blob/master/lib/templates/gem.rb>
21
17
 
22
- References
23
- ----------
24
18
 
25
- * `bundle gem`
26
- * Rails generator
19
+ Contributing
20
+ ------------
21
+
22
+ Fork and send a pull request and I'll review as quickly as possible. Thanks!
@@ -0,0 +1,27 @@
1
+ # See: <https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb>
2
+ #
3
+ class String
4
+
5
+ def dasherize
6
+ self.tr('_', '-')
7
+ end
8
+
9
+ def snakecase
10
+ word = self.dup
11
+ word.gsub!('::', '/')
12
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
13
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
14
+ word.tr!("-", "_")
15
+ word.downcase!
16
+ word
17
+ end
18
+
19
+ def camelcase(uppercase_first_letter = true)
20
+ string = self.dup
21
+ if uppercase_first_letter
22
+ string = string.sub(/^[a-z\d]*/) { $&.capitalize }
23
+ end
24
+ string.gsub(/(?:_|(\/))([a-z\d]*)/) { $2.capitalize }.gsub('/', '::')
25
+ end
26
+
27
+ end
data/lib/p.rb CHANGED
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
 
3
3
  module P
4
4
 
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
 
7
7
  def self.template_paths
8
8
  [ File.join(File.dirname(__FILE__), "templates") ]
@@ -13,3 +13,5 @@ require_relative "p/template"
13
13
  require_relative "p/actions"
14
14
  require_relative "p/actions/template_file"
15
15
  require_relative "p/builder"
16
+
17
+ require_relative "ext/string"
@@ -6,4 +6,13 @@ file "#{@name}.gemspec" do
6
6
  end
7
7
 
8
8
  directory "lib"
9
+
10
+ file "lib/#{@name.snakecase}.rb" do
11
+ source "lib.erb"
12
+ end
13
+
9
14
  directory "test"
15
+
16
+ file "test/#{@name.snakecase}_test.rb" do
17
+ source "test.erb"
18
+ end
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,9 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs.push "lib"
5
+ t.test_files = FileList['test/*_test.rb']
6
+ t.verbose = true
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), 'lib/<%= @name.snakecase %>')
2
+ require 'rake'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = '<%= @name %>'
6
+ s.version = <%= @name.camelcase %>::VERSION
7
+ s.summary = "<summary>"
8
+ s.authors = ["<name>"]
9
+ s.email = '<email>'
10
+ s.files = FileList[ "lib/**/*.rb" ]
11
+ s.homepage = "<homepage>"
12
+
13
+ s.add_development_dependency 'rake', '~> 10.0'
14
+ s.add_development_dependency 'minitest', '~> 5.0'
15
+
16
+ s.test_files = Dir.glob('test/*_test.rb')
17
+ end
@@ -0,0 +1,5 @@
1
+ module <%= @name.camelcase %>
2
+
3
+ VERSION = "0.1.0"
4
+
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require '<%= @name.snakecase %>'
4
+
5
+ describe <%= @name.camelcase %> do
6
+ it "should have semantic version" do
7
+ <%= @name.camelcase %>::VERSION.must_match /^\d+\.\d+\.\d+$/
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -66,12 +66,18 @@ executables:
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
+ - lib/ext/string.rb
69
70
  - lib/p/actions/template_file.rb
70
71
  - lib/p/actions.rb
71
72
  - lib/p/builder.rb
72
73
  - lib/p/command.rb
73
74
  - lib/p/template.rb
74
75
  - lib/p.rb
76
+ - lib/templates/gem/Gemfile
77
+ - lib/templates/gem/gemspec.erb
78
+ - lib/templates/gem/lib.erb
79
+ - lib/templates/gem/Rakefile
80
+ - lib/templates/gem/test.erb
75
81
  - lib/templates/gem.rb
76
82
  - Gemfile
77
83
  - Gemfile.lock
@@ -103,6 +109,6 @@ rubyforge_project:
103
109
  rubygems_version: 1.8.23
104
110
  signing_key:
105
111
  specification_version: 3
106
- summary: A project generator for everything
112
+ summary: p is a project generator - for anything
107
113
  test_files:
108
114
  - test/p_test.rb