mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 17:28:50 +01:00
More code style fixes
This commit is contained in:
parent
465419f46a
commit
d4c9041ccd
61 changed files with 406 additions and 422 deletions
|
|
@ -7,7 +7,7 @@ require 'activeresource'
|
|||
# sudo gem install activeresource --source http://gems.rubyonrails.org --include-dependencies
|
||||
|
||||
# $ SITE="http://myusername:p4ssw0rd@mytracksinstallation.com" irb -r tracks_api_wrapper.rb
|
||||
#
|
||||
#
|
||||
# >> my_pc = Tracks::Context.find(:first)
|
||||
# => #<Tracks::Context:0x139c3c0 @prefix_options={}, @attributes={"name"=>"my pc", "updated_at"=>Mon Aug 13 02:56:18 UTC 2007, "hide"=>0, "id"=>8, "position"=>1, "created_at"=>Wed Feb 28 07:07:28 UTC 2007}
|
||||
# >> my_pc.name
|
||||
|
|
@ -35,26 +35,24 @@ require 'activeresource'
|
|||
# http://blog.pepperdust.org/2007/2/13/enabling-wire-level-debug-output-for-activeresource
|
||||
|
||||
module Tracks
|
||||
|
||||
class Base < ActiveResource::Base
|
||||
self.site = ENV["SITE"] || "http://username:password@localhost:3000/"
|
||||
end
|
||||
|
||||
|
||||
class Todo < Base
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Context < Base
|
||||
def todos
|
||||
return attributes["todos"] if attributes.keys.include?("todos")
|
||||
return Todo.find(:all, :params => {:context_id => id})
|
||||
end
|
||||
return Todo.find(:all, :params => { :context_id => id })
|
||||
end
|
||||
end
|
||||
|
||||
class Project < Base
|
||||
def todos
|
||||
return attributes["todos"] if attributes.keys.include?("todos")
|
||||
return Todo.find(:all, :params => {:project_id => id})
|
||||
end
|
||||
return Todo.find(:all, :params => { :project_id => id })
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@ require 'net/https'
|
|||
require File.expand_path(File.dirname(__FILE__) + '/tracks_xml_builder')
|
||||
|
||||
module TracksCli
|
||||
|
||||
class TracksAPI
|
||||
def initialize(options)
|
||||
@options = options
|
||||
@options = options
|
||||
end
|
||||
|
||||
def get_http(uri)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
|
||||
if uri.scheme == "https" # enable SSL/TLS
|
||||
# Enable SSL/TLS
|
||||
if uri.scheme == "https"
|
||||
http.use_ssl = true
|
||||
http.ca_path = "/etc/ssl/certs/" # Debian based path
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
||||
|
|
@ -57,7 +57,5 @@ module TracksCli
|
|||
def get_context(context_id)
|
||||
get(context_uri_for(context_id))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
require 'active_support/time_with_zone'
|
||||
|
||||
module TracksCli
|
||||
|
||||
class TracksXmlBuilder
|
||||
|
||||
def xml_for_description(description)
|
||||
"<description>#{description}</description>"
|
||||
end
|
||||
|
|
@ -23,8 +21,8 @@ module TracksCli
|
|||
def xml_for_taglist(taglist)
|
||||
unless taglist.nil?
|
||||
tags = taglist.split(",")
|
||||
if tags.length() > 0
|
||||
tags = tags.collect { |tag| "<tag><name>#{tag.strip}</name></tag>" unless tag.strip.empty?}.join('')
|
||||
if tags.length > 0
|
||||
tags = tags.collect { |tag| "<tag><name>#{tag.strip}</name></tag>" unless tag.strip.empty? }.join('')
|
||||
return "<tags>#{tags}</tags>"
|
||||
end
|
||||
else
|
||||
|
|
@ -61,6 +59,5 @@ module TracksCli
|
|||
def build_project_xml(project)
|
||||
"<project><name>#{project[:description]}</name><default-context-id>#{project[:default_context_id]}</default-context-id></project>"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class TemplateParser
|
|||
line = replace_tokens_in line
|
||||
|
||||
# line is either todo/dependency or project
|
||||
if (line[0].chr == "." ) || (line[0].chr == "^")
|
||||
if (line[0].chr == ".") || (line[0].chr == "^")
|
||||
if @last_project_id.nil?
|
||||
puts "Warning: no project specified for task \"#{line}\". Using default project."
|
||||
end
|
||||
|
|
@ -153,7 +153,8 @@ class TemplatePoster
|
|||
password: ENV['GTD_PASSWORD'],
|
||||
projects_uri: ENV['GTD_PROJECTS_URL'] || 'http://localhost:3000/projects.xml',
|
||||
contexts_uri: ENV['GTD_CONTEXT_URL'] || 'http://localhost:3000/contexts.xml',
|
||||
context_prefix: ENV['GTD_CONTEXT_URL_PREFIX'] || 'http://localhost:3000/contexts/'})
|
||||
context_prefix: ENV['GTD_CONTEXT_URL_PREFIX'] || 'http://localhost:3000/contexts/'
|
||||
})
|
||||
@context_id = options[:context_id] ? options[:context_id].to_i : 1
|
||||
@project_id = options[:project_id] ? options[:project_id].to_i : 1
|
||||
end
|
||||
|
|
@ -265,7 +266,7 @@ class ConsoleOptionsForTemplate
|
|||
@parser.parse!(args)
|
||||
@poster = TemplatePoster.new(@options)
|
||||
|
||||
if !@filename.nil? and not File.exist?(@filename)
|
||||
if !@filename.nil? && not File.exist?(@filename)
|
||||
puts "ERROR: file #{@filename} doesn't exist"
|
||||
exit 1
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue