fly.io-rails 0.2.2 → 0.2.4

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
  SHA256:
3
- metadata.gz: '091df3ce45d486651daa4c683f833bf32a70125a00864d8d35cf83aeff979bf8'
4
- data.tar.gz: bb2d0a59197a4a9731ed03367a81cccafe2f770a7949e49b2ae744db9cec5647
3
+ metadata.gz: 441c33814d7b420542d516c828b710b72802b50370a449f8e0a63fb2bbb83460
4
+ data.tar.gz: 8f300d43d0b7d0f712b92fba97a38eb71a1e5cf1ecd5caf5e474f0886742a8a1
5
5
  SHA512:
6
- metadata.gz: b30322c1952953f68d2edf9d5ad85d333c7d71e956ff8a0f41c7e06c8b301f19610f915470d9ef0a4b665e31703714d93478bf2884d65a818c11adbda1bda7b4
7
- data.tar.gz: b4ac51e241cbbdf226013d2421a44b0fae3d532e04ccd6f0b4fd5b870780aff55671b44d2d7fd11abe09fd7ada1f00973409d18d646d4640ba3f862b1185b1b4
6
+ metadata.gz: f19969c7b8f4c4af08e5522c429f4237b70bf0af2cdd92908a632204761978a8a17fbf2569d8191cf826167ef1550c793cad18ba0311550c18c1717288757cc0
7
+ data.tar.gz: 2e54d69fbb7203c19157ddf6de6851e80ee0fc5c79ea485e728e11d6a645e056bf4fd3802abae612455fabf768782076762788bceb54e7f61437faac7442f14b
@@ -16,13 +16,13 @@ module Fly
16
16
  include Fly::Scanner
17
17
  attr_accessor :options
18
18
 
19
- def initialize(app, options={})
19
+ def initialize(app=nil, options={})
20
20
  # placate thor
21
21
  @options = {}
22
22
  @destination_stack = [Dir.pwd]
23
23
 
24
24
  # extract options
25
- self.app = app
25
+ app ? self.app = app : app = self.app
26
26
  regions = options[:region]&.flatten || []
27
27
  @avahi = options[:avahi]
28
28
  @litefs = options[:litefs]
@@ -0,0 +1,42 @@
1
+ $:.unshift File.expand_path('lib')
2
+ require 'fly.io-rails/actions'
3
+
4
+ require 'bundler'
5
+ require 'pp'
6
+
7
+ def check_git
8
+ return if Dir.exist? '/srv/fly.io-rails/lib'
9
+
10
+ spec = Bundler::Definition.build('Gemfile', nil, []).dependencies.
11
+ find {|spec| spec.name == 'fly.io-rails'}
12
+
13
+ if spec.git
14
+ if `which git`.empty? and File.exist? '/etc/debian_version'
15
+ system 'apt-get update'
16
+ system 'apt-get install -y git'
17
+ end
18
+
19
+ system `git clone --depth 1 #{spec.git} /srv/fly.io-rails`
20
+ exit 1 unless Dir.exist? '/srv/fly.io-rails/lib'
21
+ ENV['RUBYLIB'] = '/srv/fly.io-rails/lib'
22
+ exec "ruby -r fly.io-rails/deploy -e #{caller_locations(1,1)[0].label}"
23
+ end
24
+ end
25
+
26
+ def dump_config
27
+ action = Fly::Actions.new
28
+
29
+ config = {}
30
+ action.instance_variables.sort.each do |name|
31
+ config[name] = action.instance_variable_get(name)
32
+ end
33
+
34
+ File.open('/srv/config', 'w') {|file| PP.pp(config, file)}
35
+ end
36
+
37
+ def build_gems
38
+ check_git
39
+ dump_config
40
+
41
+ system 'rake -f lib/tasks/fly.rake fly:build_gems'
42
+ end
@@ -1,10 +1,26 @@
1
1
  module Fly
2
2
  module DSL
3
3
  class Base
4
+ @@blocks = {}
5
+
4
6
  def initialize
5
7
  @value = {}
6
8
  end
7
9
 
10
+ def self.block name, kind
11
+ @@blocks[name] = kind
12
+
13
+ define_method name do |&block|
14
+ @config[name] ||= kind.new
15
+ @config[name].instance_eval(&block) if block
16
+ @config[name]
17
+ end
18
+ end
19
+
20
+ def self.blocks
21
+ @@blocks
22
+ end
23
+
8
24
  def self.option name, default=nil
9
25
  @options ||= {}
10
26
  @options[name] = default
@@ -47,33 +63,23 @@ module Fly
47
63
  option :size, 3
48
64
  end
49
65
 
66
+ class Deploy < Base
67
+ option :swap_mb, 0
68
+ end
69
+
50
70
  #############################################################
51
71
 
52
- class Config
53
- @@blocks = {}
72
+ class Config < Base
54
73
 
55
74
  def initialize
56
75
  @config = {}
57
76
  end
58
77
 
59
- def self.block name, kind
60
- @@blocks[name] = kind
61
-
62
- define_method name do |&block|
63
- @config[name] ||= kind.new
64
- @config[name].instance_eval(&block) if block
65
- @config[name]
66
- end
67
- end
68
-
69
- def self.blocks
70
- @@blocks
71
- end
72
-
73
78
  block :machine, Machine
74
79
  block :postgres, Postgres
75
80
  block :redis, Redis
76
81
  block :sqlite3, Sqlite3
82
+ block :deploy, Deploy
77
83
  end
78
84
  end
79
85
  end
@@ -1,3 +1,3 @@
1
1
  module Fly_io
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'fly.io-rails/actions'
2
+
3
+ module Fly::Generators
4
+ class ConfigGenerator < Rails::Generators::Base
5
+ include FlyIoRails::Utils
6
+
7
+ # despite its name, this is a debug tool that will dump the config
8
+ def generate_config
9
+ action = Fly::Actions.new(@app, options)
10
+
11
+ config = {}
12
+ action.instance_variables.sort.each do |name|
13
+ config[name] = action.instance_variable_get(name)
14
+ end
15
+
16
+ pp config
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fly.io-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-10 00:00:00.000000000 Z
11
+ date: 2022-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fly-ruby
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description:
55
+ description:
56
56
  email: rubys@intertwingly.net
57
57
  executables: []
58
58
  extensions: []
@@ -63,6 +63,7 @@ files:
63
63
  - Rakefile
64
64
  - lib/fly.io-rails.rb
65
65
  - lib/fly.io-rails/actions.rb
66
+ - lib/fly.io-rails/deploy.rb
66
67
  - lib/fly.io-rails/dsl.rb
67
68
  - lib/fly.io-rails/generators.rb
68
69
  - lib/fly.io-rails/hcl.rb
@@ -72,6 +73,7 @@ files:
72
73
  - lib/fly.io-rails/utils.rb
73
74
  - lib/fly.io-rails/version.rb
74
75
  - lib/generators/fly/app_generator.rb
76
+ - lib/generators/fly/config_generator.rb
75
77
  - lib/generators/fly/terraform_generator.rb
76
78
  - lib/generators/templates/Dockerfile.erb
77
79
  - lib/generators/templates/Procfile.fly.erb
@@ -91,7 +93,7 @@ licenses:
91
93
  - Apache-2.0
92
94
  metadata:
93
95
  homepage_uri: https://github.com/rubys/fly.io-rails
94
- post_install_message:
96
+ post_install_message:
95
97
  rdoc_options: []
96
98
  require_paths:
97
99
  - lib
@@ -106,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  - !ruby/object:Gem::Version
107
109
  version: '0'
108
110
  requirements: []
109
- rubygems_version: 3.3.11
110
- signing_key:
111
+ rubygems_version: 3.3.5
112
+ signing_key:
111
113
  specification_version: 4
112
114
  summary: Rails support for Fly-io
113
115
  test_files: []