devflow 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 75c44216cec882533a73aa64b7a095038c67472973a497849c8a7466944a43e6
4
+ data.tar.gz: 5a279601376a3fc0718a7105058e41753b3e417227ff6105cac9bd37f1d9997b
5
+ SHA512:
6
+ metadata.gz: ae4a2247ecf38d5f7d23aec8b33238940473f94faa89c6deb25117f86380fbf9a3da9e0f524450cebf2906cc7bab7a548eee5b41355fa62fe30d56cdfccf17c1
7
+ data.tar.gz: cdb0aa711ebc8dec6f7bfbb9af32a4f3746784a97c407af7d080456d3abbe54c3331693c1e24012e768538624b0928cb5537e4cbe5fa5a4f0308c296aa599b0f
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in valid_email2.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,18 @@
1
+ GEM
2
+ specs:
3
+ httparty (0.16.3)
4
+ mime-types (~> 3.0)
5
+ multi_xml (>= 0.5.2)
6
+ mime-types (3.2.2)
7
+ mime-types-data (~> 3.2015)
8
+ mime-types-data (3.2018.0812)
9
+ multi_xml (0.6.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ httparty (~> 0.16)
16
+
17
+ BUNDLED WITH
18
+ 1.17.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Micke Lisinge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/bin/df ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "devflow"
4
+
5
+ DevFlow::TargetProcess.check_config!
6
+
7
+ assignments = DevFlow::TargetProcess.assignments
8
+
9
+ if assignments.count == 1
10
+ assignment = assignments.first
11
+ else
12
+ puts "Multiple tasks in progress. Which one are you working on?"
13
+ assignments.each do |a|
14
+ puts "#{a[:id]}: #{a[:name]}"
15
+ end
16
+ selection = gets.chomp.to_i
17
+
18
+ assignment = assignments.find { |a| a[:id] == selection }
19
+
20
+ unless assignment
21
+ puts "No such task"
22
+ exit 1
23
+ end
24
+ end
25
+
26
+ branch = "#{assignment[:id]}-#{DevFlow.branchify(assignment[:name])}"
27
+
28
+ `git checkout -b #{branch}`
data/devflow.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "devflow/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "devflow"
7
+ spec.version = DevFlow::VERSION
8
+ spec.authors = ["Micke Lisinge"]
9
+ spec.email = ["hi@micke.me"]
10
+ spec.description = %q{CLI for creating branches in a TP workflow}
11
+ spec.summary = %q{CLI for creating branches in a TP workflow}
12
+ spec.homepage = "https://github.com/micke/devflow"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = ">= 1.9.3"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_runtime_dependency "httparty", "~> 0.16"
24
+ end
25
+
@@ -0,0 +1,20 @@
1
+ module DevFlow
2
+ class TargetProcess
3
+ class RequestError < StandardError
4
+ attr_reader :response, :request
5
+
6
+ def initialize(response)
7
+ @response = response
8
+ @request = response.request
9
+
10
+ super("Error from TP: #{response.code} - #{response.body}")
11
+ end
12
+ end
13
+
14
+ class ConfigError < StandardError
15
+ def initialize(key)
16
+ super("Missing environment variable: #{key}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ require "httparty"
2
+ require "devflow/target_process/error"
3
+
4
+ module DevFlow
5
+ class TargetProcess
6
+ include HTTParty
7
+
8
+ BASE_URI = ENV["TP_BASE_URL"]
9
+ USER_ID = ENV["TP_USER_ID"]
10
+ ACCESS_TOKEN = ENV["TP_ACCESS_TOKEN"]
11
+ ENTITY_PATTERN = /#{BASE_URI}\/entity\/(\d+)/.freeze
12
+
13
+ base_uri BASE_URI
14
+ headers "Content-Type" => "application/json"
15
+ format :json
16
+ default_params(
17
+ access_token: ACCESS_TOKEN,
18
+ format: "json"
19
+ )
20
+
21
+ def self.check_config!
22
+ raise ConfigError, "TP_ACCESS_TOKEN" unless ACCESS_TOKEN
23
+ raise ConfigError, "TP_BASE_URL" unless BASE_URI
24
+ raise ConfigError, "TP_ACCESS_TOKEN" unless ACCESS_TOKEN
25
+ end
26
+
27
+ def self.assignments
28
+ where = "(GeneralUser.Id eq #{USER_ID})and" \
29
+ "(Assignable.EntityState.Name eq 'In Progress')"
30
+ response = request(
31
+ :get,
32
+ "/api/v1/assignments",
33
+ query: { where: where, include: "[Assignable[Id,Name]]" }
34
+ )
35
+
36
+ response["Items"].map do |i|
37
+ { id: i["Assignable"]["Id"], name: i["Assignable"]["Name"] }
38
+ end
39
+ end
40
+
41
+ def self.request(method, *args)
42
+ response = send(method, *args)
43
+
44
+ raise TargetProcess::RequestError, response unless response.code == 200
45
+
46
+ response
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module DevFlow
2
+ VERSION = "0.0.1"
3
+ end
data/lib/devflow.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "devflow/target_process"
2
+
3
+ module DevFlow
4
+ def self.branchify(string)
5
+ string.tr(' ', '-').gsub(/[^\w-]/, '').downcase
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devflow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Micke Lisinge
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.16'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.16'
41
+ description: CLI for creating branches in a TP workflow
42
+ email:
43
+ - hi@micke.me
44
+ executables:
45
+ - df
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - bin/df
54
+ - devflow.gemspec
55
+ - lib/devflow.rb
56
+ - lib/devflow/target_process.rb
57
+ - lib/devflow/target_process/error.rb
58
+ - lib/devflow/version.rb
59
+ homepage: https://github.com/micke/devflow
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.9.3
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.7.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: CLI for creating branches in a TP workflow
83
+ test_files: []