sfb_scripts 0.1.7 → 0.1.8

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: e3d6009dbd443b1c3afcf0e214ecf245ceae4f49
4
- data.tar.gz: 9f67a07cc0cb014d5b50456536746fce0f3aa16e
3
+ metadata.gz: 3ad64628594616c16074cdf1dc8a025a2d788778
4
+ data.tar.gz: 48f17df97550e050c646e3c15cae131a14a07a1c
5
5
  SHA512:
6
- metadata.gz: a6df2ec87740289436c430aaf8f425f3d4ea4c31411ceadb9a43d50d583134c18b9b65ec80ec461c57c373e402b633f657c038d6fc3768774ceda2dcd29e90a1
7
- data.tar.gz: 809299b62276b552ba6ffaf310eea2cc91f1e2fc10575aa1f3874f33bdb4b3dbf578f5df1289eebf2dcab6c469fbd696a28e0083c25897eeed961c866ecaf8d0
6
+ metadata.gz: 66862b0679ce60cd59bd4075627014fe2cc9c13228ce18c6e6d956687d757a7c067353287553917d5a688e39da8e133a82e959ffc85fd43ac96efae16b190377
7
+ data.tar.gz: 0df73ca2bf1cb38a5444ff17ce152504d628bc2c3ee4466af52586f65b46064428120bac50e9a53bee22446bec0f745762512bc2b8d3beb116d11a6e8c652e6d
data/bin/app_up CHANGED
@@ -9,12 +9,12 @@ class CLI < Thor
9
9
  # REBASE
10
10
  #
11
11
 
12
- desc "app_up", "Rebase your commits onto master. Bundle installs and migrates as needed. Will terminate if conflicts are found."
12
+ desc "up", "Rebase your commits onto master. Bundle installs and migrates as needed. Will terminate if conflicts are found."
13
13
  option :loud, :type => :boolean, :desc => 'Pipe output to terminal or not (output is always piped to /tmp/app_up.log)'
14
- option :no_git, aliases: :all, :type => :boolean, :desc => "Don't update the repo, just bundle and migrate everywhere."
15
- option :no_engines, type: :boolean, desc: "Don't migrate engines"
14
+ option :no_git, aliases: ['--no-pull', '--no-rebase', '--all'], :type => :boolean, :desc => "Don't update the repo, just bundle and migrate everywhere."
15
+ option :engines, type: :boolean, default: false, desc: "Perform actions in engines as well"
16
16
 
17
- def app_up
17
+ def up
18
18
  if options[:no_git]
19
19
  Upper.no_git(options)
20
20
  else
@@ -32,7 +32,7 @@ class CLI < Thor
32
32
  Upper.pre_push_hook(git_command, options)
33
33
  end
34
34
 
35
- default_task :app_up
35
+ default_task :up
36
36
  end
37
37
 
38
38
  CLI.start(ARGV)
@@ -1,24 +1,25 @@
1
1
  class BundleManager
2
- attr_accessor :shell, :repo, :queue
2
+ attr_accessor :shell, :repo, :queue, :folder_guard
3
3
 
4
- def initialize(repo: raise, shell: raise)
4
+ def initialize(repo: raise, shell: raise, queue: raise, folder_guard: folder_guard)
5
5
  @shell = shell
6
6
  @repo = repo
7
- @queue = WorkQueue.new(2, nil)
7
+ @queue = queue
8
+ @folder_guard = folder_guard
8
9
  end
9
10
 
10
11
  def bundle_where_necessary
11
12
  shell.notify "\nBundling:"
12
- find("Gemfile.lock").each do |gemfile_lock|
13
- if repo.changed?(gemfile_lock)
14
- queue.enqueue_b do
15
- bundle(directory_of(gemfile_lock))
16
- end
13
+ directories_to_bundle.each do |dir|
14
+ queue.enqueue_b do
15
+ bundle(dir)
17
16
  end
18
17
  end
19
18
  queue.join
20
19
  end
21
20
 
21
+ private
22
+
22
23
  def bundle(gemfile_directory)
23
24
  begin
24
25
  shell.run "bundle install --local", dir: gemfile_directory
@@ -28,6 +29,25 @@ class BundleManager
28
29
  end
29
30
  end
30
31
 
32
+ def directories_to_bundle
33
+ changed_gemfile_locks.map do |gemfile_lock|
34
+ directory_of(gemfile_lock)
35
+ end
36
+ .select do |dir|
37
+ folder_guard.allowed?(dir)
38
+ end
39
+ end
40
+
41
+ def changed_gemfile_locks
42
+ all_gemfile_locks.select do |gemfile_lock|
43
+ repo.changed?(gemfile_lock)
44
+ end
45
+ end
46
+
47
+ def all_gemfile_locks
48
+ find("Gemfile.lock")
49
+ end
50
+
31
51
  def find(file_name)
32
52
  Dir.glob("**/#{file_name}")
33
53
  end
@@ -0,0 +1,11 @@
1
+ class FolderGuard
2
+
3
+ attr_reader :denied_matches
4
+ def initialize(denied_matches)
5
+ @denied_matches = denied_matches
6
+ end
7
+
8
+ def allowed?(folder)
9
+ denied_matches.select { |d| folder.match(d) }.empty?
10
+ end
11
+ end
@@ -1,14 +1,13 @@
1
1
  class Migrator
2
- attr_accessor :shell, :repo, :queue
2
+ attr_accessor :shell, :repo, :queue, :folder_guard
3
3
 
4
4
  # hack: move engines flag into
5
5
  # another object that decides
