Class: Redsync

Inherits:
Object
  • Object
show all
Defined in:
lib/redsync.rb,
lib/redsync/cli.rb,
lib/redsync/wiki.rb,
lib/redsync/project.rb,
lib/redsync/sync_stat.rb,
lib/redsync/wiki_page.rb,
lib/redsync/local_wiki.rb,
lib/redsync/remote_wiki.rb

Defined Under Namespace

Classes: CLI, LocalWiki, Project, RemoteWiki, SyncStat, Wiki, WikiPage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Redsync

Valid options:

:url => Redmine's base URL. Required.
:projects => List of target projects. Required.
:username => Redmine username. Required.
:password => Redmine password. Required.
:data_dir => Directory to read/write. Required.
:extension => Filename extensions. Defaults to "txt"


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/redsync.rb', line 29

def initialize(options)
  @projects = options[:projects].map do |pj|
    Project.new(
      :url => options[:url].sub(/^(.*?)\/?$/, '\1') + "/projects/#{pj}/wiki",
      :api_key => options[:api_key],
      :data_dir => File.join(options[:data_dir], pj),
      :extension => options[:extension]
    )
  end

  @agent = Mechanize.new
end

Instance Attribute Details

#data_dirObject (readonly)

Returns the value of attribute data_dir.



15
16
17
# File 'lib/redsync.rb', line 15

def data_dir
  @data_dir
end

#extensionObject (readonly)

Returns the value of attribute extension.



15
16
17
# File 'lib/redsync.rb', line 15

def extension
  @extension
end

#projectsObject (readonly)

Returns the value of attribute projects.



15
16
17
# File 'lib/redsync.rb', line 15

def projects
  @projects
end

#urlObject (readonly)

Returns the value of attribute url.



15
16
17
# File 'lib/redsync.rb', line 15

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



15
16
17
# File 'lib/redsync.rb', line 15

def username
  @username
end

#wikisObject (readonly)

Returns the value of attribute wikis.



15
16
17
# File 'lib/redsync.rb', line 15

def wikis
  @wikis
end

Instance Method Details

#interactiveObject



57
58
59
# File 'lib/redsync.rb', line 57

def interactive
  binding.pry
end

#status_checkObject



43
44
45
46
47
# File 'lib/redsync.rb', line 43

def status_check
  @projects.each do |pj|
    pj.status_check
  end
end

#sync_allObject



50
51
52
53
54
# File 'lib/redsync.rb', line 50

def sync_all
  @projects.each do |pj|
    pj.sync
  end
end

#to_sObject



62
63
64
65
66
67
68
69
70
# File 'lib/redsync.rb', line 62

def to_s
  str = "#<Redsync"
  str << " url = \"#{@url}\"\n"
  str << " username = \"#{@username}\"\n"
  str << " projects = \"#{@projects}\"\n"
  str << " data_dir = \"#{@data_dir}\"\n"
  str << " extension = \"#{@extension}\"\n"
  str << ">"
end