limer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
6
+ .pt_project_id
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "highline", :git => "git@github.com:JEG2/highline.git", :ref => 'master'
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Orgil
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Limer
2
+ =======
3
+
4
+ Command line tools for tasks at Limesoft
5
+
6
+ Based on following repo: [https://github.com/makandra/geordi]
7
+
8
+ ## Installation
9
+
10
+ Install it:
11
+
12
+ $ gem install limer
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/gitpt ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), '../lib/limer/gitpt')
3
+
4
+ Limer::Gitpt.new.run
@@ -0,0 +1,151 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems'
3
+ require 'highline'
4
+ require 'pivotal-tracker'
5
+ require 'yaml'
6
+
7
+ module Limer
8
+ class Gitpt
9
+ attr_reader :token, :highline, :initials, :name, :memberships, :applicable_stories, :setting_file
10
+
11
+ def initialize
12
+ @highline = HighLine.new
13
+ @setting_file = File.join(ENV['HOME'], '.gitpt')
14
+
15
+ load_setting
16
+ hello unless settings_valid?
17
+ request_settings while not settings_valid?
18
+ stored if not settings_valid?
19
+ PivotalTracker::Client.use_ssl = true
20
+ PivotalTracker::Client.token = token
21
+ end
22
+
23
+ def highlight string
24
+ bold HighLine::BLUE + string
25
+ end
26
+
27
+ def bold string
28
+ HighLine::BOLD + string + HighLine::RESET
29
+ end
30
+
31
+ def hello
32
+ highline.say HighLine::RESET
33
+ highline.say "Welcome to #{bold 'gitpt'}.\n\n"
34
+ end
35
+
36
+ def settings_valid?
37
+ token and token.size > 0
38
+ end
39
+
40
+ def stored
41
+ highline.say "
42
+ Thank you. Your settings have been stored at #{highlight @settings_file}
43
+ You may remove that file for the wizard to reappear.
44
+
45
+ ----------------------------------------------------"
46
+
47
+ end
48
+
49
+ def load_setting
50
+ if File.exists? setting_file
51
+ settings = YAML.load(File.read setting_file)
52
+ @initials = settings[:initials]
53
+ @token = settings[:token]
54
+ else
55
+ end
56
+ end
57
+
58
+ def load_project
59
+ project_id_file = '.pt_project_id'
60
+ if File.exists? project_id_file
61
+ project_ids = File.read(project_id_file).split(/[\s]+/).map(&:to_i)
62
+ end
63
+ unless project_ids and project_ids.size > 0
64
+ highline.say "No project config provided. Add project id(s) to .pt_project_id file"
65
+ exit 1
66
+ end
67
+ loading 'Connecting to Pivotal Tracker: ... ' do
68
+ projects = project_ids.collect do |project_id|
69
+ PivotalTracker::Project.find(project_id)
70
+ end
71
+
72
+ @memberships = projects.collect(&:memberships).map(&:all).flatten
73
+
74
+ @applicable_stories = projects.collect do |project|
75
+ project.stories.all(:state => 'started,finished,rejected')
76
+ end.flatten
77
+ end
78
+ end
79
+
80
+ def loading(message, &block)
81
+ print message
82
+ STDOUT.flush
83
+ yield
84
+ print "\r" + ' ' * message.size + "\r" # Remove loading message
85
+ STDOUT.flush
86
+ end
87
+
88
+ def request_settings
89
+ highline.say highlight('Your settings are missing or invalid.')
90
+ highline.say "Please configure your Pivotal Tracker access.\n\n"
91
+ token = highline.ask bold("Your API key:") + " "
92
+ initials = highline.ask bold("Your PT initials") + " (optional, used for highlighting your stories): "
93
+ highline.say "\n"
94
+
95
+ settings = { :token => token, :initials => initials }
96
+
97
+ File.open setting_file, 'w' do |file|
98
+ file.write settings.to_yaml
99
+ end
100
+
101
+ load_setting
102
+ end
103
+
104
+ def choose_story
105
+ selected_story = nil
106
+
107
+ highline.choose do |menu|
108
+ menu.header = "Choose a story"
109
+ applicable_stories.each do |story|
110
+ owner_name = story.owned_by
111
+ owner = if owner_name
112
+ owners = memberships.select{|member| member.name == owner_name}
113
+ owners.first ? owners.first.initials : '?'
114
+ else
115
+ '?'
116
+ end
117
+
118
+ state = story.current_state
119
+ if state == 'started'
120
+ state = HighLine::GREEN + state + HighLine::RESET
121
+ elsif state != 'finished'
122
+ state = HighLine::RED + state + HighLine::RESET
123
+ end
124
+ state += HighLine::BOLD if owner == initials
125
+
126
+ label = "(#{owner}, #{state}) #{story.name}"
127
+ label = bold(label) if owner == initials
128
+ menu.choice(label) { selected_story = story }
129
+ end
130
+ menu.hidden ''
131
+ end
132
+
133
+ if selected_story
134
+ message = highline.ask("\nAdd an optional message")
135
+ highline.say message
136
+
137
+ commit_message = "[##{selected_story.id}] #{selected_story.name}"
138
+ if message.strip != ''
139
+ commit_message << ' - '<< message.strip
140
+ end
141
+
142
+ puts commit_message
143
+ # exec('git', 'commit', '-m', commit_message)
144
+ end
145
+ end
146
+ def run
147
+ load_project
148
+ choose_story
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,3 @@
1
+ module Limer
2
+ VERSION = "0.0.1"
3
+ end
data/lib/limer.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "limer/version"
2
+
3
+ module Limer
4
+ # Your code goes here...
5
+ end
data/limer.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "limer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "limer"
7
+ s.version = Limer::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Orgil Urtnasan"]
10
+ s.email = ["orgil@limesoft.mn"]
11
+ s.homepage = "http://limesoft.com"
12
+ s.summary = 'Command line tools for tasks at Limesoft.'
13
+ s.description = 'COmmand line tools for tasks at Limesoft.'
14
+
15
+ s.rubyforge_project = "limer"
16
+
17
+ s.add_dependency("highline")
18
+ s.add_dependency("pivotal-tracker")
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: limer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Orgil Urtnasan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: highline
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: pivotal-tracker
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: COmmand line tools for tasks at Limesoft.
47
+ email:
48
+ - orgil@limesoft.mn
49
+ executables:
50
+ - gitpt
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/gitpt
60
+ - lib/limer.rb
61
+ - lib/limer/gitpt.rb
62
+ - lib/limer/version.rb
63
+ - limer.gemspec
64
+ homepage: http://limesoft.com
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project: limer
84
+ rubygems_version: 1.8.25
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Command line tools for tasks at Limesoft.
88
+ test_files: []