mafia 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.
@@ -0,0 +1,6 @@
1
+ # Mafia
2
+ Mafia is a generator gem that creates the directory structure and files for a [sinatra](http://www.sinatrarb.com) app that is also a gem in itself. The benefits for writing sinatra apps as gems is you can make your apps more modular and easily use them as rack middleware.
3
+
4
+ ## Usage
5
+ sudo gem install mafia
6
+ mafia appname
@@ -8,39 +8,45 @@ module Mafia
8
8
  argument :name
9
9
 
10
10
  def self.source_root
11
- File.dirname(__FILE__)
11
+ File.expand_path(File.join(File.dirname(__FILE__), 'mafia/templates'))
12
12
  end
13
13
 
14
14
  def create_gemspec_file
15
- template("mafia/templates/gemspec.tt", "#{name}/#{name}.gemspec")
15
+ opts = {
16
+ :name => name,
17
+ :creator_name => `git config user.name`.chomp,
18
+ :creator_email => `git config user.email`.chomp
19
+ }
20
+
21
+ template("gemspec.tt", "#{name}/#{name}.gemspec", opts)
16
22
  end
17
23
 
18
24
  def create_config_ru_file
19
- template("mafia/templates/config.ru.tt", "#{name}/config.ru")
25
+ template("config.ru.tt", "#{name}/config.ru")
20
26
  end
21
27
 
22
28
  def create_version_file
23
- template("mafia/templates/version.rb.tt", "#{name}/lib/version.rb")
29
+ template("version.rb.tt", "#{name}/lib/version.rb")
24
30
  end
25
31
 
26
32
  def create_gem_file
27
- template("mafia/templates/gem.rb.tt", "#{name}/lib/#{name}.rb")
33
+ template("gem.rb.tt", "#{name}/lib/#{name}.rb")
28
34
  end
29
35
 
30
36
  def create_app_file
31
- template("mafia/templates/app.rb.tt", "#{name}/lib/#{name}/app.rb")
37
+ template("app.rb.tt", "#{name}/lib/#{name}/app.rb")
32
38
  end
33
39
 
34
40
  def copy_rakefile
35
- copy_file("mafia/templates/Rakefile", "#{name}/Rakefile")
41
+ copy_file("Rakefile", "#{name}/Rakefile")
36
42
  end
37
43
 
38
44
  def copy_gemfile
39
- copy_file("mafia/templates/Gemfile", "#{name}/Gemfile")
45
+ copy_file("Gemfile", "#{name}/Gemfile")
40
46
  end
41
47
 
42
48
  def copy_readme
43
- copy_file("mafia/templates/README", "#{name}/README")
49
+ template("README.md.tt", "#{name}/README.md")
44
50
  end
45
51
 
46
52
  def create_empty_files_and_directories
@@ -48,6 +54,25 @@ module Mafia
48
54
  empty_directory("#{name}/lib/#{name}/views")
49
55
  empty_directory("#{name}/lib/#{name}/lib")
50
56
  end
57
+
58
+ def create_license
59
+ if yes? "Use MIT License?"
60
+
61
+ opts = {
62
+ :name => name,
63
+ :creator_name => `git config user.name`.chomp,
64
+ :creator_email => `git config user.email`.chomp
65
+ }
66
+
67
+ template("LICENSE.tt", "#{name}/LICENSE", opts)
68
+ end
69
+ end
70
+
71
+ def initalize_git_repo
72
+ target = File.join(Dir.pwd, name)
73
+ say "Initializating git repo in #{target}"
74
+ Dir.chdir(target) { `git init`; `git add .` }
75
+ end
51
76
 
52
77
  end # Generator
53
78
  end # Rackgem
@@ -0,0 +1,20 @@
1
+ Copyright (c) <%= Time.now.year %> <%= config[:creator_name] %>, <%= config[:creator_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,13 @@
1
+ # <%= name.capitalize %>
2
+
3
+ **<%= name.capitalize %>** is a [sinatra](http://www.sinatrarb.com) app/middleware that can be run standalone app or required as a gem.
4
+
5
+ ## Running standalone
6
+ Simply run the ``bundle`` and then ``rackup`` commands.
7
+
8
+ ## Bundling as a gem
9
+ gem build <%= name %>.gemspec
10
+ sudo gem install <%= name %>-0.0.1.gem
11
+
12
+ ## License
13
+ Please see License.txt
@@ -3,10 +3,10 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
  require "version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "<%= name %>"
7
- s.version = <%= name.capitalize %>::VERSION
8
- s.authors = ["George Drummond"]
9
- s.email = ["george@accountsapp.com"]
6
+ s.name = "<%= config[:name] %>"
7
+ s.version = <%= config[:name].capitalize %>::VERSION
8
+ s.authors = ["<%= config[:creator_name] %>"]
9
+ s.email = ["<%= config[:creator_email] %>"]
10
10
  s.homepage = ""
11
11
  s.summary = %q{TODO: Write a gem summary}
12
12
  s.description = %q{TODO: Write a gem description}
@@ -1,3 +1,3 @@
1
1
  module Mafia
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Mafia::VERSION
8
8
  s.authors = ["George Drummond"]
9
9
  s.email = ["george@accountsapp.com"]
10
- s.homepage = ""
10
+ s.homepage = "http://github.com/georgedrummond/mafia"
11
11
  s.summary = %q{Generator to create sinatra apps that are also gems}
12
12
  s.description = %q{Generator to create sinatra apps that are also gems}
13
13
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mafia
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - George Drummond
@@ -43,13 +43,15 @@ extra_rdoc_files: []
43
43
  files:
44
44
  - .gitignore
45
45
  - Gemfile
46
+ - README.md
46
47
  - Rakefile
47
48
  - bin/mafia
48
49
  - lib/.DS_Store
49
50
  - lib/mafia.rb
50
51
  - lib/mafia/.DS_Store
51
52
  - lib/mafia/templates/Gemfile
52
- - lib/mafia/templates/README
53
+ - lib/mafia/templates/LICENSE.tt
54
+ - lib/mafia/templates/README.md.tt
53
55
  - lib/mafia/templates/Rakefile
54
56
  - lib/mafia/templates/app.rb.tt
55
57
  - lib/mafia/templates/config.ru.tt
@@ -58,7 +60,7 @@ files:
58
60
  - lib/mafia/templates/version.rb.tt
59
61
  - lib/version.rb
60
62
  - mafia.gemspec
61
- homepage: ""
63
+ homepage: http://github.com/georgedrummond/mafia
62
64
  licenses: []
63
65
 
64
66
  post_install_message:
File without changes