6
- def initialize(repo: raise, shell: raise, migrate_engines: raise)
6
+ def initialize(repo: raise, shell: raise, queue: raise, folder_guard: raise)
7
7
  @shell = shell
8
8
  @repo = repo
9
- @migrate_engines = migrate_engines
10
- # should be passed in
11
- @queue = WorkQueue.new(8, nil)
9
+ @queue = queue
10
+ @folder_guard = folder_guard
12
11
  end
13
12
 
14
13
  def migrate_where_necessary
@@ -23,7 +22,7 @@ class Migrator
23
22
 
24
23
  def directories_to_migrate
25
24
  migrate_dirs = repo.files_changed.select {|f| f.match("/migrate/") }.map {|f| File.dirname(f) }.map {|dir| dir.gsub(/\/db\/migrate$/, '')}.uniq
26
- migrate_dirs.select {|d| in_rack_application?(d) };
25
+ migrate_dirs.select {|d| folder_guard.allowed?(d) };
27
26
  end
28
27
 
29
28
  private
@@ -38,14 +37,7 @@ class Migrator
38
37
  end
39
38
 
40
39
  def in_rack_application?(migrate_dir)
41
- if migrate_engines?
42
- true
43
- else
44
- ! migrate_dir.match(/engines/)
45
- end
40
+ folder_guard.allowed?(migrate_dir)
46
41
  end
47
42
 
48
- def migrate_engines?
49
- @migrate_engines
50
- end
51
43
  end
@@ -16,10 +16,14 @@ require_relative 'test_running/test_collection'
16
16
  require_relative 'test_running/test_file_runner'
17
17
  require_relative 'test_running/test_method_runner'
18
18
  require_relative 'test_running/test_runner'
19
+ require_relative 'folder_guard'
19
20
 
20
21
 
21
22
  class NeedsManager
22
23
 
24
+ BUNDLER_MAX_THREAD_COUNT = 2
25
+ MIGRATOR_MAX_THREAD_COUNT = 8
26
+
23
27
  def self.configure(task, needs, options)
24
28
  new(task, needs, options).configure
25
29
  end
@@ -36,6 +40,8 @@ class NeedsManager
36
40
  set_working_directory
37
41
 
38
42
  create_shell
43
+ create_folder_guard
44
+
39
45
  create_repo if needs.include? :repo
40
46
  create_bundler if needs.include? :bundler
41
47
  create_migrator if needs.include? :migrator
@@ -61,6 +67,12 @@ class NeedsManager
61
67
  end
62
68
  end
63
69
 
70
+ def create_folder_guard
71
+ denied_folders = []
72
+ denied_folders << 'engines' if ! options[:engines]
73
+ env[:folder_guard] = FolderGuard.new(denied_folders)
74
+ end
75
+
64
76
  def create_repo
65
77
  env[:repo] = repo_class.new(shell: env[:shell])
66
78
  end
@@ -76,11 +88,13 @@ class NeedsManager
76
88
  end
77
89
 
78
90
  def create_bundler
79
- env[:bundler] = BundleManager.new(shell: env[:shell], repo: env[:repo])
91
+ queue = WorkQueue.new(BUNDLER_MAX_THREAD_COUNT, nil)
92
+ env[:bundler] = BundleManager.new(shell: env[:shell], repo: env[:repo], queue: queue, folder_guard: env[:folder_guard])
80
93
  end
81
94
 
82
95
  def create_migrator
83
- env[:migrator] = Migrator.new(shell: env[:shell], repo: env[:repo], migrate_engines: ! options[:no_engines])
96
+ queue = WorkQueue.new(MIGRATOR_MAX_THREAD_COUNT, nil)
97
+ env[:migrator] = Migrator.new(shell: env[:shell], repo: env[:repo], queue: queue, folder_guard: env[:folder_guard])
84
98
  end
85
99
 
86
100
  def create_test_runner
@@ -53,7 +53,7 @@ class Upper
53
53
  end
54
54
 
55
55
  def no_git
56
- env[:shell].notify "\nBundling and migrating all apps/engines:"
56
+ env[:shell].notify "\nBundling and migrating without checking diffs:"
57
57
  bundler.bundle_where_necessary
58
58
  migrator.migrate_where_necessary
59
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfb_scripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom
@@ -14,40 +14,40 @@ dependencies:
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.19'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '1.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.19'
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '1.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: work_queue
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 2.5.3
40
- - - <
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '3.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.5.3
50
- - - <
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3.0'
53
53
  description: Easily update your rails app and run tests from command line
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - lib/sfb_scripts/bundler/bundle_manager.rb
63
+ - lib/sfb_scripts/folder_guard.rb
63
64
  - lib/sfb_scripts/hook_manager.rb
64
65
  - lib/sfb_scripts/hooks/pre_push_hook.rb
65
66
  - lib/sfb_scripts/migrations/migrator.rb
@@ -90,12 +91,12 @@ require_paths:
90
91
  - lib
91
92
  required_ruby_version: !ruby/object:Gem::Requirement
92
93
  requirements:
93
- - - '>='
94
+ - - ">="
94
95
  - !ruby/object:Gem::Version
95
96
  version: '0'
96
97
  required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  requirements:
98
- - - '>='
99
+ - - ">="
99
100
  - !ruby/object:Gem::Version
100
101
  version: '0'
101
102
  requirements: []
@@ -105,4 +106,3 @@ signing_key:
105
106
  specification_version: 4
106
107
  summary: Easily update your rails app and run tests from command line
107
108
  test_files: []
108
- has_rdoc: