utopia 2.13.1 → 2.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8b5b3a827d5761b59943834584c7662632de566d79966cc452d53a9a62c420f
4
- data.tar.gz: d9448719a5819dcf6afc7b2c82c0add6972d5d934a1312c01419a03a650f6d03
3
+ metadata.gz: b55bff1afd9814b453d84f5539d06fb4e969c804bedae04eb40259ff934b2097
4
+ data.tar.gz: 4483a3359f05949c3952ff22e4d6bd3f34907e861b2da9e8b75ed77a84d8b6a6
5
5
  SHA512:
6
- metadata.gz: 607d2cf34d0d851e653f8fc3a3c913255c398edf657af96d8a611bb8ea7b2b9a7a8aa0a22c4d1a5a7683da0d6990c07264e237ee3e9458a9bca04961c3925465
7
- data.tar.gz: 37cf0301c908e4790b6711cbd3cde0f2e0362a866232633c51c86868d3c4c2781ebef12a743fdf805c7c711ec0ff11bc04bae561e3c7cdbbff7f9e3696708b02
6
+ metadata.gz: f4512d2aae4b421a2a10cf5ccb50badfa4dee7792ab59dabb79eaab0792e9bed35f5f61a0a1bbe04e38acbed98bdf714583de7f75cbded5ac2fcea6112c28b89
7
+ data.tar.gz: b5ae7a176dedc1af47f5e2a8a57b3d8168de33f11824b607e972d5c6eba81d409583626cff3bc4daedd4ba8c3166a18015c554a418b3e65999d1bfd3fc56b4b1
data/.travis.yml CHANGED
@@ -11,7 +11,6 @@ before_install:
11
11
 
12
12
  matrix:
13
13
  include:
14
- - rvm: 2.4
15
14
  - rvm: 2.5
16
15
  - rvm: 2.6
17
16
  env: BENCHMARK=true
data/bake/utopia/test.rb CHANGED
@@ -6,5 +6,5 @@ def coverage
6
6
  end
7
7
 
8
8
  def test
9
- system("rspec", exception: true)
9
+ system("rspec") or abort
10
10
  end
@@ -22,6 +22,7 @@
22
22
 
23
23
  require 'securerandom'
24
24
  require 'yaml/store'
25
+ require 'console'
25
26
 
26
27
  module Utopia
27
28
  module Command
@@ -31,27 +32,41 @@ module Utopia
31
32
 
32
33
  options do
33
34
  option '-e/--environment-name <name>', "The environment file to modify.", default: 'environment'
35
+ option '-d/--defaults', "Initialize any recommended defaults."
34
36
  end
35
37
 
36
38
  many :variables, "A list of environment KEY=VALUE pairs to set."
37
39
 
40
+ def self.defaults(destination_root)
41
+ # Set some useful defaults for the environment.
42
+ self["--environment-name", "testing", "--defaults"].call(destination_root)
43
+ self["--environment-name", "development", "--defaults"].call(destination_root)
44
+ end
45
+
46
+ def environment_name
47
+ @options[:environment_name]
48
+ end
49
+
38
50
  # Setup `config/environment.yaml` according to specified options.
39
- def update_environment(root, name = @options[:environment_name])
51
+ def update_environment(root, name = self.environment_name)
40
52
  environment_path = File.join(root, "config", "#{name}.yaml")
41
53
  FileUtils.mkpath File.dirname(environment_path)
42
54
 
43
55
  store = YAML::Store.new(environment_path)
44
56
 
45
57
  store.transaction do
46
- yield store
58
+ yield store, name, environment_path
47
59
  end
48
60
  end
49
61
 
50
- def invoke(parent)
51
- destination_root = parent.root
52
-
53
- update_environment(destination_root) do |store|
54
- variables.each do |variable|
62
+ def call(root = parent.root)
63
+ update_environment(root) do |store, name, path|
64
+ if @options[:defaults]
65
+ # Set some useful defaults for the environment.
66
+ store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
67
+ end
68
+
69
+ variables&.each do |variable|
55
70
  key, value = variable.split('=', 2)
56
71
 
57
72
  if value
@@ -63,10 +78,13 @@ module Utopia
63
78
  end
64
79
  end
65
80
 
66
- store.roots.each do |key|
67
- value = store[key]
68
-
69
- puts "#{Rainbow(key).blue}: #{Rainbow(value.inspect).green}"
81
+ Console.logger.debug(self) do |buffer|
82
+ buffer.puts "Environment #{name} (#{path}):"
83
+ store.roots.each do |key|
84
+ value = store[key]
85
+
86
+ buffer.puts "#{key}=#{value.inspect}"
87
+ end
70
88
  end
71
89
  end
72
90
  end
@@ -99,11 +99,7 @@ module Utopia
99
99
  end
100
100
  end
101
101
 
102
- # Set some useful defaults for the environment.
103
- environment = Environment[]
104
- environment.update_environment(destination_root, :testing) do |store|
105
- store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
106
- end
102
+ Environment.defaults(destination_root)
107
103
 
108
104
  name = `git config user.name || whoami`.chomp
109
105
 
@@ -177,6 +173,8 @@ module Utopia
177
173
  File.open(destination_path, "w") { |file| file.write(buffer) }
