rails-new 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -20
- data/bin/rails-new +4 -8
- data/lib/rails_new/.DS_Store +0 -0
- data/lib/rails_new/api.rb +11 -0
- data/lib/rails_new/version.rb +3 -0
- data/lib/rails_new.rb +4 -0
- data/{rails-new-gem.gemspec → rails-new.gemspec} +2 -2
- metadata +7 -5
- data/lib/rails/new/gem/version.rb +0 -7
- data/lib/rails/new/gem.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4796dc67275bd498094319869adcf14864198733
|
4
|
+
data.tar.gz: 3cbdcf5b99f8be252ae5699c90e8df4d23302107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e7ac0ab0068a4c92b32ad51c19f94f21130066bb4202af19573213f16786886ca54901d95601c7ff51a6169e37f9c0cf18d90486c11f9291acb7867e173831
|
7
|
+
data.tar.gz: 05a97a083d462f38d886b2f5ebcaa9f07a2411a08d940209b177c2b6b2cba06a67a6e29a74343407887142b0fd8cec8f4e338709227a6598184c70eac7f363b5
|
data/README.md
CHANGED
@@ -1,38 +1,44 @@
|
|
1
1
|
# Rails New
|
2
2
|
|
3
|
-
This is a wrapper over `rails new` attached to a
|
3
|
+
This is a wrapper over `rails new` attached to a repository of rails application templates located on <http://rails-new.herokuapp.com>. This repository stores templates to be used with this gem as a client. The main objective is to be able to make something like this:
|
4
4
|
|
5
|
-
|
5
|
+
```bash
|
6
|
+
$ rails-new my-organization/application my-new-project
|
7
|
+
```
|
8
|
+
|
9
|
+
or even have the ability to have two or more rails templates related to specific things:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
$ rails-new my-organization/api my-new-api
|
13
|
+
```
|
14
|
+
|
15
|
+
To accomplish this, the repository exposes a public API using your username and the template name. For example, this url: <http://rails-new.herokuapp.com/api/v1/templates/julio/application.json> returns the data for the stored template `julio/application` created by the user `julio` and named `application`:
|
6
16
|
|
7
17
|
```json
|
8
18
|
{
|
9
19
|
"template": {
|
10
20
|
"id": 1,
|
11
|
-
"name": "
|
12
|
-
"git_repository": "https://github.com/juliogarciag/rails-template
|
21
|
+
"name": "application",
|
22
|
+
"git_repository": "https://github.com/juliogarciag/rails-template",
|
23
|
+
"git_branch": "master",
|
13
24
|
"main_file_location": "template.rb",
|
25
|
+
"updated_at": "2015-03-15T06:51:57.106Z",
|
14
26
|
"arguments": [
|
15
27
|
{
|
16
28
|
"id": 1,
|
17
|
-
"key": "--skip-
|
29
|
+
"key": "--skip-spring",
|
18
30
|
"has_value": false,
|
19
31
|
"value": ""
|
20
32
|
},
|
21
33
|
{
|
22
34
|
"id": 2,
|
23
|
-
"key": "--skip-
|
35
|
+
"key": "--skip-test-unit",
|
24
36
|
"has_value": false,
|
25
37
|
"value": ""
|
26
38
|
},
|
27
39
|
{
|
28
40
|
"id": 3,
|
29
|
-
"key": "--skip-
|
30
|
-
"has_value": false,
|
31
|
-
"value": ""
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"id": 4,
|
35
|
-
"key": "--skip-spring",
|
41
|
+
"key": "--skip-turbolinks",
|
36
42
|
"has_value": false,
|
37
43
|
"value": ""
|
38
44
|
}
|
@@ -41,15 +47,12 @@ For example, this url: <http://rails-new.herokuapp.com/api/v1/templates/julio/ba
|
|
41
47
|
}
|
42
48
|
```
|
43
49
|
|
44
|
-
This json represents the arguments needed for this template, the repository where this is stored and the location of the template file inside of the the repository.
|
50
|
+
This json represents the arguments needed for this template, the repository where this is stored and the location of the template file inside of the the repository. The point is to be able to use it from this gem (or from somewhere else) to do two things (of many) that are very complex with Rails application templates:
|
45
51
|
|
46
|
-
|
52
|
+
- Tie arguments (`--skip-turbolinks`, `--skip-test-unit`, etc) to the template. If you build a template that heavily rely on RSpec, you may want to make `--skip-test-unit` required as an argument. In normal usage, you should need to add the argument aside from the template argument.
|
53
|
+
- `rails new -m URL` is broken by design. The command only works with super simple templates that doesn't use erb templates or copy files from somewhere else. This gem downloads the template with all the files needed to run and runs it from the file system, avoiding the problem with using urls.
|
47
54
|
|
48
|
-
|
49
|
-
|
50
|
-
```bash
|
51
|
-
rails-new julio/base my-new-project
|
52
|
-
```
|
55
|
+
And, additionally, and this is more of a side-effect, this allows us to share Rails templates built in whatever way you want with everyone.
|
53
56
|
|
54
57
|
## Installation
|
55
58
|
|
@@ -61,6 +64,11 @@ Install running:
|
|
61
64
|
|
62
65
|
Run `rails-new --help` for instructions.
|
63
66
|
|
67
|
+
## Current Caveats
|
68
|
+
|
69
|
+
- Right now, before running the `rails new...` command built with the template, the gem asks for confirmation of the command because there's always the chance of injection in maybe unexpected ways we can't simply assume don't exist. (If you can think of a way to avoid doing this, it will be really useful)
|
70
|
+
- All templates are readable by everyone right now. We didn't think of a way to authenticate some template request right now without complicating the flow yet. This is just temporal.
|
71
|
+
|
64
72
|
## Contributing with Templates while private
|
65
73
|
|
66
74
|
Create an issue with the git repository of the template, the location inside it, the name of the user you want to keep the repository within, the name of the template and the arguments you expect the template to be called with. This is just temporal until we figure out how to make it more user-friendly and secure at the same time.
|
data/bin/rails-new
CHANGED
@@ -5,6 +5,8 @@ require "thor/group"
|
|
5
5
|
require 'httparty'
|
6
6
|
require 'tmpdir'
|
7
7
|
|
8
|
+
require_relative '../lib/rails_new'
|
9
|
+
|
8
10
|
class RailsNewWrapper < Thor::Group
|
9
11
|
desc "run `rails new` with the requirements of the template"
|
10
12
|
|
@@ -18,14 +20,8 @@ class RailsNewWrapper < Thor::Group
|
|
18
20
|
:desc => "The application name to pass to Rails",
|
19
21
|
:required => true
|
20
22
|
|
21
|
-
RAILS_NEW_API_SERVER = ENV['RAILS_NEW_API_SERVER'] || "https://rails-new.herokuapp.com"
|
22
|
-
|
23
|
-
TEMPLATE_URL = -> template_key do
|
24
|
-
"#{RAILS_NEW_API_SERVER}/api/v1/templates/#{template_key}.json"
|
25
|
-
end
|
26
|
-
|
27
23
|
def request_template_data
|
28
|
-
url =
|
24
|
+
url = RailsNew::Api.template_url_for(template_key)
|
29
25
|
|
30
26
|
say "Fetching template data from ", :green, false
|
31
27
|
say url, :blue
|
@@ -50,7 +46,7 @@ class RailsNewWrapper < Thor::Group
|
|
50
46
|
|
51
47
|
say "Cloning git repository ", :green, false
|
52
48
|
say @git_repository, :blue
|
53
|
-
Kernel.system
|
49
|
+
Kernel.system %w{git clone -b #{@git_branch} #{@git_repository} #{temp_dir}}
|
54
50
|
|
55
51
|
command = [
|
56
52
|
"rails", "new", @app_name, "-m", template_location, *@arguments, *extra_rails_arguments
|
Binary file
|
data/lib/rails_new.rb
ADDED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'rails_new/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "rails-new"
|
8
|
-
spec.version =
|
8
|
+
spec.version = RailsNew::VERSION
|
9
9
|
spec.authors = ["juliogarciag"]
|
10
10
|
spec.email = ["julioggonz@gmail.com"]
|
11
11
|
spec.summary = %q{A Rails template installation command.}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-new
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,9 +80,11 @@ files:
|
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
82
|
- bin/rails-new
|
83
|
-
- lib/
|
84
|
-
- lib/
|
85
|
-
-
|
83
|
+
- lib/rails_new.rb
|
84
|
+
- lib/rails_new/.DS_Store
|
85
|
+
- lib/rails_new/api.rb
|
86
|
+
- lib/rails_new/version.rb
|
87
|
+
- rails-new.gemspec
|
86
88
|
homepage: ''
|
87
89
|
licenses:
|
88
90
|
- MIT
|