Class: Upper

Inherits:
Object
  • Object
show all
Defined in:
lib/sfb_scripts/upper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Upper

Returns a new instance of Upper.



55
56
57
58
59
60
# File 'lib/sfb_scripts/upper.rb', line 55

def initialize(env)
  @env = env
  @repo = env[:repo]
  @bundler = env[:bundler]
  @migrator = env[:migrator]
end

Instance Attribute Details

#bundlerObject (readonly)

Returns the value of attribute bundler.



53
54
55
# File 'lib/sfb_scripts/upper.rb', line 53

def bundler
  @bundler
end

#envObject (readonly)

Returns the value of attribute env.



53
54
55
# File 'lib/sfb_scripts/upper.rb', line 53

def env
  @env
end

#migratorObject (readonly)

Returns the value of attribute migrator.



53
54
55
# File 'lib/sfb_scripts/upper.rb', line 53

def migrator
  @migrator
end

#repoObject (readonly)

Returns the value of attribute repo.



53
54
55
# File 'lib/sfb_scripts/upper.rb', line 53

def repo
  @repo
end

Class Method Details

.arbitrary_action!(git_command, options) ⇒ Object



13
14
15
16
# File 'lib/sfb_scripts/upper.rb', line 13

def self.arbitrary_action!(git_command, options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :active))
  new(env).arbitrary_action!(git_command)
end

.finish_rebase(options) ⇒ Object



38
39
40
41
# File 'lib/sfb_scripts/upper.rb', line 38

def self.finish_rebase(options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :active))
  new(env).finish_rebase
end

.install_hooks(options) ⇒ Object



43
44
45
46
# File 'lib/sfb_scripts/upper.rb', line 43

def self.install_hooks(options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :lazy))
  new(env).install_hooks
end

.needsObject



5
6
7
# File 'lib/sfb_scripts/upper.rb', line 5

def self.needs
  [:shell, :repo, :bundler, :migrator]
end

.no_git(options) ⇒ Object



33
34
35
36
# File 'lib/sfb_scripts/upper.rb', line 33

def self.no_git(options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :lazy))
  new(env).no_git
end

.pre_push_hook(git_command, options) ⇒ Object



48
49
50
51
# File 'lib/sfb_scripts/upper.rb', line 48

def self.pre_push_hook(git_command, options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :active))
  new(env).pre_push_hook(git_command)
end

.rebase_on_branch!(options) ⇒ Object



18
19
20
21
# File 'lib/sfb_scripts/upper.rb', line 18

def self.rebase_on_branch!(options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :active))
  new(env).arbitrary_action!("pull --rebase origin #{env[:repo].current_branch}")
end

.rebase_on_master!(options) ⇒ Object



23
24
25
26
# File 'lib/sfb_scripts/upper.rb', line 23

def self.rebase_on_master!(options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :active))
  new(env).arbitrary_action!("pull --rebase origin master")
end

.up_master!(options) ⇒ Object



28
29
30
31
# File 'lib/sfb_scripts/upper.rb', line 28

def self.up_master!(options)
  env = NeedsManager.configure(:up, needs, with_defaults(options).merge(repo_type: :active))
  new(env).up_master!
end

.with_defaults(options) ⇒ Object



9
10
11
# File 'lib/sfb_scripts/upper.rb', line 9

def self.with_defaults(options)
  {loud: true}.merge(options)
end

Instance Method Details

#arbitrary_action!(git_command) ⇒ Object



68
69
70
71
72
# File 'lib/sfb_scripts/upper.rb', line 68

def arbitrary_action!(git_command)
  repo.alter!(git_command)
  bundler.bundle_where_necessary
  migrator.migrate_where_necessary
end

#finish_rebaseObject



80
81
82
83
84
# File 'lib/sfb_scripts/upper.rb', line 80

def finish_rebase
  repo.compare_with_reflog
  bundler.bundle_where_necessary
  migrator.migrate_where_necessary
end

#install_hooksObject



86
87
88
# File 'lib/sfb_scripts/upper.rb', line 86

def install_hooks
  HookManager.install!(env)
end

#no_gitObject



74
75
76
77
78
# File 'lib/sfb_scripts/upper.rb', line 74

def no_git
  env[:shell].notify "\nBundling and migrating without checking diffs:"
  bundler.bundle_where_necessary
  migrator.migrate_where_necessary
end

#pre_push_hook(git_command) ⇒ Object



90
91
92
# File 'lib/sfb_scripts/upper.rb', line 90

def pre_push_hook(git_command)
  PrePushHook.check(git_command, env)
end

#up_master!Object



62
63
64
65
66
# File 'lib/sfb_scripts/upper.rb', line 62

def up_master!
  repo.up_master!
  bundler.bundle_where_necessary
  migrator.migrate_where_necessary
end