178
174
  end
179
175
 
176
+ Environment.defaults(destination_root)
177
+
180
178
  begin
181
179
  Dir.chdir(destination_root) do
182
180
  # Stage any files that have been changed or removed:
data/lib/utopia/setup.rb CHANGED
@@ -113,11 +113,11 @@ module Utopia
113
113
  Utopia.logger.debug(self) {"Loading environment at path: #{path.inspect}"}
114
114
 
115
115
  # Load the YAML environment file:
116
- environment = YAML.load_file(path)
117
-
118
- # We update ENV but only when it's not already set to something:
119
- ENV.update(environment) do |name, old_value, new_value|
120
- old_value || new_value
116
+ if environment = YAML.load_file(path)
117
+ # We update ENV but only when it's not already set to something:
118
+ ENV.update(environment) do |name, old_value, new_value|
119
+ old_value || new_value
120
+ end
121
121
  end
122
122
 
123
123
  return true
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Utopia
24
- VERSION = "2.13.1"
24
+ VERSION = "2.13.2"
25
25
  end
@@ -1,6 +1,7 @@
1
1
  # Development specific:
2
2
  .rspec_status
3
3
  .tags*
4
+ .bundle
4
5
 
5
6
  # Temporary data should not be added to the repository:
6
7
  tmp/
@@ -28,16 +28,13 @@ require 'open3'
28
28
  require 'bundler'
29
29
 
30
30
  RSpec.describe "utopia command" do
31
+ let(:utopia_path) {File.expand_path("../..", __dir__)}
32
+ let(:pkg_path) {File.expand_path("pkg", utopia_path)}
31
33
  let(:utopia) {File.expand_path("../../bin/utopia", __dir__)}
32
- let(:gemspec) {Gem::Specification.load File.expand_path("../../utopia.gemspec", __dir__)}
33
- let(:package_path) {File.expand_path("../../pkg/#{gemspec.file_name}", __dir__)}
34
34
 
35
35
  before(:all) do
36
36
  # We need to build a package to test deployment:
37
37
  system("rake", "build") or abort("Could not build package for setup spec!")
38
-
39
- ENV['DEPLOY_USER'] = 'http'
40
- ENV['DEPLOY_GROUP'] = 'http'
41
38
  end
42
39
 
43
40
  around(:each) do |example|
@@ -45,9 +42,6 @@ RSpec.describe "utopia command" do
45
42
  # If we don't delete this, when running on travis, it will try submit the coverage report.
46
43
  ENV.delete('COVERAGE')
47
44
 
48
- # This allows the utopia command to load the correct library:
49
- ENV['RUBYLIB'] = File.expand_path("../../lib", __dir__)
50
-
51
45
  example.run
52
46
  end
53
47
  end
@@ -75,24 +69,21 @@ RSpec.describe "utopia command" do
75
69
  end
76
70
 
77
71
  def install_packages(dir)
78
- # We do a bit of a hack here to ensure the package is available:
79
- FileUtils.mkpath File.join(dir, "vendor/cache")
80
- FileUtils.cp package_path, File.join(dir, "vendor/cache")
72
+ system("bundle", "config", "--local", "local.utopia", utopia_path, chdir: dir)
73
+ system("bundle", "config", "--local", "cache_path", pkg_path, chdir: dir)
81
74
  end
82
75
 
83
76
  it "should generate sample site" do
84
77
  Dir.mktmpdir('test-site') do |dir|
85
78
  install_packages(dir)
86
79
 
87
- result = sh_status(utopia, "--in", dir, "site", "create")
88
- expect(result).to be == 0
80
+ system(utopia, "--in", dir, "site", "create")
89
81
 
90
82
  expect(Dir.entries(dir)).to include(".yarnrc", ".git", "Gemfile", "Gemfile.lock", "README.md", "bake.rb", "config.ru", "lib", "pages", "public", "spec")
91
83
 
92
- Dir.chdir(dir) do
93
- result = sh_status("bundle", "exec", "bake", "utopia:test")
94
- expect(result).to be == 0
95
- end
84
+ expect(
85
+ system("bundle", "exec", "bake", "utopia:test", chdir: dir)
86
+ ).to be true
96
87
  end
97
88
  end
98
89
 
data/utopia.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.required_ruby_version = '~> 2.2'
24
+ spec.required_ruby_version = '~> 2.5'
25
25
 
26
26
  spec.add_dependency 'trenni', '~> 3.0'
27
27
  spec.add_dependency 'mime-types', '~> 3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.1
4
+ version: 2.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -813,14 +813,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
813
813
  requirements:
814
814
  - - "~>"
815
815
  - !ruby/object:Gem::Version
816
- version: '2.2'
816
+ version: '2.5'
817
817
  required_rubygems_version: !ruby/object:Gem::Requirement
818
818
  requirements:
819
819
  - - ">="
820
820
  - !ruby/object:Gem::Version
821
821
  version: '0'
822
822
  requirements: []
823
- rubygems_version: 3.0.3
823
+ rubygems_version: 3.1.2
824
824
  signing_key:
825
825
  specification_version: 4
826
826
  summary: Utopia is a framework for building dynamic content-driven websites.