sly 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sly/branch.rb +23 -0
- data/lib/sly/gui.rb +2 -2
- data/lib/sly/installer.rb +1 -1
- data/lib/sly/item.rb +25 -2
- data/lib/sly/version.rb +1 -1
- data/lib/sly.rb +1 -0
- metadata +5 -4
data/lib/sly/branch.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sly'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
class Sly::Branch
|
7
|
+
|
8
|
+
def self.for(item_number)
|
9
|
+
item = Sly::Item.with_number(item_number)
|
10
|
+
raise "No Sprint.ly item found with that number" if item.nil?
|
11
|
+
current_branches = git :branch
|
12
|
+
prefix = "-b" unless current_branches =~ /-#{item.number}\n/
|
13
|
+
git :checkout, [prefix, item.git_slug].join(' ')
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.git(command, arg = "")
|
17
|
+
command = "git #{command.to_s} #{arg.to_s}"
|
18
|
+
output = %x[#{command} 2>&1]
|
19
|
+
raise "Error running #{command}" unless $?.success?
|
20
|
+
output
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/sly/gui.rb
CHANGED
@@ -20,8 +20,8 @@ class Sly::GUI
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def self.display_items(title, items)
|
23
|
-
|
23
|
+
$stdout.print " ---------------- #{title} ---------------- \n"
|
24
24
|
items.map(&:print)
|
25
|
-
|
25
|
+
$stdout.print "\n"
|
26
26
|
end
|
27
27
|
end
|
data/lib/sly/installer.rb
CHANGED
@@ -8,7 +8,7 @@ class Sly::Installer
|
|
8
8
|
|
9
9
|
if success_call?(results)
|
10
10
|
create_file(username, password)
|
11
|
-
|
11
|
+
$stdout.write "Thanks! Your details are currently stored in ~/.slyrc to authorise your interactions using the Sprint.ly CLI\n"
|
12
12
|
else
|
13
13
|
raise "The details provided were incorrect, please check your details and try again."
|
14
14
|
end
|
data/lib/sly/item.rb
CHANGED
@@ -3,9 +3,24 @@ require 'rainbow'
|
|
3
3
|
class Sly::Item
|
4
4
|
|
5
5
|
TYPE_COLOR = { task: :black, test: :blue, defect: :red, story: :green }
|
6
|
+
TYPES = { "task" => :task, "defect" => :defect, "story" => :feature }
|
6
7
|
|
7
8
|
attr_accessor :number, :archived, :title, :score, :tags, :status, :type
|
8
9
|
|
10
|
+
def self.with_number(number)
|
11
|
+
begin
|
12
|
+
items = YAML::load(File.open(File.join(".sly", "items")))
|
13
|
+
rescue Exception => e
|
14
|
+
raise "Unable to locate project files"
|
15
|
+
end
|
16
|
+
|
17
|
+
if items
|
18
|
+
items.select { |i| i.number.to_s == number.to_s }.first
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
9
24
|
def initialize(item_attributes = {})
|
10
25
|
@number = item_attributes["number"]
|
11
26
|
@archived = item_attributes["archived"]
|
@@ -13,7 +28,7 @@ class Sly::Item
|
|
13
28
|
@score = item_attributes["score"]
|
14
29
|
@tags = item_attributes["tags"]
|
15
30
|
@status = item_attributes["status"]
|
16
|
-
@type = item_attributes["type"].to_sym
|
31
|
+
@type = TYPES[item_attributes["type"]].to_sym
|
17
32
|
end
|
18
33
|
|
19
34
|
def overview
|
@@ -24,13 +39,21 @@ class Sly::Item
|
|
24
39
|
alias_method :to_s, :overview
|
25
40
|
|
26
41
|
def print
|
27
|
-
|
42
|
+
$stdout.print self.overview
|
28
43
|
end
|
29
44
|
|
30
45
|
def prettify(content, wrap_limit)
|
31
46
|
content.scan(/\S.{0,#{wrap_limit}}\S(?=\s|$)|\S+/).join("\n")
|
32
47
|
end
|
33
48
|
|
49
|
+
def slug
|
50
|
+
self.title.downcase.gsub(/(&|&)/, ' and ').strip.gsub(/ to | the |[^\w\s]/, '').gsub(/ +|_+/, '-')
|
51
|
+
end
|
52
|
+
|
53
|
+
def git_slug
|
54
|
+
"#{self.type}/" + self.slug.slice(0, 60) + "-#{self.number}"
|
55
|
+
end
|
56
|
+
|
34
57
|
private
|
35
58
|
|
36
59
|
def type_colour
|
data/lib/sly/version.rb
CHANGED
data/lib/sly.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- bin/sly
|
153
153
|
- lib/sly/version.rb
|
154
154
|
- lib/sly.rb
|
155
|
+
- lib/sly/branch.rb
|
155
156
|
- lib/sly/connector.rb
|
156
157
|
- lib/sly/gui.rb
|
157
158
|
- lib/sly/installer.rb
|
@@ -180,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
segments:
|
182
183
|
- 0
|
183
|
-
hash:
|
184
|
+
hash: -4553548518654402689
|
184
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
186
|
none: false
|
186
187
|
requirements:
|
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
version: '0'
|
190
191
|
segments:
|
191
192
|
- 0
|
192
|
-
hash:
|
193
|
+
hash: -4553548518654402689
|
193
194
|
requirements: []
|
194
195
|
rubyforge_project:
|
195
196
|
rubygems_version: 1.8.25
|