p 0.1.3 → 0.1.4
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.
- data/Gemfile.lock +1 -1
- data/README.md +9 -13
- data/lib/ext/string.rb +27 -0
- data/lib/p.rb +3 -1
- data/lib/templates/gem.rb +9 -0
- data/lib/templates/gem/Gemfile +3 -0
- data/lib/templates/gem/Rakefile +9 -0
- data/lib/templates/gem/gemspec.erb +17 -0
- data/lib/templates/gem/lib.erb +5 -0
- data/lib/templates/gem/test.erb +9 -0
- metadata +8 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,22 @@
|
|
1
1
|
# p [](http://badge.fury.io/rb/p) [](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>
|
9
|
+
`p <project-type> <project-name>`
|
10
10
|
|
11
|
-
|
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
|
-
|
15
|
-
------
|
14
|
+
### Rubygem
|
16
15
|
|
17
|
-
|
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
|
-
|
26
|
-
|
19
|
+
Contributing
|
20
|
+
------------
|
21
|
+
|
22
|
+
Fork and send a pull request and I'll review as quickly as possible. Thanks!
|
data/lib/ext/string.rb
ADDED
@@ -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.
|
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"
|
data/lib/templates/gem.rb
CHANGED
@@ -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
|
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.
|
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:
|
112
|
+
summary: p is a project generator - for anything
|
107
113
|
test_files:
|
108
114
|
- test/p_test.rb
|