microgem 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f283172b8480ba94a3045409c7901cabf19f810c
4
+ data.tar.gz: 9a7f882810555e419c62f75db97686c674eb2a47
5
+ SHA512:
6
+ metadata.gz: 9bdde3705d0f51df4110bdb08a55b7ffc4136953b543719f34dee743cabc4c4f12e9da3213120840082e8a2198933e42d9062a0fcf0275810bbe1151b9b21d8f
7
+ data.tar.gz: 15ab1268ee7ad646a6ddd39cc4e14f987151a5e8627eed779b66885d8c988b7f717bd4c1fea094a6008a20325b623d115734cdfbd1b72d4329e11312a4c61428
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## CHANGELOG
2
+
3
+ ### 1.0.0
4
+
5
+ * Release
6
+
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Jan Lelis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # microgem [![[version]](https://badge.fury.io/rb/microgem.svg)](http://badge.fury.io/rb/microgem)
2
+
3
+ Yet another [thor](http://whatisthor.com/) based gem generator. Not much options, if you are looking for something more flexible, consider using [ore](https://github.com/ruby-ore/ore) instead.
4
+
5
+
6
+ ## Usage
7
+
8
+ $ microgem gem_name
9
+
10
+
11
+ ## J-_-L
12
+
13
+ Copyright (C) 2015 [Jan Lelis](http://janlelis.com). MIT Licese.
data/bin/microgem ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "microgem"
4
+ Microgem.run!
data/lib/microgem.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative 'microgem/version'
2
+ require_relative 'microgem/generator'
3
+
4
+ module Microgem
5
+ def self.run!
6
+ Microgem::Generator.start
7
+ end
8
+ end
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'json'
5
+
6
+ class Microgem::Generator < Thor::Group
7
+ include Thor::Actions
8
+
9
+ def self.source_root
10
+ File.dirname(__FILE__) + '/../../template/'
11
+ end
12
+
13
+ argument :name
14
+ class_option :version, default: "0.1.0"
15
+ class_option :info, default: "TODO"
16
+ class_option :specs, default: true
17
+ class_option :class, default: false
18
+ class_option :github
19
+
20
+ attr_reader :settings
21
+
22
+ def load_settings
23
+ dotfile_path = File.expand_path("~/.microgem")
24
+ if File.exist? dotfile_path
25
+ @settings = JSON.load File.read(dotfile_path)
26
+ else
27
+ @settings = {}
28
+ say "This is your first microgem. Please tell me who you are!"
29
+ guess_author = `git config user.name`.chomp
30
+ guess_author = nil if guess_author.empty?
31
+ guess_email = `git config user.email`.chomp
32
+ guess_email = nil if guess_email.empty?
33
+ guess_github = `git config github.user`.chomp
34
+ guess_github = nil if guess_github.empty?
35
+ @settings["author"] = ask("Your Name" + (guess_author ? " [#{guess_author}]:" : ":"))
36
+ @settings["author"] = guess_author if @settings["author"].empty? && guess_author
37
+ @settings["email"] = ask("Your E-Mail" + (guess_email ? " [#{guess_email}]:" : ":")) || guess_email
38
+ @settings["email"] = guess_email if @settings["email"].empty? && guess_email
39
+ @settings["website"] = ask("Your Website:")
40
+ @settings["github"] = ask("Your GitHub Name" + (guess_github ? " [#{guess_github}]:" : ":")) || guess_github
41
+ @settings["github"] = guess_github if @settings["github"].empty? && guess_github
42
+ File.write dotfile_path, JSON.dump(@settings)
43
+ end
44
+ end
45
+
46
+ def validate_name
47
+ unless name =~ /\A[A-Z0-9_-]+\z/i
48
+ raise ArgumentError, "invalid gem name: must only contain A-Z, 0-9, _ or -"
49
+ end
50
+ if module_name =~ /::[^A-Z]/
51
+ raise ArgumentError, "invalid gem name: module names only allowed to start with A-Z"
52
+ end
53
+ end
54
+
55
+ # - - -
56
+
57
+ def module_def(index=nil)
58
+ options[:class] && index && sub_modules.size == index + 1 ? "class" : "module"
59
+ end
60
+
61
+ def module_name
62
+ name.gsub(/-[_-]*(?![_-]|$)/){ '::' }.gsub(/(^?[_-]+|(?<=:)|^)(.|$)/){ $2.upcase }
63
+ end
64
+
65
+ def sub_modules
66
+ module_name.split '::'
67
+ end
68
+
69
+ def path
70
+ name.gsub(/-[_-]*(?![_-]|$)/){ '/' }
71
+ end
72
+
73
+ def spec_name
74
+ name.gsub(/-[_-]*(?![_-]|$)/){ '_' }
75
+ end
76
+
77
+ def last_name
78
+ path[%r<[^/]+$>]
79
+ end
80
+
81
+ def github_name
82
+ options[:github] || name
83
+ end
84
+
85
+ def info
86
+ options[:info]
87
+ end
88
+
89
+ def version
90
+ options[:version]
91
+ end
92
+
93
+ def current_year
94
+ Date.today.year
95
+ end
96
+
97
+ def generate
98
+ directory ".", name, exclude_pattern: %r<_spec.rb|Gemfile|\.travis\.yml>
99
+ if options[:specs]
100
+ directory "spec", name + "/spec"
101
+ template ".travis.yml", name + "/.travis.yml"
102
+ copy_file "Gemfile", name + "/Gemfile"
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,3 @@
1
+ module Microgem
2
+ VERSION = '1.0.0'
3
+ end
data/microgem.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/lib/microgem/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "microgem"
7
+ gem.version = Microgem::VERSION
8
+ gem.summary = "Generates new micro gems."
9
+ gem.description = "Generates new micro gems. Usage: $ microgem gem_name"
10
+ gem.authors = ["Jan Lelis"]
11
+ gem.email = "mail@janlelis.de"
12
+ gem.homepage = "https://github.com/janlelis/microgem"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + "/lib/<%= path %>/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "<%= name %>"
7
+ gem.version = <%= module_name %>::VERSION
8
+ gem.summary = "<%= info %>"
9
+ gem.description = "<%= info %>"
10
+ gem.authors = ["<%= settings['author'] %>"]
11
+ gem.email = "mail@janlelis.de"
12
+ gem.homepage = "https://github.com/<%= settings['github'] %>/<%= github_name %>"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+ end
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+
3
+ script: bundle exec ruby spec/<%= spec_name %>.rb
4
+
5
+ rvm:
6
+ - 2.2.1
7
+ - 2.2.0
8
+ - 2.1.5
9
+ - 2.1.4
10
+ - 2.1.3
11
+ - 2.1.2
12
+ - 2.1.1
13
+ - 2.1.0
14
+ - 2.0.0
15
+ - rbx-2
16
+ - jruby-head
17
+ - jruby-9000
18
+
@@ -0,0 +1,6 @@
1
+ ## CHANGELOG
2
+
3
+ ### <%= version %>
4
+
5
+ * Inital release
6
+
data/template/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
@@ -0,0 +1,20 @@
1
+ Copyright (c) <%= current_year %> <%= settings['author'] %>, <%= settings['email'] %>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # <%= name %> [![[version]](https://badge.fury.io/rb/<%= name %>.svg)](http://badge.fury.io/rb/<%= name %>) [![[travis]](https://travis-ci.org/<%= settings['github'] %>/<%= github_name %>.png)](https://travis-ci.org/<%= settings['github'] %>/<%= github_name %>)
2
+
3
+ <%= info %>
4
+
5
+
6
+ ## Setup
7
+
8
+ Add to your `Gemfile`:
9
+
10
+ ```ruby
11
+ gem '<%= name %>'
12
+ ```
13
+
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ ```
19
+
20
+
21
+ ## MIT License
22
+
23
+ Copyright (C) <%= current_year %> <%= settings['author'] %> <<%= settings['website'] %>>. Released under the MIT license.
@@ -0,0 +1,6 @@
1
+ require_relative "<%= last_name %>/version"
2
+
3
+ <% sub_modules.each.with_index do |sub_module, index| %><%= " " * index %><%= module_def(index) %> <%= sub_module %>
4
+ <% end %><% sub_modules.size.downto(1) do |index| %><%= " " * (index - 1) %>end
5
+ <% end %>
6
+
@@ -0,0 +1,5 @@
1
+ <% sub_modules.each.with_index do |sub_module, index| %><%= " " * index %><%= module_def(index) %> <%= sub_module %>
2
+ <% end %><%= " " * sub_modules.size %>VERSION = "<%= version %>".freeze
3
+ <% sub_modules.size.downto(1) do |index| %><%= " " * (index - 1) %>end
4
+ <% end %>
5
+
@@ -0,0 +1,9 @@
1
+ require_relative "../lib/<%= path %>"
2
+ require "minitest/autorun"
3
+
4
+ describe <%= module_name %> do
5
+ it "works" do
6
+ assert_equal true, false
7
+ end
8
+ end
9
+
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: microgem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'Generates new micro gems. Usage: $ microgem gem_name'
14
+ email: mail@janlelis.de
15
+ executables:
16
+ - microgem
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - CHANGELOG.md
22
+ - MIT-LICENSE.txt
23
+ - README.md
24
+ - bin/microgem
25
+ - lib/microgem.rb
26
+ - lib/microgem/generator.rb
27
+ - lib/microgem/version.rb
28
+ - microgem.gemspec
29
+ - template/%name%.gemspec.tt
30
+ - template/.gitignore
31
+ - template/.travis.yml.tt
32
+ - template/CHANGELOG.md.tt
33
+ - template/Gemfile
34
+ - template/MIT-LICENSE.txt.tt
35
+ - template/README.md.tt
36
+ - template/lib/%path%.rb.tt
37
+ - template/lib/%path%/version.rb.tt
38
+ - template/spec/%spec_name%_spec.rb.tt
39
+ homepage: https://github.com/janlelis/microgem
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.4.6
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Generates new micro gems.
63
+ test_files: []