style_pusher 0.0.2

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,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7bc41acdc9eeecbd2cc4705364bb393efbe4d84bbb4af10d16c923848a987865
4
+ data.tar.gz: 0bbecca6ea6832cf53433f2f3c7831f4e92e4d7b74af10a57044f2d47e666a62
5
+ SHA512:
6
+ metadata.gz: 6e5e8f47baa5070a5dfeb79afbb45dfa1ba8ab06449b7ec4ec0bbcc9e2f0629898b6b975bf24999cb9026e815ea33729f5dbb91eef8130f18f8210598dfc505d
7
+ data.tar.gz: 9ebae083245d8311ebf349d273c3c9eb2136bc7aac42ecc027f9642e20acad350a18c567f13597c6a4bac3a038aa8e6fb61933c02c85912ccbf4dd660df94281
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ Gemfile.lock
5
+ lib/bundler/man
6
+ pkg
7
+ rdoc
8
+ tmp
9
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+ gem "pry"
3
+ gemspec
@@ -0,0 +1,39 @@
1
+ ### Installation
2
+
3
+ To build, test, and install the gem:
4
+
5
+ ```
6
+ bundle install
7
+ rake spec install
8
+ ```
9
+
10
+ ### Purpose:
11
+
12
+ This gem was created to enable designers push a complete stylesheet to project's repo, as often as they need to.
13
+
14
+ The complete stylesheet is a mix of scss variebles and mixins. This stylesheet needs to be broken down to variables.scss and mixin.scss and will be pushed to the project repo. Engineers will be notified by designers that there's a new branch / or they see the new branch and can create pull request to approve and merge to master.
15
+
16
+ ### How to use this gem:
17
+
18
+ After installing the gem `rake install` use the following command:
19
+ `$: "location of the stylesheet" "git repo ssh url" "Name for the branch" "Write a short description" "Location of the stylesheets in the project - where should be uploaded to" `
20
+
21
+ For example:
22
+
23
+ `$: ~/Desktop/devmynd_master_style.scss git@github.com:devmynd/scssketch.git update_colors \"update background color from white to silver\" app/assets/stylesheets`
24
+
25
+ ### Behind the seen:
26
+
27
+ The gem will
28
+ - pull down the project or cloning it using the git url user has provided.
29
+ - then takes the complete stylesheet and breaks it down to variables.scss and mixins.scss.
30
+ - uploads the new stylesheets to the location that the user has specified
31
+ - creates a branch using the name user has provided
32
+ - adds and commits the changes with the message that the user has provided
33
+ - pushes the changes to origin
34
+ - deletes the local branch
35
+
36
+
37
+ This will install an executable called `style_pusher` that you can use to run the program.
38
+
39
+ _This gem was developed using Ruby 2.5.1 under `rbenv`. YMMV._
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ## Example
4
+ ## main program to run
5
+ $0 = "style_uploader"
6
+
7
+ begin
8
+ require "StylePusher"
9
+ rescue LoadError
10
+ require "rubygems"
11
+ require "StylePusher"
12
+ end
13
+
14
+ if (ARGV.length != 5)
15
+ puts "USAGE: If here are spaces in your branch name or comment use quotes"
16
+ puts "... Please upload your stylesheet"
17
+ puts "... Git repo"
18
+ puts "... Name for the branch"
19
+ puts "... Write a short description"
20
+ puts "... Location of master css file"
21
+ puts "For example:"
22
+ puts "~/Desktop/devmynd_master_style.scss git@github.com:devmynd/scssketch.git update_colors \"update background color from white to silver\" app/assets/stylesheets"
23
+ exit(1)
24
+ end
25
+
26
+ file_extension = File.extname(ARGV[0])
27
+ if(file_extension.to_s.empty? || !file_extension.match(/\.s?css/))
28
+ puts "We can only accept stylesheets at this point. File type must be \"css\" or \"scss\""
29
+ exit(1)
30
+ end
31
+
32
+ git_url_regex = /git@github\.com:([\w\.@\:\/\-~]+)(\.git)(\/)?/
33
+ if(!ARGV[1].match(git_url_regex))
34
+ puts "Please ener a valid \"ssh\" git repo url"
35
+ exit(1)
36
+ end
37
+
38
+ if(ARGV[2].length > 25)
39
+ puts "Please choose a shorter branch name"
40
+ end
41
+
42
+ if(ARGV[3].length > 200)
43
+ puts "Please make the message short and sweet!"
44
+ end
45
+
46
+ puts StylePusher.push(stylesheet: File.open(ARGV[0], "rb"),
47
+ git_url: ARGV[1],
48
+ git_branch_name: ARGV[2],
49
+ git_commit_message: ARGV[3],
50
+ stylesheets_location:ARGV[4])
@@ -0,0 +1,37 @@
1
+ require "git"
2
+ require "style_pusher/utils/git_driver"
3
+
4
+ module StylePusher
5
+ def self.push(stylesheet:,
6
+ git_url:,
7
+ git_branch_name:,
8
+ git_commit_message:,
9
+ stylesheets_location:)
10
+
11
+ parent_directory = File.expand_path("..", Dir.pwd)
12
+ branch_name = git_branch_name.gsub(" ", "_").downcase
13
+ project_name = project_name(git_url: git_url)
14
+ local_repo = File.join(parent_directory, project_name)
15
+ upload_location = "#{local_repo}/#{stylesheets_location}"
16
+
17
+ stylesheets = [
18
+ {
19
+ name: "blah.scss",
20
+ content: stylesheet
21
+ }
22
+ ]
23
+
24
+ GitDriver.push(url: git_url,
25
+ local_repo: local_repo,
26
+ branch_name: branch_name,
27
+ project_name: project_name,
28
+ stylesheets: stylesheets, #later this should be an array
29
+ upload_location: upload_location,
30
+ commit_message: git_commit_message)
31
+ end
32
+
33
+ private
34
+ def self.project_name(git_url:)
35
+ @repo_name ||= git_url.split("git@github.com:").last.split(".git").first.split("/").last
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ require "pry"
2
+ class GitDriver
3
+ def self.push(url:, local_repo:, branch_name:, project_name:, stylesheets:, upload_location:, commit_message:)
4
+
5
+ #Configure git
6
+ git = create_or_pull(local_path: local_repo, url: url, project_name: project_name)
7
+
8
+ #Crete and checkout a branch
9
+ git.branch(branch_name).checkout
10
+
11
+ #Commit changes
12
+ upload_stylesheets(stylesheets, upload_location)
13
+ git.add
14
+ git.commit(commit_message)
15
+
16
+ #Push the branch
17
+ git.push("origin", branch_name, f: true)
18
+
19
+ #Remove the local branch
20
+ git.checkout("master")
21
+ git.branch(branch_name).delete
22
+ end
23
+
24
+ private
25
+ def self.create_or_pull(local_path:, url:, project_name:)
26
+ begin
27
+ git = Git.open(local_path)
28
+ git.pull
29
+ return git
30
+ rescue
31
+ parent_dir = File.expand_path("..", local_path)
32
+ return Git.clone(url, project_name, path: parent_dir)
33
+ end
34
+ end
35
+
36
+ def self.upload_stylesheets(stylesheets, location)
37
+ stylesheets.each do |stylesheet|
38
+ # left off here
39
+ File.write("#{location}/#{stylesheet[:name]}", stylesheet[:content])
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module StylePusher
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "style_pusher/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "style_pusher"
8
+ gem.version = StylePusher::VERSION
9
+
10
+ gem.authors = ["Sarah Aslanifar"]
11
+ gem.email = ["sarah.aslanifar@devmynd.com"]
12
+ gem.description = "Executable gem file"
13
+ gem.summary = gem.description
14
+ gem.homepage = "http://devmynd.com"
15
+ gem.license = "Apache 2.0"
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+
22
+ gem.add_development_dependency("rake", "10.0.4")
23
+ gem.add_development_dependency("rspec", "2.14.1")
24
+ gem.add_dependency("git", "1.5.0")
25
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: style_pusher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Sarah Aslanifar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 10.0.4
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 10.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.14.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.14.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: git
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.5.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.0
55
+ description: Executable gem file
56
+ email:
57
+ - sarah.aslanifar@devmynd.com
58
+ executables:
59
+ - style_pusher
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/style_pusher
68
+ - lib/style_pusher.rb
69
+ - lib/style_pusher/utils/git_driver.rb
70
+ - lib/style_pusher/version.rb
71
+ - style_pusher.gemspec
72
+ homepage: http://devmynd.com
73
+ licenses:
74
+ - Apache 2.0
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.7.6
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Executable gem file
96
+ test_files: []