tracco 0.0.16 → 0.0.17

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.
data/CHANGELOG CHANGED
@@ -1,14 +1,23 @@
1
+ 0.0.17 / 2013-03-15
2
+ ==================
3
+ * migrating all the rake tasks to bin executables. Still leaving the rake task, marking them as DEPRECATED though
4
+ * adding a verbose mode to run the tracking collection, by default the logger level is now raised to Logger::WARN
5
+ * updating README with new tracco commands
6
+ * refactoring the namespace of several modules, simplifying tracco.rb
7
+ * improving tracco loading using autoload
8
+ * improving date parsing in CLI
9
+
1
10
  0.0.16 / 2013-03-12
2
11
  ==================
3
- slowly migrating from rake tasks to bin commands
4
- improving readme
5
- dropping ruby 1.9.2 support due to Mongoid issues (http://mongoid.org/en/mongoid/docs/tips.html#ruby)
6
- updating depending gems
7
- improving Tracco load env, avoiding double env loading when running the specs, renaming MONGOID_ENV to a more generic TRACCO_ENV
8
- adding a logo for Tracco!
9
- adding Ruby 2.0.0 compatibility
10
- adding awesome_print gem to the console task
11
- adding an helper task to copy the configuration template files
12
+ * Slowly migrating from rake tasks to bin commands (using Thor gem).
13
+ * Improving README
14
+ * Dropping ruby 1.9.2 support due to some Mongoid issues (http://mongoid.org/en/mongoid/docs/tips.html#ruby)
15
+ * Updating depending gems
16
+ * Improving Tracco load env, avoiding double env loading when running the specs, renaming MONGOID_ENV to a more generic TRACCO_ENV
17
+ * Adding a logo for Tracco!
18
+ * Adding Ruby 2.0.0 compatibility
19
+ * Adding awesome_print gem to the console task
20
+ * Adding an helper task to copy the configuration template files
12
21
 
13
22
  0.0.15 / 2013-03-01
14
23
  ==================
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tracco (0.0.16)
4
+ tracco (0.0.17)
5
5
  bson_ext
6
6
  chronic
7
7
  google_drive
data/README.md CHANGED
@@ -85,14 +85,12 @@ To generate a proper access token key, log in to Trello with the 'tracking user'
85
85
  At the end of this process, you'll receive a valid access\_token\_key, which is needed by Tracco to have the proper rights to fetch all the tracking notifications sent as comments to the 'tracking user'.
86
86
 
87
87
  ## Collecting data from Trello
88
- To collect and store tracking data from your Trello board, you can use one of the provided rake tasks, e.g.
89
-
90
- ```ruby
91
- rake 'run:today[test]' # will extract today's tracked data and store on the test db
88
+ ```shell
89
+ tracco collect today --environment test # will extract today's tracked data and store on the test db
92
90
 
93
- rake run:today # will extract today's tracked data and store on the default (that is development) db
91
+ tracco collect today # will extract today's tracked data and store on the default (that is development) db
94
92
 
95
- rake 'run:from_day[2012-11-1, production]' # will extract tracked data starting from November the 1st, 2012 and store them into the production db
93
+ tracco collect 2012-11-1 --environment production # will extract tracked data starting from November the 1st, 2012 and store them into the production db
96
94
  ```
97
95
 
98
96
  Or you may just create a TrelloTracker instance and execute its track method.
@@ -165,14 +163,14 @@ Or using the config.yml (which is the actual fallback mode, useful in developmen
165
163
  ### Console
166
164
  You can open a irb console with the ruby-trello gem and this gem loaded, so that you can query the db or the Trello API and play with them
167
165
 
168
- ```ruby
169
- rake console
166
+ ```shell
167
+ tracco console
170
168
  ```
171
169
 
172
170
  The default env is development. To load a console in the (e.g.) production db env, execute:
173
171
 
174
- ```ruby
175
- rake "console[production]"
172
+ ```shell
173
+ tracco console -e production
176
174
  ```
177
175
 
178
176
  ## Estimate format convention
@@ -243,8 +241,8 @@ mongoimport --db tracco_production --collection tracked_cards --file tracco_pro
243
241
  ## Google Docs exporter
244
242
  To export all your tracked cards on a google docs named 'my_sheet' in the 'tracking' worksheet, run
245
243
 
246
- ```ruby
247
- rake "export:google_docs[my_sheet, tracking, production]"
244
+ ```shell
245
+ tracco export_google_docs my_sheet tracking -e production
248
246
  ```
249
247
  The default env is development.
250
248
 
@@ -254,7 +252,7 @@ If the spreadsheet name you provide does not exists, it will be created in you g
254
252
  So, running simply
255
253
 
256
254
  ```ruby
257
- rake export:google_docs
255
+ tracco export_google_docs
258
256
  ```
259
257
  will create (or update) a spreadsheet named "trello effort tracking" using the development db env.
260
258
 
@@ -268,7 +266,7 @@ PROJECT_PATH="/Users/$USER/Documents/workspace/tracco"
268
266
  LC_ALL=en_US.UTF-8
269
267
 
270
268
  # m h dom mon dow command
271
- */10 * * * * rvm-shell $GEMSET -c "cd $PROJECT_PATH; bundle exec rake run:today[production]" >> /tmp/crontab.out 2>&1
269
+ */10 * * * * rvm-shell $GEMSET -c "cd $PROJECT_PATH; bundle exec tracco collect today -e production" >> /tmp/crontab.out 2>&1
272
270
  ```
273
271
 
274
272
  ## Roadmap and improvements
data/bin/tracco CHANGED
@@ -1,34 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
3
 
4
- require 'trello'
5
- require 'rainbow'
6
- require 'set'
7
- require 'yaml'
8
- require 'chronic'
9
- require 'mongoid'
10
- require 'forwardable'
11
-
12
- require 'tracco/cli'
13
- require 'tracco/version'
14
- require 'tracco/mongoid_helper'
15
- require 'tracco/trello_configuration'
16
- require 'tracco/trello_authorize'
17
- require 'tracco/models/tracked_card'
18
- require 'tracco/models/member'
19
- require 'tracco/models/estimate'
20
- require 'tracco/models/effort'
21
- require 'tracco/tracking/base'
22
- require 'tracco/tracking/estimate_tracking'
23
- require 'tracco/tracking/effort_tracking'
24
- require 'tracco/tracking/card_done_tracking'
25
- require 'tracco/tracking/invalid_tracking'
26
- require 'tracco/tracking/factory'
27
- require 'tracco/trello_tracker'
28
- require 'tracco/configuration'
29
- require 'tracco/exporters/google_docs'
30
-
31
- require 'patches/trello/member'
32
- require 'patches/trello/card'
4
+ require 'tracco'
33
5
 
34
6
  Tracco::CLI.start(ARGV)
@@ -1,2 +1,2 @@
1
- include TrelloAuthorize
1
+ include Tracco::TrelloAuthorize
2
2
  authorize_on_trello
@@ -1,72 +1,36 @@
1
- #TODO: deprecated (use 'tracco console')
1
+ # DEPRECATED: use tracco executables instead
2
2
  desc "Open an irb session preloaded with this library, e.g. rake 'console[production]' will open a irb session with the production db env"
3
3
  task :console, [:tracco_env] do |t, args|
4
4
  args.with_defaults(tracco_env: "development")
5
- sh "export TRACCO_ENV=#{args.tracco_env}; irb -rubygems -I lib -r tracco -r startup_trello.rb -r awesome_print"
5
+ sh "tracco c --environment #{args.tracco_env}"
6
6
  end
7
7
 
8
- #TODO: deprecated (use 'tracco console')
8
+ # DEPRECATED: use tracco executables instead
9
9
  task :c, [:tracco_env] do |t, args|
10
- Rake::Task[:console].invoke(args.tracco_env)
11
- end
12
-
13
- desc "Copy template config files"
14
- task :prepare do
15
- Dir.glob("config/*.template.yml").each do |file|
16
- template_file = File.basename(file)
17
- target_file = template_file.sub('.template', '')
18
- if File.exists?(File.join('config', target_file))
19
- puts "skipping #{target_file.color(:yellow)}, already exists."
20
- else
21
- cp File.join('config', template_file), File.join('config', target_file)
22
- puts "please edit the #{target_file} to have all the proper configurations"
23
- end
24
- end
10
+ args.with_defaults(tracco_env: "development")
11
+ sh "tracco c --environment #{args.tracco_env}"
25
12
  end
26
13
 
27
- #TODO: deprecated (use 'tracco collect')
14
+ # DEPRECATED: use tracco executables instead
28
15
  namespace :run do
29
- include TrelloConfiguration
30
-
31
16
  desc "Run on the cards tracked starting from a given day, e.g. rake 'run:from_day[2012-11-1]'"
32
- task :from_day, [:starting_date, :tracco_env] => [:ensure_environment] do |t, args|
17
+ task :from_day, [:starting_date, :tracco_env] do |t, args|
33
18
  args.with_defaults(starting_date: Date.today.to_s, tracco_env: "development")
34
- Tracco::Database.load_env(args.tracco_env)
35
-
36
- tracker = Tracco::TrelloTracker.new
37
- tracker.track(Date.parse(args.starting_date))
19
+ sh "tracco t #{args.starting_date} --environment #{args.tracco_env}"
38
20
  end
39
21
 
40
22
  desc "Run on the cards tracked today, #{Date.today}"
41
- task :today, [:tracco_env] => [:ensure_environment] do |t, args|
23
+ task :today, [:tracco_env] do |t, args|
42
24
  args.with_defaults(tracco_env: "development")
43
- Rake.application.invoke_task("run:from_day[#{Date.today.to_s}, #{args.tracco_env}]")
25
+ sh "tracco t #{Date.today.to_s} --environment #{args.tracco_env}"
44
26
  end
45
27
  end
46
28
 
29
+ # DEPRECATED: use tracco executables instead
47
30
  namespace :export do
48
31
  desc "Export all cards to a google docs spreadsheet, e.g. rake \"export:google_docs[my_sheet,tracking,production]\""
49
- task :google_docs, [:spreadsheet, :worksheet, :tracco_env] => [:ensure_environment] do |t, args|
32
+ task :google_docs, [:spreadsheet, :worksheet, :tracco_env] do |t, args|
50
33
  args.with_defaults(tracco_env: "development")
51
- Tracco::Database.load_env(args.tracco_env)
52
-
53
- exporter = Tracco::Exporters::GoogleDocs.new(args.spreadsheet, args.worksheet)
54
- spreadsheet_url = exporter.export
55
-
56
- puts "[DONE]".color(:green)
57
- puts "Go to #{spreadsheet_url}"
58
- end
59
- end
60
-
61
- task :ensure_environment do
62
- %w{developer_public_key access_token_key}.each do |each_name|
63
- unless ENV[each_name] || authorization_params_from_config_file[each_name]
64
- puts "ERROR: Missing <#{each_name}> configuration parameter: set it as environment variable or in the config/config.yml file."
65
- exit 1
66
- end
67
- end
68
- unless tracker_username
69
- puts "ERROR: Missing <tracker_username> configuration parameter: set it as environment variable or in the config/config.yml file."
70
- exit 1
34
+ sh "tracco egd #{args.spreadsheet} #{args.worksheet} --environment #{args.tracco_env}"
71
35
  end
72
36
  end
@@ -1,32 +1,38 @@
1
1
  require 'trello'
2
2
  require 'rainbow'
3
- require 'set'
4
- require 'yaml'
5
3
  require 'chronic'
6
4
  require 'mongoid'
7
5
  require 'forwardable'
8
6
 
9
- require 'tracco/cli'
10
- require 'tracco/version'
11
- require 'tracco/mongoid_helper'
12
- require 'tracco/trello_configuration'
13
- require 'tracco/trello_authorize'
14
- require 'tracco/models/tracked_card'
15
- require 'tracco/models/member'
16
- require 'tracco/models/estimate'
17
- require 'tracco/models/effort'
18
- require 'tracco/tracking/base'
19
- require 'tracco/tracking/estimate_tracking'
20
- require 'tracco/tracking/effort_tracking'
21
- require 'tracco/tracking/card_done_tracking'
22
- require 'tracco/tracking/invalid_tracking'
23
- require 'tracco/tracking/factory'
24
- require 'tracco/trello_tracker'
25
7
  require 'tracco/configuration'
26
- require 'tracco/exporters/google_docs'
8
+
9
+ module Tracco
10
+ autoload :TrelloAuthorize, 'tracco/trello_authorize'
11
+
12
+ autoload :TrackedCard, 'tracco/models/tracked_card'
13
+ autoload :Member, 'tracco/models/member'
14
+ autoload :Estimate, 'tracco/models/estimate'
15
+ autoload :Effort, 'tracco/models/effort'
16
+ autoload :TrelloTracker, 'tracco/trello_tracker'
17
+
18
+ module Tracking
19
+ autoload :Base, 'tracco/tracking/base'
20
+ autoload :EstimateTracking, 'tracco/tracking/estimate_tracking'
21
+ autoload :EffortTracking, 'tracco/tracking/effort_tracking'
22
+ autoload :CardDoneTracking, 'tracco/tracking/card_done_tracking'
23
+ autoload :InvalidTracking, 'tracco/tracking/invalid_tracking'
24
+ autoload :Factory, 'tracco/tracking/factory'
25
+ end
26
+
27
+ module Exporters
28
+ autoload :GoogleDocs, 'tracco/exporters/google_docs'
29
+ end
30
+
31
+ autoload :CLI, 'tracco/cli'
32
+ end
27
33
 
28
34
  require 'patches/trello/member'
29
35
  require 'patches/trello/card'
30
36
 
31
- Trello.logger.level = Logger::DEBUG
37
+ Trello.logger.level = Logger::WARN
32
38
  Tracco.load_env!
@@ -4,35 +4,88 @@ require 'thor/actions'
4
4
  module Tracco
5
5
  class CLI < Thor
6
6
  include Thor::Actions
7
+ include TrelloConfiguration
7
8
 
8
- desc "console ENVIRONMENT", "Open an irb session preloaded with this library"
9
+ def self.source_root
10
+ File.join(File.dirname(__FILE__), "..", "..", "config")
11
+ end
12
+
13
+ map "c" => :console
14
+ map %w(track t) => :collect
15
+ map "egd" => :export_google_docs
16
+ map "check_env" => :ensure_env
17
+ map %w(-v --version) => :version
18
+ map %w(initialize --initialize) => :init
19
+
20
+ desc "console", "Opens up an irb session preloaded with Tracco gem"
9
21
  long_desc <<-LONGDESC
10
- Open an irb session preloaded with this library.
22
+ Opens up an irb session preloaded with this library.
11
23
  e.g. 'tracco console production' will open a irb session with the production environment
12
24
  LONGDESC
13
- def console(environment="development")
14
- error("invalid environment specified: #{environment}") unless is_valid_env?(environment)
15
-
25
+ method_option :environment, :aliases => "-e", :desc => "the env to use", :default => "development"
26
+ def console
27
+ environment = environment_from(options)
16
28
  run "export TRACCO_ENV=#{environment}; irb -rubygems -I lib -r tracco -r startup_trello.rb -r awesome_print"
17
29
  end
18
- map %w(c) => :console
19
30
 
20
31
 
21
- desc "collect STARTING_FROM", "Run tracking data fetching on the cards tracked starting from a given date"
32
+ desc "collect STARTING_FROM", "Runs tracking data fetching on the cards tracked starting from a given date"
33
+ long_desc <<-LONGDESC
34
+ Runs tracking data fetching on the cards tracked starting from a given date.
35
+ e.g. 'tracco 2013.03.23' will start collecting tracking data starting from March 23, 2013.
36
+ LONGDESC
22
37
  method_option :environment, :aliases => "-e", :desc => "the env to use", :default => "development"
23
38
  method_option :mongoid_config_path, :aliases => "-m", :desc => "the mongoid config file to use"
24
- def collect(starting_date=Date.today.to_s)
25
- environment = options[:environment]
26
- error("invalid environment specified: #{environment}") unless is_valid_env?(environment)
27
-
28
- starting_date = Date.today.to_s if starting_date == "today"
29
- error("invalid date: #{starting_date}") unless is_valid_date?(starting_date)
39
+ method_option :verbose, :aliases => "-v", :type => :boolean, :default => false
40
+ def collect(starting_date_as_string=Date.today.to_s)
41
+ set_logger_level(options[:verbose])
42
+ invoke :ensure_env
30
43
 
44
+ starting_date = date_from(starting_date_as_string)
45
+ environment = environment_from(options)
31
46
  Tracco::Database.load_env(environment, options[:mongoid_config_path])
32
47
 
33
- puts "collecting tracking data starting from #{starting_date} in the #{environment} env."
48
+ puts "Collecting tracking data starting from #{starting_date} in the #{environment} env."
34
49
  tracker = Tracco::TrelloTracker.new
35
- tracker.track(Date.parse(starting_date))
50
+ tracker.track(starting_date)
51
+ end
52
+
53
+ desc "initialize", "Copy template configuration files"
54
+ def init
55
+ Dir.glob("config/*.template.yml").each do |file|
56
+ template_file = File.basename(file)
57
+ target_file = template_file.sub('.template', '')
58
+
59
+ if File.exists?(File.join('config', target_file))
60
+ say "skipping #{target_file.color(:yellow)}, already exists."
61
+ else
62
+ copy_file File.join(CLI.source_root, template_file), File.join(CLI.source_root, target_file)
63
+ say "please edit the #{target_file} to have all the proper configurations"
64
+ end
65
+ end
66
+ end
67
+
68
+ desc "export_google_docs SPREADSHEET_NAME WORKSHEET_NAME", "Exports tracking data to google docs"
69
+ long_desc <<-LONGDESC
70
+ Exports all tracking data stored in the db into a google docs.
71
+ e.g. 'tracco export_google_docs tracco_export tracking_data' will export tracking data into a 'tracco_export' sheet,
72
+ in the 'tracking_data' worksheet.
73
+ LONGDESC
74
+
75
+ method_option :environment, :aliases => "-e", :desc => "the env to use", :default => "development"
76
+ method_option :mongoid_config_path, :aliases => "-m", :desc => "the mongoid config file to use"
77
+ method_option :verbose, :type => :boolean, :aliases => "-v", :default => false
78
+ def export_google_docs(spreadsheet="tracco", worksheet="tracking")
79
+ set_logger_level(options[:verbose])
80
+ invoke :ensure_env
81
+
82
+ environment = environment_from(options)
83
+ Tracco::Database.load_env(environment, options[:mongoid_config_path])
84
+
85
+ exporter = Tracco::Exporters::GoogleDocs.new(spreadsheet, worksheet)
86
+ spreadsheet_url = exporter.export
87
+ say "[DONE]".color(:green)
88
+ say "Go to #{spreadsheet_url}"
36
89
  end
37
90
 
38
91
 
@@ -40,27 +93,55 @@ module Tracco
40
93
  def version
41
94
  say "Tracco version #{Tracco::VERSION}"
42
95
  end
43
- map %w(-v --version) => :version
44
96
 
97
+ desc "ensure_env", "Ensures the environment is valid"
98
+ def ensure_env(*args)
99
+ %w{developer_public_key access_token_key}.each do |each_name|
100
+ unless ENV[each_name] || authorization_params_from_config_file[each_name]
101
+ error("Missing <#{each_name}> configuration parameter: set it as environment variable or in the config/config.yml file.")
102
+ end
103
+ end
104
+ unless tracker_username
105
+ error("Missing <tracker_username> configuration parameter: set it as environment variable or in the config/config.yml file.")
106
+ end
107
+ end
45
108
 
46
109
  private
47
110
 
48
- def is_valid_env?(environment)
49
- %w{production development test}.include? environment
111
+ def set_logger_level(verbose)
112
+ Trello.logger.level = verbose ? Logger::DEBUG : Logger::INFO
113
+ end
114
+
115
+ def environment_from(options)
116
+ environment = options[:environment]
117
+ error_invalid_environment(environment) unless is_valid_env?(environment)
118
+
119
+ return environment
50
120
  end
51
121
 
52
- def is_valid_date?(date)
53
- begin
54
- Date.parse(date)
55
- true
56
- rescue ArgumentError
57
- false
122
+ def date_from(starting_date_as_string)
123
+ if starting_date_as_string == "today"
124
+ Date.today
125
+ else
126
+ parse_date(starting_date_as_string) || error("Invalid date: #{starting_date_as_string}")
58
127
  end
59
128
  end
60
129
 
130
+ def parse_date(date_as_string)
131
+ Date.parse(date_as_string) rescue nil
132
+ end
133
+
134
+ def is_valid_env?(environment)
135
+ %w{production development test}.include? environment
136
+ end
137
+
61
138
  def error(message)
62
- say "ERROR: #{message}"
139
+ say "[ERROR] ".color(:red) << message
63
140
  exit 1
64
141
  end
142
+
143
+ def error_invalid_environment(environment)
144
+ error("Invalid environment specified: #{environment}")
145
+ end
65
146
  end
66
147
  end
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module Tracco
2
4
  def self.environment
3
5
  ENV['TRACCO_ENV']
@@ -11,8 +13,8 @@ module Tracco
11
13
  begin
12
14
  Database.load_env(environment || "development", ENV['MONGOID_CONFIG_PATH'])
13
15
  rescue Errno::ENOENT => e
14
- puts e.message
15
- puts "try running 'rake prepare'"
16
+ Trello.logger.warn e.message
17
+ Trello.logger.warn "try running 'rake prepare'"
16
18
  end
17
19
  end
18
20
 
@@ -20,7 +22,29 @@ module Tracco
20
22
  def self.load_env(tracco_env, mongoid_configuration_path=nil)
21
23
  Tracco.environment = tracco_env
22
24
  Mongoid.load!(mongoid_configuration_path || "config/mongoid.yml", tracco_env)
23
- Trello.logger.info "Mongo db env: #{tracco_env.color(:green)}."
25
+ Trello.logger.debug "Mongo db env: #{tracco_env.color(:green)}."
26
+ end
27
+ end
28
+
29
+ module TrelloConfiguration
30
+
31
+ def tracker_username(forced_tracker_username=nil)
32
+ @tracker_username ||= forced_tracker_username || ENV["tracker_username"] || configuration["tracker_username"]
33
+ end
34
+
35
+ def authorization_params_from_config_file
36
+ begin
37
+ configuration["trello"]
38
+ rescue NoMethodError => e
39
+ Trello.logger.info "Invalid configuration file".color(:red)
40
+ {}
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ def configuration
47
+ @configuration ||= YAML.load_file("config/config.yml")
24
48
  end
25
49
  end
26
50
 
@@ -6,13 +6,15 @@ module Tracco
6
6
  class GoogleDocs
7
7
  include TrelloConfiguration
8
8
 
9
+ trap("SIGINT") { exit! }
10
+
9
11
  def initialize(spreadsheet_name, worksheet_name)
10
12
  @spreadsheet_name = spreadsheet_name || "trello effort tracking"
11
13
  @worksheet_name = worksheet_name || "tracking"
12
14
  end
13
15
 
14
16
  def export
15
- Trello.logger.info "Running exporter from db env '#{Environment.name}' to google docs '#{@spreadsheet_name.color(:green)}##{@worksheet_name.color(:green)}'..."
17
+ Trello.logger.info "Running exporter from db env '#{Tracco.environment}' to google docs '#{@spreadsheet_name.color(:green)}##{@worksheet_name.color(:green)}'..."
16
18
 
17
19
  spreadsheet = google_docs_session.spreadsheet_by_title(@spreadsheet_name) || google_docs_session.create_spreadsheet(@spreadsheet_name)
18
20
  worksheet = spreadsheet.worksheet_by_title(@worksheet_name) || spreadsheet.add_worksheet(@worksheet_name)
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Tracco
2
4
  class Effort
3
5
  include Mongoid::Document
@@ -1,3 +1,5 @@
1
+ require 'tracco/mongoid_helper'
2
+
1
3
  module Tracco
2
4
  class TrackedCard
3
5
  include Mongoid::Document
@@ -1,13 +1,15 @@
1
- module MongoidHelper
2
-
3
- def without_mongo_raising_errors(&block)
4
- original_value = Mongoid.raise_not_found_error
5
- Mongoid.raise_not_found_error = false
6
- begin
7
- block.call if block
8
- ensure
9
- Mongoid.raise_not_found_error = original_value
1
+ module Tracco
2
+ module MongoidHelper
3
+
4
+ def without_mongo_raising_errors(&block)
5
+ original_value = Mongoid.raise_not_found_error
6
+ Mongoid.raise_not_found_error = false
7
+ begin
8
+ block.call if block
9
+ ensure
10
+ Mongoid.raise_not_found_error = original_value
11
+ end
10
12
  end
13
+
11
14
  end
12
-
13
- end
15
+ end
@@ -1,16 +1,18 @@
1
- module TrelloAuthorize
2
- include TrelloConfiguration
3
- include Trello::Authorization
1
+ module Tracco
2
+ module TrelloAuthorize
3
+ include TrelloConfiguration
4
+ include Trello::Authorization
4
5
 
5
- def authorize_on_trello(auth_params={})
6
- %w{developer_public_key access_token_key}.each do |key|
7
- auth_params[key.to_sym] ||= ENV[key] || authorization_params_from_config_file[key]
8
- end
6
+ def authorize_on_trello(auth_params={})
7
+ %w{developer_public_key access_token_key}.each do |key|
8
+ auth_params[key.to_sym] ||= ENV[key] || authorization_params_from_config_file[key]
9
+ end
9
10
 
10
- Trello.configure do |config|
11
- config.developer_public_key = auth_params[:developer_public_key]
12
- config.member_token = auth_params[:access_token_key]
11
+ Trello.configure do |config|
12
+ config.developer_public_key = auth_params[:developer_public_key]
13
+ config.member_token = auth_params[:access_token_key]
14
+ end
13
15
  end
14
- end
15
16
 
17
+ end
16
18
  end
@@ -22,7 +22,7 @@ module Tracco
22
22
  begin
23
23
  tracked_card = TrackedCard.update_or_create_with(tracking_notification.card)
24
24
  tracked_card.add!(tracking)
25
- Trello.logger.info tracking.to_s
25
+ log(tracking)
26
26
 
27
27
  rescue StandardError => e
28
28
  Trello.logger.warn "skipping tracking: #{e.message}".color(:magenta)
@@ -43,6 +43,10 @@ module Tracco
43
43
  [dates.min, dates.max]
44
44
  end
45
45
 
46
+ def log(tracking)
47
+ Trello.logger.level > Logger::INFO ? print(".".color(:green)) : puts(tracking.to_s)
48
+ end
49
+
46
50
  end
47
51
 
48
52
  end
@@ -1,3 +1,3 @@
1
1
  module Tracco
2
- VERSION = '0.0.16'
2
+ VERSION = '0.0.17'
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'trello'
3
3
 
4
- describe "TrelloAuthorization" do
5
- include TrelloAuthorize
4
+ describe "Trello Authorization" do
5
+ include Tracco::TrelloAuthorize
6
6
 
7
7
  let(:config) {
8
8
  # auth params for trackinguser_for_test/testinguser!
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
  require 'trello'
3
3
 
4
- describe TrelloAuthorize do
4
+ describe Tracco::TrelloAuthorize do
5
5
  include Trello::Authorization
6
- include TrelloAuthorize
6
+ include Tracco::TrelloAuthorize
7
7
 
8
8
  before(:each) do
9
9
  keep_original_auth_envs
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'trello'
3
3
 
4
- describe TrelloConfiguration do
5
- include TrelloConfiguration
4
+ describe Tracco::TrelloConfiguration do
5
+ include Tracco::TrelloConfiguration
6
6
 
7
7
  describe "#authorization_params_from_config_file" do
8
8
  it "loads the default trello auth params from config yml" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
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-03-12 00:00:00.000000000 Z
12
+ date: 2013-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-trello
@@ -217,7 +217,6 @@ files:
217
217
  - lib/tracco/tracking/factory.rb
218
218
  - lib/tracco/tracking/invalid_tracking.rb
219
219
  - lib/tracco/trello_authorize.rb
220
- - lib/tracco/trello_configuration.rb
221
220
  - lib/tracco/trello_tracker.rb
222
221
  - lib/tracco/version.rb
223
222
  - script/ci/before_script.sh
@@ -262,7 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
261
  version: '0'
263
262
  segments:
264
263
  - 0
265
- hash: -2206961055360224389
264
+ hash: 2030524429048154611
266
265
  required_rubygems_version: !ruby/object:Gem::Requirement
267
266
  none: false
268
267
  requirements:
@@ -1,27 +0,0 @@
1
- module TrelloConfiguration
2
-
3
- def tracker_username(forced_tracker_username=nil)
4
- @tracker_username ||= forced_tracker_username || ENV["tracker_username"] || configuration["tracker_username"]
5
- end
6
-
7
- def authorization_params_from_config_file
8
- begin
9
- configuration["trello"]
10
- rescue NoMethodError => e
11
- Trello.logger.info "Invalid configuration file".color(:red)
12
- {}
13
- end
14
-
15
- end
16
-
17
- private
18
-
19
- def configuration
20
- @configuration ||= load_configuration
21
- end
22
-
23
- def load_configuration
24
- YAML.load_file("config/config.yml")
25
- end
26
-
27
- end