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: 987dc444541f73d96d4ef8639822910e52cfb47c
4
- data.tar.gz: 7ab798c262fbcf37680b5333d8bb5c856a9a933e
3
+ metadata.gz: 2ecc781b9a3506569610b1a024046d3a4654a162
4
+ data.tar.gz: 76e8f79b2e3f86f8654b487b0ef0a0c7d9c4a2e3
5
5
  SHA512:
6
- metadata.gz: 4df59039d6e5728ce6c92165b682bb3894ea6e314612e05c91bd1f23b8aaf98d6f19953542874ddcac6d71b47067dc5c5829447cba278348ef5ce2561a47cc59
7
- data.tar.gz: 98ee05f7b84c9f894c27ac52f58fa853b76c1253d4e6e2b12ef2fc95750b3876f5ac40957e6f2825d568f8df42547b81bb0349dfcb61dc8f99b6480faf724cab
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: ' '.freeze, newline: "\n".freeze, &block)
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
- [' do'].any? { |end_with| stripped.split('#').first.to_s.end_with?(end_with) } ||
242
- ['class ', 'module ', 'def ', 'if '].any? { |start_with| stripped.start_with?(start_with) }
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'.freeze) && !stripped.include?('do ')
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
- EffectiveDeveloper.setup do |config|
2
- # Tracks changes to the effective_resource do .. end block
3
- # And automatically writes database migration changes
4
- config.live = false
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
- ActiveSupport.on_load :effective_resource do
14
- Effective::LiveGenerator.new(self).generate! if EffectiveDeveloper.live
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
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.4.2'.freeze
2
+ VERSION = '0.4.3'.freeze
3
3
  end
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.2
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-05 00:00:00.000000000 Z
11
+ date: 2018-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails