Class: Pickler
- Inherits:
-
Object
show all
- Defined in:
- lib/pickler.rb,
lib/pickler/runner.rb,
lib/pickler/feature.rb,
lib/pickler/tracker.rb,
lib/pickler/tracker/note.rb,
lib/pickler/tracker/story.rb,
lib/pickler/tracker/project.rb,
lib/pickler/tracker/iteration.rb
Defined Under Namespace
Modules: Editor
Classes: Error, Feature, Runner, Tracker
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path = '.') ⇒ Pickler
Returns a new instance of Pickler.
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/pickler.rb', line 26
def initialize(path = '.')
@lang = 'en'
@directory = File.expand_path(path)
until File.directory?(File.join(@directory,'features'))
if @directory == File.dirname(@directory)
raise Error, 'Project not found. Make sure you have a features/ directory.', caller
end
@directory = File.dirname(@directory)
end
end
|
Instance Attribute Details
#directory ⇒ Object
Returns the value of attribute directory.
24
25
26
|
# File 'lib/pickler.rb', line 24
def directory
@directory
end
|
Class Method Details
.config ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/pickler.rb', line 12
def self.config
@config ||= {'api_token' => ENV["TRACKER_API_TOKEN"]}.merge(
if File.exist?(path = File.expand_path('~/.tracker.yml'))
YAML.load_file(path)
end || {}
)
end
|
.run(argv) ⇒ Object
20
21
22
|
# File 'lib/pickler.rb', line 20
def self.run(argv)
Runner.new(argv).run
end
|
Instance Method Details
#config ⇒ Object
45
46
47
48
|
# File 'lib/pickler.rb', line 45
def config
@config ||= File.exist?(config_file) && YAML.load_file(config_file) || {}
self.class.config.merge(@config)
end
|
#config_file ⇒ Object
41
42
43
|
# File 'lib/pickler.rb', line 41
def config_file
features_path('tracker.yml')
end
|
#deliver_all_finished_stories ⇒ Object
81
82
83
|
# File 'lib/pickler.rb', line 81
def deliver_all_finished_stories
project.deliver_all_finished_stories
end
|
#feature(string) ⇒ Object
129
130
131
|
# File 'lib/pickler.rb', line 129
def feature(string)
string.kind_of?(Feature) ? string : Feature.new(self,string)
end
|
#features_path(*subdirs) ⇒ Object
37
38
39
|
# File 'lib/pickler.rb', line 37
def features_path(*subdirs)
File.join(@directory,'features',*subdirs)
end
|
113
114
115
|
# File 'lib/pickler.rb', line 113
def format
(config['format'] || :comment).to_sym
end
|
#iteration_length ⇒ Object
69
70
71
|
# File 'lib/pickler.rb', line 69
def iteration_length
project.iteration_length
end
|
#local_features ⇒ Object
117
118
119
|
# File 'lib/pickler.rb', line 117
def local_features
Dir[features_path('**','*.feature')].map {|f|feature(f)}.select {|f|f.pushable?}
end
|
#name ⇒ Object
65
66
67
|
# File 'lib/pickler.rb', line 65
def name
project.name
end
|
#new_story(attributes = {}, &block) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/pickler.rb', line 54
def new_story(attributes = {}, &block)
attributes = attributes.inject('requested_by' => real_name) do |h,(k,v)|
h.update(k.to_s => v)
end
project.new_story(attributes, &block)
end
|
#parser ⇒ Object
85
86
87
88
89
|
# File 'lib/pickler.rb', line 85
def parser
require 'cucumber'
Cucumber.load_language(@lang)
@parser ||= Cucumber::Parser::FeatureParser.new
end
|
#point_scale ⇒ Object
73
74
75
|
# File 'lib/pickler.rb', line 73
def point_scale
project.point_scale
end
|
#project ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/pickler.rb', line 95
def project
@project ||= Dir.chdir(@directory) do
unless token = config['api_token']
raise Error, 'echo api_token: ... > ~/.tracker.yml'
end
unless id = project_id
raise Error, 'echo project_id: ... > features/tracker.yml'
end
ssl = config['ssl']
Tracker.new(token, ssl).project(id)
end
end
|
#project_id ⇒ Object
91
92
93
|
# File 'lib/pickler.rb', line 91
def project_id
config["project_id"] || (self.class.config["projects"]||{})[File.basename(@directory)]
end
|
#real_name ⇒ Object
50
51
52
|
# File 'lib/pickler.rb', line 50
def real_name
config["real_name"] || (require 'etc'; Etc.getpwuid.gecos.split(',').first)
end
|
#scenario_features ⇒ Object
121
122
123
124
125
126
127
|
# File 'lib/pickler.rb', line 121
def scenario_features
project.stories(scenario_word, :includedone => true).reject do |s|
s.current_state =~ /^unscheduled|unstarted$/
end.select do |s|
s.to_s =~ /^\s*#{Regexp.escape(scenario_word)}:/ && parser.parse(s.to_s)
end
end
|
#scenario_word ⇒ Object
108
109
110
111
|
# File 'lib/pickler.rb', line 108
def scenario_word
parser
Cucumber.keyword_hash['scenario']
end
|
#stories(*args) ⇒ Object
61
62
63
|
# File 'lib/pickler.rb', line 61
def stories(*args)
project.stories(*args)
end
|
#story(string) ⇒ Object
133
134
135
|
# File 'lib/pickler.rb', line 133
def story(string)
feature(string).story
end
|
#week_start_day ⇒ Object
77
78
79
|
# File 'lib/pickler.rb', line 77
def week_start_day
project.week_start_day
end
|