railgen 0.0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a058cfd9136b30dc3038bf1cc2d768d3667c09b
4
+ data.tar.gz: 61d9efa018ae7f29917e28bd2298d35e0aca572d
5
+ SHA512:
6
+ metadata.gz: bf5562e5d0e50658f923976027333ea1c19f2c60d82adfac7b67330e823931ebbd70594b1deb8d36b2f0b7edfd2e2a5610bbb47f9d41aa585f0dfdf27ccd9bb1
7
+ data.tar.gz: 97e39800fbd43a07e564dd27ee5adc5aaaa53fe3b01147494999e4c212602c81b90cc1c88bf98d7572ab286fb89d908ae411fa84b2837f8a742998c26b3ffbf8
@@ -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
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in railgen.gemspec
4
+ gemspec
5
+ gem 'rinne'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Naoto SHINGAKI
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,41 @@
1
+ # Railgen
2
+
3
+ Railgen is generate gem that provides a rails application
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'railgen'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install railgen
18
+
19
+ ## Usage
20
+
21
+ ### Generate Skeleton
22
+
23
+ ```bash
24
+ $ railgen new appname [option]
25
+ ```
26
+
27
+ ### Option
28
+
29
+ - `-t`,`--target`: target directory
30
+
31
+ ### Thanks
32
+
33
+ - Yusaku ONO - https://github.com/yono
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'railgen'
4
+
5
+ Railgen::CLI.new(ARGV).exec
@@ -0,0 +1,11 @@
1
+ require "railgen/version"
2
+
3
+ module Railgen
4
+ # Your code goes here...
5
+ require 'rinne'
6
+ require 'erb'
7
+
8
+ require 'railgen/cli'
9
+ require 'railgen/new'
10
+ require 'railgen/skeleton'
11
+ end
@@ -0,0 +1,31 @@
1
+ require 'optparse'
2
+
3
+ module Railgen
4
+ class CLI
5
+
6
+ def initialize(argv)
7
+ @options = options(argv)
8
+ end
9
+
10
+ def exec
11
+ if @options[:command].nil?
12
+ puts "command not found"
13
+ else
14
+ eval "#{@options[:command]}.exec(@options)"
15
+ end
16
+ end
17
+
18
+
19
+ private
20
+ def options(argv)
21
+ option = {}
22
+ op = OptionParser.new
23
+ op.on('-t','--target VAL','target directory'){ |v| option[:target] = v }
24
+ op.permute!(argv)
25
+ option[:command] = Rinne.camelize(argv.shift) unless argv.empty?
26
+ option[:namespace] = Rinne.camelize(argv.shift) unless argv.empty?
27
+ option
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,57 @@
1
+ module Railgen
2
+ class New
3
+
4
+ def self.exec(options)
5
+ generator = new(options)
6
+ generator.make_app_directory
7
+ generator.skeleton
8
+ end
9
+
10
+ def initialize(options)
11
+ @options = options
12
+ end
13
+
14
+ def make_app_directory
15
+ Dir.mkdir("#{target}/#{namespace_to_snake}")
16
+ end
17
+
18
+ def skeleton
19
+ files = skeleton_files
20
+ files.each do |file|
21
+ filepath = "#{target}/#{namespace_to_snake}#{file.skeleton_path.gsub('skeleton', namespace_to_snake).gsub(/\.erb$/,'')}"
22
+ puts "create #{filepath}"
23
+ if file.directory?
24
+ Dir.mkdir(filepath)
25
+ elsif file.erb?
26
+ open(filepath, 'w+') do |f|
27
+ f.write ERB.new(file.read).result(binding)
28
+ end
29
+ else
30
+ open(filepath, 'w+') do |f|
31
+ f.write file.read
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ private
38
+ def target
39
+ @options[:target] ||= './'
40
+ end
41
+
42
+ def namespace
43
+ @options[:namespace] ||= 'Sample'
44
+ end
45
+
46
+ def namespace_to_snake
47
+ Rinne.to_snake(namespace)
48
+ end
49
+
50
+ def skeleton_files
51
+ Dir.glob("#{File.dirname(__FILE__)}/../../skeleton/**/*", File::FNM_DOTMATCH).map do |v|
52
+ Skeleton.new(v, File.dirname(__FILE__))
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,28 @@
1
+ module Railgen
2
+ class Skeleton
3
+
4
+ attr_reader :path
5
+
6
+ def initialize(path, base)
7
+ @path = path
8
+ @base = base
9
+ end
10
+
11
+ def skeleton_path
12
+ @path.gsub("#{@base}/../../skeleton", '')
13
+ end
14
+
15
+ def directory?
16
+ File.directory?(@path)
17
+ end
18
+
19
+ def erb?
20
+ File.extname(@path) == ".erb"
21
+ end
22
+
23
+ def read
24
+ open(@path).read
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Railgen
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ #-*- encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'railgen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "railgen"
8
+ spec.version = Railgen::VERSION
9
+ spec.authors = ["Naoto SHINGAKI"]
10
+ spec.email = ["n.shingaki@gmail.com"]
11
+ spec.description = %q{Railgen is generate gem that provides a rails application}
12
+ spec.summary = %q{Railgen is generate gem that provides a rails application}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in <%= Rinne.to_snake(@options[:namespace]) %>.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2013
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.
23
+
@@ -0,0 +1,38 @@
1
+ # <%= @options[:namespace] %>
2
+
3
+ <%= @options[:namespace] %> is a sample gem that provides a rails application.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem '<%= Rinne.to_snake(@options[:namespace]) %>'
10
+
11
+ Runs the installation generator with:
12
+
13
+ rails generate <%= Rinne.to_snake(@options[:namespace]) %>:install
14
+
15
+ This will install the migration file into `db/migrate`
16
+
17
+ Don't forget to run the migration with:
18
+
19
+ rake db:migrate
20
+
21
+ ## Routes
22
+
23
+ The installation script will also automatically add the Gyomu routes into your app, like this:
24
+
25
+ ```ruby
26
+ Rails.application.routes.draw do
27
+ use_<%= Rinne.to_snake(@options[:namespace]) %>
28
+ # your routes
29
+ end
30
+ ```
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
File without changes
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ class <%= @options[:namespace] %>::InstallGenerator < ::Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ desc "Install <%= @options[:namespace] %>"
7
+
8
+ def install
9
+ route "use_<%= Rinne.to_snake(@options[:namespace]) %>"
10
+ migration_template 'migration.rb', 'db/migrate/create_<%= Rinne.to_snake(@options[:namespace]) %>_tables.rb'
11
+ readme "README"
12
+ end
13
+
14
+ def self.next_migration_number(dirname)
15
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ ===============================================================================
2
+
3
+ There is a setup that you need to do before you can use self.
4
+
5
+ Step 1.
6
+
7
+ Run migration.
8
+
9
+ rake db:migrate
10
+
11
+ Step 2.
12
+
13
+ That's all.
14
+
15
+ ===============================================================================
@@ -0,0 +1,11 @@
1
+ class Create<%= @options[:namespace] %>Tables < ActiveRecord::Migration
2
+ def change
3
+ # Sample
4
+ # create_table :users do |t|
5
+ # t.string :name
6
+ # t.string :email
7
+ #
8
+ # t.timestamps
9
+ # end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ require "<%= Rinne.to_snake(@options[:namespace]) %>/version"
2
+ require "<%= Rinne.to_snake(@options[:namespace]) %>/engine"
3
+
4
+ module <%= @options[:namespace] %>
5
+ module Rails
6
+ autoload :Routes, "<%= Rinne.to_snake(@options[:namespace]) %>/rails/routes"
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ module <%= @options[:namespace] %>
4
+ class Engine < Rails::Engine
5
+ initializer "<%= Rinne.to_snake(@options[:namespace]) %>.routes" do
6
+ <%= @options[:namespace] %>::Rails::Routes.install!
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- codinf: utf-8 -*-
3
+
4
+ module <%= @options[:namespace] %>
5
+ module Rails
6
+ class Routes
7
+ module Helper
8
+ def use_<%= Rinne.to_snake(@options[:namespace]) %>
9
+ <%= @options[:namespace] %>::Rails::Routes.new(self).generate_routes!
10
+ end
11
+ end
12
+
13
+ def self.install!
14
+ ActionDispatch::Routing::Mapper.send :include, <%= @options[:namespace] %>::Rails::Routes::Helper
15
+ end
16
+
17
+ attr_accessor :routes
18
+
19
+ def initialize(routes)
20
+ @routes = routes
21
+ end
22
+
23
+ def generate_routes!
24
+ routes.scope '<%= Rinne.to_snake(@options[:namespace]) %>', :as => '<% Rinne.to_snake(@options[:namespace]) %>' do
25
+ # routes.resource aads
26
+ # TODO: router config file load
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,3 @@
1
+ module <%= @options[:namespace] %>
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require '<%= Rinne.to_snake(@options[:namespace]) %>/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "<%= Rinne.to_snake(@options[:namespace]) %>"
8
+ spec.version = <%= @options[:namespace] %>::VERSION
9
+ spec.authors = ["TODO: author name"]
10
+ spec.email = ["TODO: author email"]
11
+ spec.description = %q{TODO: Description}
12
+ spec.summary = %q{TODO: Summary}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rails"
24
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railgen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naoto SHINGAKI
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Railgen is generate gem that provides a rails application
42
+ email:
43
+ - n.shingaki@gmail.com
44
+ executables:
45
+ - railgen
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/railgen
55
+ - lib/railgen.rb
56
+ - lib/railgen/cli.rb
57
+ - lib/railgen/new.rb
58
+ - lib/railgen/skeleton.rb
59
+ - lib/railgen/version.rb
60
+ - railgen.gemspec
61
+ - skeleton/.gitignore.erb
62
+ - skeleton/Gemfile.erb
63
+ - skeleton/LICENSE.txt
64
+ - skeleton/README.md.erb
65
+ - skeleton/Rakefile
66
+ - skeleton/app/assets/skeleton/images/.keep
67
+ - skeleton/app/assets/skeleton/javascripts/.keep
68
+ - skeleton/app/assets/skeleton/stylesheets/.keep
69
+ - skeleton/app/controllers/skeleton/.keep
70
+ - skeleton/app/helpers/skeleton/.keep
71
+ - skeleton/app/models/skeleton/.keep
72
+ - skeleton/app/views/skeleton/.keep
73
+ - skeleton/lib/generators/skeleton/install_generator.rb.erb
74
+ - skeleton/lib/generators/skeleton/templates/README
75
+ - skeleton/lib/generators/skeleton/templates/migration.rb.erb
76
+ - skeleton/lib/skeleton.rb.erb
77
+ - skeleton/lib/skeleton/engine.rb.erb
78
+ - skeleton/lib/skeleton/rails/routes.rb.erb
79
+ - skeleton/lib/skeleton/version.rb.erb
80
+ - skeleton/skeleton.gemspec.erb
81
+ homepage: ''
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Railgen is generate gem that provides a rails application
105
+ test_files: []