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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c9f63a1b56bb93b9c6dc1d89d5ebe14879a8d13
4
- data.tar.gz: 99d8b62c1d513aad577c3ce5eaa4ad6fe475d7ca
3
+ metadata.gz: 4796dc67275bd498094319869adcf14864198733
4
+ data.tar.gz: 3cbdcf5b99f8be252ae5699c90e8df4d23302107
5
5
  SHA512:
6
- metadata.gz: 3a4baaa51b7061979600127f22f7d33bc2e057a68339c22733121f2aca381c8eea598cc1f2df7719b7367b28562f2ca0c3c456c15b701316dccae421fa718921
7
- data.tar.gz: 7049d2579403dba12865fd432af8330a96fff260c012790861d70a40fd776e08bb941d1cd4950673d02a5058b13a9bc7f56a82ab3e12341a2802199c3d01d2f3
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 privately managed repository of templates on `http://rails-new.herokuapp.com/admin`. We don't store the templates itself but a reference to his repository location (only GIT supported right now). The main objective of this repository is to be to able to put in a single place how the template should be using.
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
- For example, this url: <http://rails-new.herokuapp.com/api/v1/templates/julio/base.json> returns:
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": "base",
12
- "git_repository": "https://github.com/juliogarciag/rails-template.git",
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-test-unit",
29
+ "key": "--skip-spring",
18
30
  "has_value": false,
19
31
  "value": ""
20
32
  },
21
33
  {
22
34
  "id": 2,
23
- "key": "--skip-turbolinks",
35
+ "key": "--skip-test-unit",
24
36
  "has_value": false,
25
37
  "value": ""
26
38
  },
27
39
  {
28
40
  "id": 3,
29
- "key": "--skip-bundle",
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
- The fact that is privately managed is just temporal. To make it public, we should need to improve the UI and improve the security to completely remove the chance of shell execution through the pass of parameters or some other arguments. Because we are not totally sure yet of the security of that system, the system is kept privately.
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
- The main point of this gem is to allow to use that template in this way:
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 = TEMPLATE_URL[template_key]
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 "git clone -b #{@git_branch} #{@git_repository} #{temp_dir}"
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
@@ -0,0 +1,11 @@
1
+ module RailsNew
2
+ module Api
3
+ extend self
4
+
5
+ API_SERVER = ENV['RAILS_NEW_API_SERVER'] || "https://rails-new.herokuapp.com"
6
+
7
+ def template_url_for(template_key)
8
+ "#{API_SERVER}/api/v1/templates/#{template_key}.json"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module RailsNew
2
+ VERSION = "0.0.5"
3
+ end
data/lib/rails_new.rb ADDED
@@ -0,0 +1,4 @@
1
+ module RailsNew
2
+ end
3
+
4
+ require_relative './rails_new/api'
@@ -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 'rails/new/gem/version'
4
+ require 'rails_new/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rails-new"
8
- spec.version = Rails::New::Gem::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
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-15 00:00:00.000000000 Z
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/rails/new/gem.rb
84
- - lib/rails/new/gem/version.rb
85
- - rails-new-gem.gemspec
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
@@ -1,7 +0,0 @@
1
- module Rails
2
- module New
3
- module Gem
4
- VERSION = "0.0.4"
5
- end
6
- end
7
- end
data/lib/rails/new/gem.rb DELETED
@@ -1,9 +0,0 @@
1
- require "rails/new/gem/version"
2
-
3
- module Rails
4
- module New
5
- module Gem
6
- # Your code goes here...
7
- end
8
- end
9
- end