rails_clone 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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +2 -0
- data/lib/rails_clone/railtie.rb +7 -0
- data/lib/rails_clone/runner.rb +38 -0
- data/lib/rails_clone/version.rb +3 -0
- data/lib/rails_clone.rb +9 -0
- data/lib/tasks/app.rake +13 -0
- data/rails_clone.gemspec +23 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 72562ea09ee116c61c60825290b3858f366cd745
|
4
|
+
data.tar.gz: b766fa8d42d245694f1d74f98085fda403a9a9a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 822df6a165994bb83b73ce152a4da0a68d723b44c7f117877267f2e4e65d6021b180f5c90c85c92e247c977aced4bd5331c10c9539a98bdfaaebee7c91743dde
|
7
|
+
data.tar.gz: 7c309ffe67346c4a108499f23f6eaf457f31680e25c7ab63437baa1219b3271b3492162378bb2f9a8cc4e7f7d82e0311d5d002aa1971f36ca8ad032008ba7484
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 jondot
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# RailsClone
|
2
|
+
|
3
|
+
[WIP]
|
4
|
+
|
5
|
+
I needed to generate Rails apps from my 'golden' base app for my
|
6
|
+
clients.
|
7
|
+
|
8
|
+
I prefer to maintain a versioned prototype and clone client apps from
|
9
|
+
that, instead of fiddling with Rails templates.
|
10
|
+
|
11
|
+
This is a gem to automate that.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'rails_clone'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
You'll see a new `app:clone` task:
|
28
|
+
|
29
|
+
```
|
30
|
+
rake app:clone[from,name,branch] # Clone an app from a branch
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
You want to change the app name (usually the namespace, db names, etc)
|
38
|
+
from some name to another name.
|
39
|
+
|
40
|
+
```
|
41
|
+
$ rake app:clone[prototype,new_app,master]
|
42
|
+
```
|
43
|
+
|
44
|
+
* prototype - the name of your prototype app. I maintain 4 app variants
|
45
|
+
named "Prime", "Omakase" and the mongodb variants of them.
|
46
|
+
|
47
|
+
* new_app - in the example, an app named "new_app"
|
48
|
+
|
49
|
+
* master - in the example, the branch I want to clone from
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
# Contributing
|
54
|
+
|
55
|
+
Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).
|
56
|
+
|
57
|
+
|
58
|
+
# Copyright
|
59
|
+
|
60
|
+
Copyright (c) 2014 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See MIT-LICENSE for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module RailsClone
|
2
|
+
class Runner < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
desc 'clone', 'Clone an app'
|
5
|
+
def clone(from, name, branch)
|
6
|
+
branches = `git branch`
|
7
|
+
unless branches.match(branch)
|
8
|
+
say "Cannot find branch #{branch}"
|
9
|
+
say "Available:\n#{branches}"
|
10
|
+
exit(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
dir = File.expand_path("../#{name}_#{branch}", destination_root)
|
14
|
+
say "Archiving current app into #{dir}"
|
15
|
+
empty_directory dir
|
16
|
+
`git archive #{branch} --format tar --output #{branch}.tar && tar -xf #{branch}.tar -C #{dir} && rm #{branch}.tar`
|
17
|
+
inside dir do
|
18
|
+
change_name(from, name)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'change_name', 'Change app name'
|
23
|
+
def change_name(from, name)
|
24
|
+
%w( app/views/layouts/application.html.erb
|
25
|
+
config/application.rb
|
26
|
+
app.json )
|
27
|
+
.each do |file|
|
28
|
+
gsub_file(file, from.classify) {|match| name.classify }
|
29
|
+
end
|
30
|
+
|
31
|
+
%w( config/database.yml
|
32
|
+
config/initializers/session_store.rb )
|
33
|
+
.each do |file|
|
34
|
+
gsub_file(file, from.camelize) {|match| name.camelize }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/rails_clone.rb
ADDED
data/lib/tasks/app.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails_clone/runner'
|
2
|
+
|
3
|
+
namespace :app do
|
4
|
+
desc "Clone an app"
|
5
|
+
task :clone, :from, :name, :branch do |t, args|
|
6
|
+
RailsClone::Runner.start(['clone',args[:from], args[:name], args[:branch]||'master'])
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Change an app name"
|
10
|
+
task :change_name, :from, :name do |t, args|
|
11
|
+
RailsClone::Runner.start(['change_name', args[:from], args[:name]])
|
12
|
+
end
|
13
|
+
end
|
data/rails_clone.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_clone/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_clone"
|
8
|
+
spec.version = RailsClone::VERSION
|
9
|
+
spec.authors = ["jondot"]
|
10
|
+
spec.email = ["jondotan@gmail.com"]
|
11
|
+
spec.summary = %q{Create a clone of a base Rails app}
|
12
|
+
spec.description = %q{Create a clone of a base Rails app. Useful for generating an app out of a base template Rails app.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_clone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jondot
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-05 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Create a clone of a base Rails app. Useful for generating an app out
|
42
|
+
of a base template Rails app.
|
43
|
+
email:
|
44
|
+
- jondotan@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/rails_clone.rb
|
55
|
+
- lib/rails_clone/railtie.rb
|
56
|
+
- lib/rails_clone/runner.rb
|
57
|
+
- lib/rails_clone/version.rb
|
58
|
+
- lib/tasks/app.rake
|
59
|
+
- rails_clone.gemspec
|
60
|
+
homepage: ''
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.2.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Create a clone of a base Rails app
|
84
|
+
test_files: []
|