waggit 0.0.0

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzQ4MjkxMDJjOTE0M2IyMzZkYjQ5OWQ4NDVkNzQwYzVmODFjNWQxZg==
5
+ data.tar.gz: !binary |-
6
+ MDgzZmUyNjViY2JmOTRlMGNjZTlmODE1NTljOWQwMzQ2ZTNmN2UzZg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OWY3MjE0YTA1ZWM3ZWFhYTNhMTUyNGQ2ZGRiNjQ2M2RlZTgwYjRhNmI2NTZh
10
+ MTNlZTlkYTg1ZmY3YWMzM2QzZTEwODhkOTNmYTNiMTZkYzRiZDhkMmMxZjc4
11
+ MzQyMzcxMGVjMjJmNDE2NjIwYTc3ZDVmZmU1YjI0MjlmNDYzNjc=
12
+ data.tar.gz: !binary |-
13
+ OGIxYTFmMWZmNGVlNDI3NWNjNzdhYWQ1NmE5MWJkZmU2YTU4Y2I5OTY4OGQ2
14
+ OTVhZjIzMmM0NmM0MTZjMzAzOGE2NjkzYzMyMDc4Y2Y1N2E0NWRjNDJmNmFh
15
+ YmI0MGUyNGQ0M2VjM2Q0MzVmZGMxZDhkN2IyNWI3OTMzZDI1MWQ=
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'waggit.rb'
4
+
5
+ cmd = ARGV[0].downcase
6
+
7
+ for arg in ARGV
8
+ puts "arg: #{arg}"
9
+ end
10
+
11
+ options = []
12
+ if ARGV.length > 1
13
+ options = ARGV[1..(ARGV.length-1)]
14
+ end
15
+
16
+
17
+ case cmd
18
+ when "s", "sync"
19
+ Waggit.sync(options)
20
+ when "f", "forcepush", "fp"
21
+ Waggit.forcepush(options)
22
+ when "c", "clean"
23
+ Waggit.clean(options)
24
+ else
25
+ puts "Invalid command!"
26
+ end
@@ -0,0 +1,38 @@
1
+
2
+ # Handles all direct interaction with Bash
3
+ #
4
+ class Command
5
+
6
+ # Runs a command and returns the output
7
+ #
8
+ def self.run(command)
9
+ return `#{command}`
10
+ end
11
+
12
+
13
+ end
14
+
15
+
16
+ #require 'shellwords'
17
+
18
+ # Handles all direct interaction with Bash
19
+ #
20
+ #class Bash
21
+
22
+ # Execute a string as a bash command.
23
+ # Returns true for success,
24
+ # false for failure.
25
+ #
26
+ #def self.run(command)
27
+ #escaped_command = Shellwords.escape(command)
28
+ #return `#{command}`
29
+ #end
30
+
31
+ # Returns the exit code of the last command run.
32
+ # 0 for success,
33
+ # non-zero for failure and exit status.
34
+ #
35
+ #def self.exit_status()
36
+ # return $?.exitstatus
37
+ #end
38
+ #end
@@ -0,0 +1,30 @@
1
+ # Helper class for manipulating file system
2
+ #
3
+ class Files
4
+
5
+ # If we have scss files that we edit, their compiled css equivalents need
6
+ # to be deleted in order for wagon to recompile the scss
7
+ #
8
+ def self.clean_css()
9
+ Dir.glob('**/*.css').each do|css_file|
10
+ puts "Found css file: #{css_file}"
11
+ scss_file = css_file + ".scss"
12
+ puts "Searching for scss file: #{scss_file }"
13
+ if File.file?(scss_file )
14
+ puts "SCSS file found"
15
+ File.delete(css_file)
16
+ if css_file.include? '/'
17
+ "/" + css_file
18
+ end
19
+ if File.file?(css_file)
20
+ puts "ERROR: CSS file not deleted!"
21
+ else
22
+ puts "CSS file deleted"
23
+ end
24
+ else
25
+ puts "SCSS not file found"
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,107 @@
1
+ require 'command.rb'
2
+
3
+ class Git
4
+
5
+ @@wagon = "wagon-branch"
6
+ @@local = "local-branch"
7
+ # Add all local changes to be committed.
8
+ #
9
+ def self.add_all()
10
+ Command.run("git add -A .")
11
+ end
12
+
13
+ # Git commit, will prompt user for commit message
14
+ #
15
+ def self.commit_prompt()
16
+ puts "Enter a git commit message:"
17
+ message = $stdin.gets.chomp
18
+ self.commit(message)
19
+ end
20
+
21
+ # Git commit using provided message
22
+ def self.commit(message)
23
+ Command.run("git commit -m '#{message}'")
24
+ end
25
+
26
+ # Git push
27
+ #
28
+ def self.push()
29
+ Command.run("git push")
30
+ end
31
+
32
+ # Git pull
33
+ #
34
+ def self.pull()
35
+ Command.run("git pull")
36
+ end
37
+
38
+ def self.checkout(branch)
39
+ Command.run("git checkout #{branch}")
40
+ end
41
+
42
+ def self.checkout_master()
43
+ self.checkout("master")
44
+ end
45
+
46
+ def self.checkout_new_wagon()
47
+ self.checkout("-b #{@@wagon}")
48
+ end
49
+
50
+ def self.checkout_new_local()
51
+ self.checkout("-b #{@@local}")
52
+ end
53
+
54
+ def self.delete_branch(branch)
55
+ Command.run("git branch -D #{branch}")
56
+ end
57
+
58
+ def self.delete_wagon()
59
+ self.delete_branch(@@wagon)
60
+ end
61
+
62
+ def self.delete_local()
63
+ self.delete_branch(@@local)
64
+ end
65
+
66
+ def self.stash()
67
+ Command.run("git stash")
68
+ end
69
+
70
+ def self.stash_pop()
71
+ Command.run("git stash pop")
72
+ end
73
+
74
+ def self.merge(branch)
75
+ Command.run("git merge #{branch}")
76
+ end
77
+
78
+ def self.merge_wagon()
79
+ self.merge(@@wagon)
80
+ end
81
+
82
+ def self.merge_local()
83
+ self.merge(@@local)
84
+ end
85
+
86
+ def self.rebase(from, to)
87
+ Command.run("git rebase #{} #{}")
88
+ end
89
+
90
+ def self.rebase_wagon()
91
+ self.rebase("master", @@wagon)
92
+ end
93
+
94
+ def self.rebase_local()
95
+ self.rebase("master", @@local)
96
+ end
97
+
98
+ def self.has_changes?()
99
+ return !!Command.run("git ls-files -m")
100
+ end
101
+
102
+ def self.clean_whitespace_changes()
103
+ # git stash && git stash apply && git diff -w > ws.patch && git checkout . && git apply --ignore-space-change --ignore-whitespace ws.patch && rm ws.patch
104
+ puts "This does nothin yet"
105
+ end
106
+
107
+ end
@@ -0,0 +1,66 @@
1
+ require 'git.rb'
2
+ require 'wagon.rb'
3
+ require 'files.rb'
4
+
5
+ class Waggit
6
+
7
+ # Verifies that the current working directory is setup to work with both git and wagon
8
+ #
9
+ def self.test()
10
+ puts "test... doesn't work yet"
11
+ end
12
+
13
+ def self.clean(options)
14
+ Files.clean_css
15
+ end
16
+
17
+ def self.forcepush(options)
18
+ puts Git.add_all
19
+ puts Git.commit_prompt
20
+ puts Git.pull
21
+ puts Git.push
22
+ puts Wagon.push(options)
23
+ end
24
+
25
+ def self.sync(options)
26
+ puts Git.checkout_master
27
+ puts Git.delete_wagon
28
+ puts Git.delete_local
29
+ puts Git.stash
30
+
31
+ puts Git.checkout_new_wagon
32
+ puts Wagon.pull(options)
33
+ #TODO: Checkout: http://stackoverflow.com/questions/3515597/git-add-only-non-whitespace-changes
34
+ if Git.has_changes?
35
+ puts Git.add_all
36
+ puts Git.commit "merge wagon pull"
37
+ end
38
+
39
+ puts Git.checkout_master
40
+ puts Git.rebase_wagon
41
+ puts Git.checkout_master
42
+ puts Git.merge_wagon
43
+
44
+ puts Git.checkout_new_local
45
+ puts Git.stash_pop
46
+ puts Git.add_all
47
+ puts Git.commit_prompt
48
+ puts Git.rebase_local
49
+ puts Git.checkout_master
50
+ puts Git.merge_local
51
+ puts Git.delete_wagon
52
+ puts Git.delete_local
53
+
54
+ Files.clean_css
55
+ if Git.has_changes?
56
+ puts Git.add_all
57
+ puts Git.commit "cleaned css"
58
+ end
59
+
60
+ puts Git.pull
61
+ puts Git.push
62
+
63
+ puts Wagon.push(options)
64
+ end
65
+
66
+ end
@@ -0,0 +1,35 @@
1
+ require 'command.rb'
2
+
3
+ class Wagon
4
+
5
+ # Converts the provided options into the appropriate
6
+ # string to append to the wagon command
7
+ #
8
+ def self.process_options(options)
9
+ resource_opts = []
10
+ for option in options
11
+ case option
12
+ when "-p"
13
+ resource_opts.push("pages")
14
+ when "-a"
15
+ resource_opts.push("theme_assets")
16
+ end
17
+ end
18
+ unless resource_opts.empty?
19
+ return " -r #{resource_opts.join(' ')}"
20
+ else
21
+ return ''
22
+ end
23
+
24
+
25
+ end
26
+
27
+ def self.pull(options)
28
+ Command.run("bundle exec wagon pull production#{self.process_options(options)}")
29
+ end
30
+
31
+ def self.push(options)
32
+ Command.run("bundle exec wagon push production#{self.process_options(options)}")
33
+ end
34
+
35
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: waggit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mere Agency
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A way of integrating LocomotiveCMS/Wagon with git.
14
+ email: support@mereagency
15
+ executables:
16
+ - waggit
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/waggit
21
+ - lib/command.rb
22
+ - lib/files.rb
23
+ - lib/git.rb
24
+ - lib/waggit.rb
25
+ - lib/wagon.rb
26
+ homepage: http://rubygems.org/gems/waggit
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.2.2
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Wagon + Git = :)
50
+ test_files: []