from-scratch 0.6.0 → 0.7.0

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: a3665e16b338521516687e86af0988408a6caed1
4
- data.tar.gz: c3141e1f2fc858d5a06461938465d07cce9da1e7
3
+ metadata.gz: b239eb34db5ddc59624f2554877ca0700cf26755
4
+ data.tar.gz: 9bfe5e376edffa38b642d1de50c2035998b1f913
5
5
  SHA512:
6
- metadata.gz: 8b4689995e6a4d6453356727e22fc167e533459170e6096b611cbbfaa8a268b18d9f89801ef6c3acdbc930e4e6750855aaf2e5094e4aea0c5dd7ee5786ecaed0
7
- data.tar.gz: 13b9438685118f017ad6c24986b77d8008d03e7e033c227b6ead2adff75be620a0ec43caade74758452cf010ef5b3b13fb5d05d7c98105422c3e2111a9c395aa
6
+ metadata.gz: 267c755543821efdb6466a64f1780e151ccb384d5058a602033579c23fcd4dd47c4bb2cf8f20f87b6f418f7d8a2995e259a32361e06f295ad9d9acb001d73b71
7
+ data.tar.gz: e1e0c001d1102f2fbecb3189c5299e4a30a916458acc5432bd3ea7c76ccd63f7562e44d16dd91318627f0de93cca32374bb2274415d036cd664fa8878bc22582
data/README.md CHANGED
@@ -13,7 +13,7 @@ And everything is done. Then add following to your `config/deploy.rb` or `config
13
13
 
14
14
  ```ruby
15
15
  server 'your.host.com', user: 'deploy', roles: %w(app db web)
16
- set :deploy_to, "/home/deploy/your_app_name"
16
+ set :deploy_to, "/home/deploy/#{fetch(:application)}"
17
17
  ```
18
18
 
19
19
  ## Supports
@@ -28,11 +28,15 @@ Ruby installers:
28
28
  - RVM (default)
29
29
  - rbenv: `scratchify your_app_name your.host.com --rbenv`
30
30
 
31
+ Setting specific ruby version:
32
+
33
+ $ scratchify your_app_name your.host.com --ruby jruby-1.7.19
34
+
31
35
  ## It's a kind of magic!
32
36
 
33
37
  Not actully. Just preconfigured [Chef](https://www.chef.io/). Here are the things done with the command:
34
38
 
35
- - Install user-wide RVM with latest MRI (2.2.3)
39
+ - Install user-wide RVM with latest MRI (2.2.4)
36
40
  - Install PostgreSQL, create database with user, pg_tune a little
37
41
  - Add _deploy_ non-admin user to system specially for your app, upload your SSH pub key to it
38
42
  - Install nginx and replace it's default site config with one prepared for rails app
data/chefignore CHANGED
@@ -100,3 +100,4 @@ Gemfile.lock
100
100
  Rakefile
101
101
  lib/*
102
102
  bin/*
103
+ *.gem
@@ -13,7 +13,7 @@ And everything is done. Then add following to your `config/deploy.rb` or `config
13
13
 
14
14
  ```ruby
15
15
  server 'your.host.com', user: 'deploy', roles: %w(app db web)
16
- set :deploy_to, "/home/deploy/your_app_name"
16
+ set :deploy_to, "/home/deploy/#{fetch(:application)}"
17
17
  ```
18
18
 
19
19
  ## Supports
@@ -28,11 +28,15 @@ Ruby installers:
28
28
  - RVM (default)
29
29
  - rbenv: `scratchify your_app_name your.host.com --rbenv`
30
30
 
31
+ Setting specific ruby version:
32
+
33
+ $ scratchify your_app_name your.host.com --ruby jruby-1.7.19
34
+
31
35
  ## It's a kind of magic!
32
36
 
33
37
  Not actully. Just preconfigured [Chef](https://www.chef.io/). Here are the things done with the command:
34
38
 
35
- - Install user-wide RVM with latest MRI (2.2.3)
39
+ - Install user-wide RVM with latest MRI (2.2.4)
36
40
  - Install PostgreSQL, create database with user, pg_tune a little
37
41
  - Add _deploy_ non-admin user to system specially for your app, upload your SSH pub key to it
38
42
  - Install nginx and replace it's default site config with one prepared for rails app
@@ -100,3 +100,4 @@ Gemfile.lock
100
100
  Rakefile
101
101
  lib/*
102
102
  bin/*
103
+ *.gem
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = %w(scratchify)
19
19
  spec.require_paths = %w(lib)
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency 'rspec', "~> 3.3"
24
- spec.add_development_dependency 'rspec-its'
25
- spec.add_development_dependency 'pry', "~> 0.10"
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec', "~> 3.3"
24
+ spec.add_development_dependency 'rspec-its', "~> 1.2"
25
+ spec.add_development_dependency 'pry', "~> 0.10"
26
26
 
27
27
  spec.add_dependency 'knife-solo'
28
28
  spec.add_dependency 'knife-solo_data_bag'
@@ -21,7 +21,7 @@
21
21
 
22
22
  <% if @options.ruby_installer == 'rvm' %>
23
23
  "rvm": {
24
- "user_default_ruby": "2.2.3",
24
+ "user_default_ruby": "<%= @options.ruby_version %>",
25
25
  "user_install_rubies": true,
26
26
  "installs": {
27
27
  "deploy": true
@@ -38,12 +38,12 @@
38
38
  "user_installs": [
39
39
  { "user": "deploy",
40
40
  "rubies": [{
41
- "name": "2.2.3",
41
+ "name": "<%= @options.ruby_version %>",
42
42
  "environment": {
43
43
  "RUBY_CONFIGURE_OPTS": "--disable-install-doc"
44
44
  }
45
45
  }],
46
- "global": "2.2.3"
46
+ "global": "<%= @options.ruby_version %>"
47
47
  }
48
48
  ]
49
49
  },
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = %w(scratchify)
19
19
  spec.require_paths = %w(lib)
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency 'rspec', "~> 3.3"
24
- spec.add_development_dependency 'rspec-its'
25
- spec.add_development_dependency 'pry', "~> 0.10"
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec', "~> 3.3"
24
+ spec.add_development_dependency 'rspec-its', "~> 1.2"
25
+ spec.add_development_dependency 'pry', "~> 0.10"
26
26
 
27
27
  spec.add_dependency 'knife-solo'
28
28
  spec.add_dependency 'knife-solo_data_bag'
@@ -5,7 +5,7 @@ require 'optparse'
5
5
  require 'ostruct'
6
6
 
7
7
  class FromScratch
8
- DEFAULTS = { ruby_installer: 'rvm' }
8
+ DEFAULTS = { ruby_installer: 'rvm', ruby_version: '2.2.4' }
9
9
 
10
10
  attr_accessor :options
11
11
 
@@ -51,6 +51,10 @@ class FromScratch
51
51
  @options.ruby_installer = 'rbenv'
52
52
  end
53
53
 
54
+ args.on '--ruby [VERSION]', "Choose specific ruby version instead of latest MRI" do |ruby_version|
55
+ @options.ruby_version = ruby_version
56
+ end
57
+
54
58
  args.on '-h', '--help', 'Prints this help' do
55
59
  puts args
56
60
  exit
@@ -1,3 +1,3 @@
1
1
  class FromScratch
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -21,7 +21,7 @@
21
21
 
22
22
  <% if @options.ruby_installer == 'rvm' %>
23
23
  "rvm": {
24
- "user_default_ruby": "2.2.3",
24
+ "user_default_ruby": "<%= @options.ruby_version %>",
25
25
  "user_install_rubies": true,
26
26
  "installs": {
27
27
  "deploy": true
@@ -38,12 +38,12 @@
38
38
  "user_installs": [
39
39
  { "user": "deploy",
40
40
  "rubies": [{
41
- "name": "2.2.3",
41
+ "name": "<%= @options.ruby_version %>",
42
42
  "environment": {
43
43
  "RUBY_CONFIGURE_OPTS": "--disable-install-doc"
44
44
  }
45
45
  }],
46
- "global": "2.2.3"
46
+ "global": "<%= @options.ruby_version %>"
47
47
  }
48
48
  ]
49
49
  },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: from-scratch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Shaydurov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-27 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rspec-its
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -575,23 +575,17 @@ files:
575
575
  - cookbooks/rvm/test/unit/libraries/provider_rvm_installation_spec.rb
576
576
  - cookbooks/rvm/test/unit/libraries/resource_rvm_installation_spec.rb
577
577
  - cookbooks/rvm/test/unit/spec_helper.rb
578
- - cookbooks/scratchify/.chef/knife.rb
579
578
  - cookbooks/scratchify/Berksfile
580
579
  - cookbooks/scratchify/Berksfile.lock
581
580
  - cookbooks/scratchify/LICENSE.txt
582
581
  - cookbooks/scratchify/README.md
583
582
  - cookbooks/scratchify/Thorfile
584
- - cookbooks/scratchify/bin/scratchify
585
583
  - cookbooks/scratchify/chefignore
586
584
  - cookbooks/scratchify/from-scratch.gemspec
587
- - cookbooks/scratchify/lib/from-scratch.rb
588
- - cookbooks/scratchify/lib/from-scratch/version.rb
589
585
  - cookbooks/scratchify/metadata.json
590
586
  - cookbooks/scratchify/recipes/default.rb
591
587
  - cookbooks/scratchify/recipes/nginx_site.rb
592
588
  - cookbooks/scratchify/recipes/pre_rvm.rb
593
- - cookbooks/scratchify/spec/from/scratch_spec.rb
594
- - cookbooks/scratchify/spec/spec_helper.rb
595
589
  - cookbooks/scratchify/templates/database.yml.erb
596
590
  - cookbooks/scratchify/templates/nginx.erb
597
591
  - cookbooks/scratchify/templates/node.json.erb
@@ -1,6 +0,0 @@
1
- cookbook_path "cookbooks"
2
- node_path "tmp/nodes"
3
- data_bag_path "tmp/data_bags"
4
-
5
- knife[:berkshelf_path] = "cookbooks"
6
- Chef::Config[:ssl_verify_mode] = :verify_peer if defined? ::Chef
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "from-scratch"
5
-
6
- FromScratch.new.run!
@@ -1,68 +0,0 @@
1
- require 'securerandom'
2
- require 'erb'
3
- require 'fileutils'
4
- require 'optparse'
5
- require 'ostruct'
6
-
7
- class FromScratch
8
- DEFAULTS = { ruby_installer: 'rvm' }
9
-
10
- attr_accessor :options
11
-
12
- def initialize
13
- @options = OpenStruct.new DEFAULTS
14
- end
15
-
16
- def run!
17
- parse_options
18
- get_host_and_app_name
19
- generate_values
20
-
21
- { node: ['nodes', @options.host],
22
- user: ['data_bags/users', 'deploy']
23
- }.each do |from, to|
24
- FileUtils.mkdir_p File.expand_path("../../tmp/#{to[0]}", __FILE__)
25
- File.open(File.expand_path("../../tmp/#{to.join('/')}.json", __FILE__), 'w') do |f|
26
- f.write ERB.new(File.open(File.expand_path("../../templates/#{from}.json.erb", __FILE__)).read).result(binding)
27
- end
28
- end
29
-
30
- Dir.chdir(File.expand_path('../..', __FILE__)) do
31
- system "knife solo bootstrap root@#{@options.host} -c ./.chef/knife.rb"
32
- system "knife solo clean root@#{@options.host} -c ./.chef/knife.rb"
33
- end
34
-
35
- FileUtils.rm_rf [File.expand_path('../../tmp', __FILE__)]
36
- end
37
-
38
- def get_host_and_app_name
39
- @options.app_name, @options.host = ARGV.select { |x| !(x =~ /^\-/) }
40
-
41
- unless @options.app_name && @options.host
42
- raise ArgumentError, 'You should specify APP_NAME and HOST. Use --help for information.'
43
- end
44
- end
45
-
46
- def parse_options
47
- opt_parser = OptionParser.new do |args|
48
- args.banner = "Usage: scratchify your_app_name your.host.com [options]"
49
-
50
- args.on '--rbenv', 'Use RBENV instead of RVM' do
51
- @options.ruby_installer = 'rbenv'
52
- end
53
-
54
- args.on '-h', '--help', 'Prints this help' do
55
- puts args
56
- exit
57
- end
58
- end
59
-
60
- opt_parser.parse!
61
- end
62
-
63
- def generate_values
64
- @options.ssh_pub_key = `cat ~/.ssh/id_rsa.pub`.strip
65
- @options.postgresql_admin_password = `echo -n '#{SecureRandom.base64(16)}''postgres' | openssl md5 | sed -e 's/.* /md5/'`.strip
66
- @options.postgresql_user_password = SecureRandom.base64(16)
67
- end
68
- end
@@ -1,3 +0,0 @@
1
- class FromScratch
2
- VERSION = "0.6.0"
3
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FromScratch do
4
- let(:instance) { described_class.new }
5
- let(:app_name) { 'my_app' }
6
- let(:host) { 'host.example.com' }
7
-
8
- describe '::new' do
9
- subject { instance }
10
-
11
- its('options.to_h') { are_expected.to eq(described_class::DEFAULTS) }
12
- end
13
-
14
- describe '#get_host_and_app_name' do
15
- before do
16
- stub_const 'ARGV', argv
17
- end
18
-
19
- subject { instance.options }
20
-
21
- context 'with app_name and host' do
22
- before { instance.get_host_and_app_name }
23
- let(:argv) { [app_name, host] }
24
-
25
- its(:app_name) { is_expected.to eq(app_name) }
26
- its(:host) { is_expected.to eq(host) }
27
- end
28
-
29
- context 'without one of app_name or host' do
30
- let(:argv) { [app_name] }
31
-
32
- it 'should raise' do
33
- expect do
34
- instance.get_host_and_app_name
35
- end.to raise_error(ArgumentError)
36
- end
37
-
38
- context 'and with --option' do
39
- let(:argv) { [app_name, '--option'] }
40
-
41
- it 'should raise' do
42
- expect do
43
- instance.get_host_and_app_name
44
- end.to raise_error(ArgumentError)
45
- end
46
- end
47
- end
48
- end
49
-
50
- describe '#parse_options' do
51
- before do
52
- stub_const 'ARGV', argv
53
- instance.parse_options
54
- end
55
-
56
- subject { instance.options }
57
-
58
- context 'with --rbenv' do
59
- let(:argv) { [app_name, host, '--rbenv'] }
60
-
61
- its(:ruby_installer) { is_expected.to eq('rbenv') }
62
- end
63
- end
64
-
65
- it 'has a version number' do
66
- expect(FromScratch::VERSION).not_to be nil
67
- end
68
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'rspec/its'
3
- require 'from-scratch'
4
- require 'pry'
5
-
6
- RSpec.configure do |c|
7
- c.filter_run focus: true
8
- c.run_all_when_everything_filtered = true
9
- end