effective_developer 0.4.2 → 0.4.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ecc781b9a3506569610b1a024046d3a4654a162
|
4
|
+
data.tar.gz: 76e8f79b2e3f86f8654b487b0ef0a0c7d9c4a2e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb4c61a015920fb4bbd1d32e3f173995c6770309c83364c4134c45e2c16791959ee678f29ee6f3588924e86a5936dafc31a19ec944a45aa05662027f699493b
|
7
|
+
data.tar.gz: 31249bfd2486d576955cb4f4df7a3b696568440b39d63a69df13e72da91930bba2c4c79c62e9252f93f685708b9fbaf22ca798eb81050bee4952b16001deaf7a
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Effective::CodeWriter.new('Gemfile') do |w|
|
2
4
|
# @use_effective_resources = w.find { |line| line.include?('effective_resources') }.present?
|
3
5
|
# end
|
@@ -9,7 +11,7 @@ module Effective
|
|
9
11
|
attr_reader :lines
|
10
12
|
attr_reader :filename, :indent, :newline
|
11
13
|
|
12
|
-
def initialize(filename, indent: ' '
|
14
|
+
def initialize(filename, indent: ' ', newline: "\n", &block)
|
13
15
|
@filename = filename
|
14
16
|
@indent = indent
|
15
17
|
@newline = newline
|
@@ -238,13 +240,13 @@ module Effective
|
|
238
240
|
def open?(content)
|
239
241
|
stripped = ss(content)
|
240
242
|
|
241
|
-
['
|
242
|
-
|
243
|
+
['class ', 'module ', 'def ', 'if '].any? { |start_with| stripped.start_with?(start_with) } ||
|
244
|
+
(stripped.include?(' do') && !stripped.end_with?('end'))
|
243
245
|
end
|
244
246
|
|
245
247
|
def close?(content)
|
246
248
|
stripped = ss(content, array_method: :last)
|
247
|
-
stripped.end_with?('end'
|
249
|
+
stripped.end_with?('end') && !stripped.include?('do ')
|
248
250
|
end
|
249
251
|
|
250
252
|
def whitespace?(content)
|
@@ -266,7 +268,7 @@ module Effective
|
|
266
268
|
when Integer then lines[value]
|
267
269
|
when Array then value.send(array_method)
|
268
270
|
else value
|
269
|
-
end.strip
|
271
|
+
end.to_s.split('#').first.to_s.strip
|
270
272
|
end
|
271
273
|
end
|
272
274
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
if Rails.env.development?
|
2
|
+
EffectiveDeveloper.setup do |config|
|
3
|
+
# Tracks changes to the effective_resource do .. end block
|
4
|
+
# And automatically writes database migration changes
|
5
|
+
config.live = false
|
6
|
+
end
|
5
7
|
end
|
@@ -9,9 +9,12 @@ module EffectiveDeveloper
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Whenever the effective_resource do block is evaluated, check for changes
|
12
|
+
# https://stackoverflow.com/questions/13506690/how-to-determine-if-rails-is-running-from-cli-console-or-as-server
|
12
13
|
initializer 'effective_developer.effective_resources' do |app|
|
13
|
-
|
14
|
-
|
14
|
+
if defined?(Rails::Server) && Rails.env.development? && EffectiveDeveloper.live
|
15
|
+
ActiveSupport.on_load :effective_resource do
|
16
|
+
Effective::LiveGenerator.new(self).generate!
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_developer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|