rails-new 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rails-new +65 -20
- data/lib/rails/new/gem/version.rb +1 -1
- data/rails-new-gem.gemspec +2 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42df0666b0fe511c259d52c15ad0e9043997d8dd
|
4
|
+
data.tar.gz: 667b2704058d7c64a50e891eed25e3f8345ec90e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f488c8d73d6c219e7eb162638137a4e8e050f6e5fd257f00ce9f48265d1c3ebd239c85b43aff4e76d45b17af1d8f60b25a703edf86911664c21434d09c0263
|
7
|
+
data.tar.gz: c1745ef8cdea41fa44867884d7b667345734e7fd228ca9c14d9b2f2d50df0122c7c49f4e5a08c2a43a1ae7ed83da5eb10acb0d52914e5991d1eac87041e92b64
|
data/bin/rails-new
CHANGED
@@ -1,32 +1,77 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "thor"
|
4
|
+
require "thor/group"
|
3
5
|
require 'httparty'
|
4
6
|
require 'tmpdir'
|
5
7
|
|
6
|
-
|
8
|
+
class RailsNewWrapper < Thor::Group
|
9
|
+
desc "run `rails new` with the requirements of the template"
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
argument :template_key,
|
12
|
+
:type => :string,
|
13
|
+
:desc => "The template key in the format user/template",
|
14
|
+
:required => true
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
argument :app_name,
|
17
|
+
:type => :string,
|
18
|
+
:desc => "The application name to pass to Rails",
|
19
|
+
:required => true
|
20
|
+
|
21
|
+
TEMPLATE_URL = -> template_key do
|
22
|
+
"https://rails-new.herokuapp.com/api/v1/templates/#{template_key}.json"
|
23
|
+
end
|
24
|
+
|
25
|
+
def request_template_data
|
26
|
+
url = TEMPLATE_URL[template_key]
|
19
27
|
|
20
|
-
|
21
|
-
|
22
|
-
git_repository = template_data['git_repository']
|
23
|
-
main_file_location = template_data["main_file_location"]
|
24
|
-
arguments = build_arguments_array(template_data['arguments'])
|
28
|
+
say "Fetching template data from ", :green, false
|
29
|
+
say url, :blue
|
25
30
|
|
26
|
-
|
27
|
-
|
31
|
+
@response = HTTParty.get(url)
|
32
|
+
if @response.code != 200
|
33
|
+
raise "The response of the server to #{@response.request.uri} was not 200."
|
34
|
+
end
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
37
|
+
def parse_template_data
|
38
|
+
@template_data = JSON.parse(@response.body)['template']
|
39
|
+
@git_repository = @template_data['git_repository']
|
40
|
+
@main_file_location = @template_data["main_file_location"]
|
41
|
+
@arguments = build_arguments_array(@template_data['arguments'])
|
42
|
+
end
|
43
|
+
|
44
|
+
def run_template
|
45
|
+
Dir.mktmpdir do |temp_dir|
|
46
|
+
template_location = Pathname.new(temp_dir).join(@main_file_location).to_s
|
47
|
+
|
48
|
+
say "Cloning git repository ", :green, false
|
49
|
+
say @git_repository, :blue
|
50
|
+
Kernel.system "git clone #{@git_repository} #{temp_dir}"
|
51
|
+
|
52
|
+
command = [
|
53
|
+
"rails", "new", @app_name, "-m", template_location, *@arguments, *extra_rails_arguments
|
54
|
+
]
|
55
|
+
|
56
|
+
say "Running rails command ", :green, false
|
57
|
+
say command.join(' '), :blue
|
58
|
+
Kernel.system *command
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def build_arguments_array(arguments)
|
65
|
+
arguments.map do |arg|
|
66
|
+
tokens = [arg['key']]
|
67
|
+
tokens << [arg['value']] if arg['has_value']
|
68
|
+
tokens
|
69
|
+
end.flatten
|
70
|
+
end
|
71
|
+
|
72
|
+
def extra_rails_arguments
|
73
|
+
@extra_rails_arguments ||= ARGV[2..-1]
|
31
74
|
end
|
32
75
|
end
|
76
|
+
|
77
|
+
RailsNewWrapper.start(ARGV)
|
data/rails-new-gem.gemspec
CHANGED
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_dependency "httparty", "0.13
|
23
|
+
spec.add_dependency "httparty", "~> 0.13"
|
24
|
+
spec.add_dependency "thor", "~> 0.19"
|
24
25
|
end
|
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.2
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,16 +42,30 @@ dependencies:
|
|
42
42
|
name: httparty
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.13
|
47
|
+
version: '0.13'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.19'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
68
|
+
version: '0.19'
|
55
69
|
description: A Rails template installation command.
|
56
70
|
email:
|
57
71
|
- julioggonz@gmail.com
|