ruby_teamsite 0.4.7

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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby_teamsite.gemspec
4
+ gemspec
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Bryan A. Crossland
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,102 @@
1
+ = Ruby TeamSite
2
+
3
+ Ruby TeamSite is a gem library for interfacing with Autonomy Interwoven TeamSite
4
+ that is normal done through TeamSite Perl Modules or TeamSite Command Line Tools.
5
+ You will need a licensed copy of Autonomy Interwoven TeamSite in order to use this gem.
6
+
7
+ This gem is currently under development. Not all methods availible in the TeamSite Perl Modules
8
+ or TeamSite Command Line Tools have been built in but will be in future releases. If you have any issues
9
+ or questions about this gem please post them to the Issues section of this gem gitHub page:
10
+ https://github.com/bacrossland/ruby_teamsite
11
+
12
+ == TeamSite Versions
13
+
14
+ Ruby TeamSite has been written only for version 6.7.1 SP1 and greater of TeamSite on Linux and Solaris servers.
15
+ Windows is not supported at this time (manly because I don't have access to a version on Windows).
16
+
17
+ == Ruby and Ruby on Rails Versions
18
+
19
+ Ruby TeamSite will work with Ruby 1.8.7 and greater as well as Rails 2.3.* and Rails 3.0.* and greater.
20
+
21
+ == Installing Ruby TeamSite
22
+
23
+ To install Ruby TeamSite run the following gem command.
24
+
25
+ gem install ruby_teamsite
26
+
27
+ == Documentation
28
+
29
+ Documentation in rdoc form will be added to the next and subsequent releases.
30
+
31
+ == Examples of Use
32
+
33
+ To use this gem you must require it and then create a new object of either TeamSite, WFworkflow, or WFtask.
34
+ WFworkflow and WFtask require a valid TeamSite job id and task id respectively to work. You can not create a blank
35
+ workflow or task by just calling new (this may change in the future). Unlike the TeamSite Perl Modules there is not need to
36
+ refresh or recreate the workflow or task object after executing a method that modifies them (ex: add_file). The results are
37
+ available immediately. For example, if you add or remove files from a task you can then run the files method and see the result.
38
+
39
+ require 'ruby_teamsite'
40
+
41
+ ts = RubyTeamSite::TeamSite.new
42
+
43
+ ts.iwhome # Return the location that TeamSite is installed in.
44
+ ts.version # Return the TeamSite version.
45
+ ts.lock(file_path,comment,[ownerid]) # Have TeamSite lock a file. Comment is required but sending a blank is acceptable.
46
+ ts.unlock(file_path) # Have TeamSite unlock a file.
47
+ ts.file_state(file_path) # Return file state in a hash.
48
+
49
+ wf = RubyTeamSite::WFworkflow.new(job_id)
50
+
51
+ wf.name # Return the name of the workflow.
52
+ wf.id # Return the id of the workflow.
53
+ wf.creator # Return the name of the workflow creator.
54
+ wf.owner # Return the name of the workflow owner.
55
+ wf.description # Return the description of the workflow.
56
+ wf.xml # Return the XML output of the workflow.
57
+ wf.variables # Return a hash of variables for this workflow. The key is the name of the variable and the value is its value.
58
+
59
+ task = RubyTeamSite::WFtask.new(task_id)
60
+
61
+ task.name # Return the name of the task.
62
+ task.id # Return the id of the task.
63
+ task.type # Return the type of the task.
64
+ task.xml # Return the XML output of the task.
65
+ task.areavpath # Return the areavpath of the task.
66
+ task.callback # Callback to the workflow system to transition an external or cgi task.
67
+ task.success([msg]) # Callback with success to the workflow system to transition an external or cgi task to it's success successor. Message for transition is optional.
68
+ task.failure([msg]) # Callback with failure to the workflow system to transition an external or cgi task to it's failure successor. Message for transition is optional.
69
+ task.add_file(file_path,comment) # Add a file to the task. Comment is required but sending a blank is acceptable.
70
+ task.remove_file(file_path) # Remove a file to the task.
71
+ task.files # Return an array of files attached to this task.
72
+
73
+ == Additional Required Libraries
74
+
75
+ Ruby TeamSite relies on Nokogiri for parsing XML of workflows. If you do not have Nokogiri installed it should install
76
+ when you install Ruby TeamSite. Ruby TeamSite uses Nokogiri 1.4.4 or greater. You can learn more about Nokogiri here:
77
+ http://nokogiri.org/
78
+
79
+
80
+ == License
81
+
82
+ Ruby TeamSite is released under the MIT license. A copy of it is provided in the LICENSE.txt file and below.
83
+
84
+ Copyright (C) 2011 by Bryan A. Crossland
85
+
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to deal
88
+ in the Software without restriction, including without limitation the rights
89
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
90
+ copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
101
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
102
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,7 @@
1
+ require 'ruby_teamsite/teamsite.rb'
2
+ require 'ruby_teamsite/wfworkflow.rb'
3
+ require 'ruby_teamsite/wftask.rb'
4
+
5
+ module RubyTeamSite
6
+
7
+ end
@@ -0,0 +1,59 @@
1
+ module RubyTeamSite
2
+ class TeamSite
3
+
4
+ # Initialize the TeamSite class.
5
+ def initialize
6
+ @iw_home = `iwgethome 2>&1`
7
+ @ts_bin = ts_bin
8
+ @ts_ver = `#{@ts_bin}/iwversion 2>&1`
9
+ end
10
+
11
+ # Return the location that TeamSite is installed in.
12
+ def iwhome
13
+ return @iw_home
14
+ end
15
+
16
+ # Return the TeamSite version.
17
+ def version
18
+ return @ts_ver
19
+ end
20
+
21
+ # Have TeamSite lock a file. Comment is required but sending a blank is acceptable.
22
+ def lock(f,comment,ownerid=nil)
23
+ file_lock = `#{@ts_bin}/iwlock #{f} "#{comment}" #{ownerid unless ownerid.nil?} 2>&1`
24
+ return file_lock
25
+ end
26
+
27
+ # Have TeamSite unlock a file.
28
+ def unlock(f)
29
+ file_lock = `#{@ts_bin}/iwunlock #{f} 2>&1`
30
+ return file_lock
31
+ end
32
+
33
+ # Return file state in a hash.
34
+ def file_state(f)
35
+ fstate = `#{ts_bin}/iwfilestate -f script #{f} 2>&1`
36
+ if fstate.include?(':')
37
+ fstate.gsub!(/\n/,'')
38
+ tmp_arr = ['error',fstate]
39
+ fstate_hash = Hash[*tmp_arr.flatten]
40
+ else
41
+ fstate.gsub!(/\n/,':-:')
42
+ fstate.gsub!('=',':-:')
43
+ fstate_arr = fstate.split(":-:")
44
+ fstate_hash = Hash[*fstate_arr.flatten]
45
+ end
46
+
47
+ return fstate_hash
48
+ end
49
+ private
50
+
51
+ # Create the location to the bin directory for TeamSite.
52
+ def ts_bin
53
+ ts_bin = iwhome + '/bin'
54
+ ts_bin.gsub!(/\n/,'')
55
+ ts_bin.strip!
56
+ return ts_bin
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module RubyTeamSite
2
+ VERSION = "0.4.7"
3
+ end
@@ -0,0 +1,128 @@
1
+ begin
2
+ require "nokogiri"
3
+ rescue LoadError
4
+ # Nokogiri is unavailable.
5
+ raise LoadError, "ERROR: Ruby TeamSite could not load nokogiri library. Please install nokogiri gem."
6
+ end
7
+
8
+ module RubyTeamSite
9
+ class WFtask
10
+
11
+ # Initialize the WFtask class by getting the task from the workflow system by ID.
12
+ def initialize(task_id)
13
+ @task_id = task_id.strip
14
+ @ts_bin = ts_bin
15
+ @task = `#{@ts_bin}/iwgetwfobj #{task_id.strip}`
16
+ set_task_info(@task)
17
+ end
18
+
19
+ # Return the name of the task.
20
+ def name
21
+ return @task_name
22
+ end
23
+
24
+ # Return the type of the task.
25
+ def type
26
+ return @task_type
27
+ end
28
+
29
+ # Return the id of the task.
30
+ def id
31
+ return @task_id
32
+ end
33
+
34
+ # Return the XML output of the task.
35
+ def xml
36
+ return @task
37
+ end
38
+
39
+ # Return the areavpath of the task.
40
+ def areavpath
41
+ return @areavpath
42
+ end
43
+
44
+ # Callback to the workflow system to transition an external or cgi task.
45
+ def callback(trans_num, comment=nil)
46
+ # Only do a callback if the task is a cgitask or an externaltask.
47
+ cb = ""
48
+ if @task_type == 'cgitask' || @task_type == 'externaltask'
49
+ cb = `#{@ts_bin}/iwcallback #{@task_id} #{trans_num} "#{comment}" 2>&1`
50
+ end
51
+ return cb
52
+ end
53
+
54
+ # Callback with success to the workflow system to transition an external or cgi task to it's success successor.
55
+ def success(msg=nil)
56
+ callback(0,msg)
57
+ end
58
+
59
+ # Callback with failure to the workflow system to transition an external or cgi task to it's failure successor.
60
+ def failure(msg=nil)
61
+ callback(1,msg)
62
+ end
63
+
64
+ # Add a file to the task. Comment is required but sending a blank is acceptable.
65
+ def add_file(f,comment)
66
+ file_path = "/#{f}"
67
+ addfile = `#{@ts_bin}/iwaddtaskfile #{@task_id} #{file_path} "#{comment}" 2>&1`
68
+ refresh
69
+ return addfile
70
+ end
71
+
72
+ # Remove a file to the task.
73
+ def remove_file(f)
74
+ file_path = "/#{f}"
75
+ rmfile = `#{@ts_bin}/iwrmtaskfile #{@task_id} #{file_path} 2>&1`
76
+ refresh
77
+ return rmfile
78
+ end
79
+
80
+ # Return an array of files attached to this task.
81
+ def files
82
+ tsk = Nokogiri::XML(@task, nil, 'UTF-8')
83
+ elmnt_files = tsk.css('files file')
84
+ files = []
85
+ if elmnt_files.empty? == false
86
+ elmnt_files.each {|f| files << f.attribute('path').to_s}
87
+ end
88
+ return files
89
+ end
90
+
91
+ private
92
+
93
+ # Create the location to the bin directory for TeamSite.
94
+ def ts_bin
95
+ iwhome = `iwgethome`
96
+ ts_bin = iwhome + '/bin'
97
+ ts_bin.gsub!(/\n/,'')
98
+ ts_bin.strip!
99
+ return ts_bin
100
+ end
101
+
102
+ # Set the information for the task.
103
+ def set_task_info(task)
104
+ tsk = Nokogiri::XML(task, nil, 'UTF-8')
105
+
106
+ # Task name
107
+ task_name = tsk.root.attribute('name')
108
+ tname = task_name.to_s
109
+ @task_name = tname.strip
110
+
111
+ # Task type
112
+ task_type = tsk.root.node_name
113
+ ttype = task_type.to_s
114
+ @task_type = ttype.strip
115
+
116
+ # Task areavpath
117
+ areavpath = tsk.css('areavpath').attribute('v')
118
+ avp = areavpath.to_s
119
+ @areavpath = avp.strip
120
+ end
121
+
122
+ # Refreshes the task variables to be current with what the workflow system has
123
+ def refresh
124
+ @task = `#{@ts_bin}/iwgetwfobj #{@task_id}`
125
+ set_task_info(@task)
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,97 @@
1
+ begin
2
+ require "nokogiri"
3
+ rescue LoadError
4
+ # Nokogiri is unavailable.
5
+ raise LoadError, "ERROR: Ruby TeamSite could not load nokogiri library. Please install nokogiri gem."
6
+ end
7
+
8
+ module RubyTeamSite
9
+ class WFworkflow
10
+
11
+ # Initialize the WFworkflow class by getting the workflow from the workflow system by ID.
12
+ def initialize(wf_id)
13
+ @workflow_id = wf_id.strip
14
+ @ts_bin = ts_bin
15
+ @workflow = `#{@ts_bin}/iwgetwfobj #{wf_id.strip}`
16
+ set_wf_info(@workflow)
17
+ end
18
+
19
+ # Return the name of the workflow.
20
+ def name
21
+ return @wf_name
22
+ end
23
+
24
+ # Return the id of the workflow.
25
+ def id
26
+ return @workflow_id
27
+ end
28
+
29
+ # Return the name of the workflow creator.
30
+ def creator
31
+ return @wf_creator
32
+ end
33
+
34
+ # Return the name of the workflow owner.
35
+ def owner
36
+ return @wf_owner
37
+ end
38
+
39
+ # Return the description of the workflow.
40
+ def description
41
+ return @wf_desc
42
+ end
43
+
44
+ # Return the XML output of the workflow.
45
+ def xml
46
+ return @workflow
47
+ end
48
+
49
+ # Return a hash of variables for this workflow. The key is the name of the variable and the value is its value.
50
+ def variables
51
+ wf = Nokogiri::XML(@workflow, nil, 'UTF-8')
52
+ elmnt_vars = wf.css('variables variable')
53
+ wf_vars = Hash.new
54
+ if elmnt_vars.empty? == false
55
+ elmnt_vars.each {|v| wf_vars[v.attribute('key').to_s] = v.attribute('value').to_s}
56
+ end
57
+ return wf_vars
58
+ end
59
+
60
+ private
61
+
62
+ # Create the location to the bin directory for TeamSite.
63
+ def ts_bin
64
+ iwhome = `iwgethome`
65
+ ts_bin = iwhome + '/bin'
66
+ ts_bin.gsub!(/\n/,'')
67
+ ts_bin.strip!
68
+ return ts_bin
69
+ end
70
+
71
+ # Set the information for the workflow.
72
+ def set_wf_info(wf)
73
+ workflow = Nokogiri::XML(wf, nil, 'UTF-8')
74
+
75
+ # Workflow name
76
+ wfname = workflow.root.attribute('name')
77
+ wfn = wfname.to_s
78
+ @wf_name = wfn.strip
79
+
80
+ # Workflow owner
81
+ wfowner = workflow.root.attribute('owner')
82
+ wfo = wfowner.to_s
83
+ @wf_owner = wfo.strip
84
+
85
+ # Workflow creator
86
+ wfcreator = workflow.root.attribute('creator')
87
+ wfc = wfcreator.to_s
88
+ @wf_creator = wfc.strip
89
+
90
+ # Workflow description
91
+ wfdesc = workflow.css('description').text
92
+ wfd = wfdesc.to_s
93
+ @wf_desc = wfd.strip
94
+
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ruby_teamsite/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ruby_teamsite"
7
+ s.version = RubyTeamSite::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Bryan A. Crossland"]
10
+ s.email = ["bacrossland@gmail.com"]
11
+ s.homepage = "https://github.com/bacrossland/ruby_teamsite"
12
+ s.summary = %q{Ruby Gem for accessing and using Autonomy Interwoven TeamSite}
13
+ s.description = %q{This Ruby Gem gives Ruby access to Autonomy Interwoven TeamSite actions normally found in TeamSite Perl Modules or TeamSite CLTs.}
14
+
15
+ s.rubyforge_project = "ruby_teamsite"
16
+ s.license = 'MIT'
17
+
18
+ s.files = Dir.glob("**/**/**")
19
+ s.require_paths = ["lib"]
20
+ s.add_dependency('nokogiri','>= 1.4.4')
21
+
22
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_teamsite
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 7
10
+ version: 0.4.7
11
+ platform: ruby
12
+ authors:
13
+ - Bryan A. Crossland
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-18 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 4
34
+ version: 1.4.4
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: This Ruby Gem gives Ruby access to Autonomy Interwoven TeamSite actions normally found in TeamSite Perl Modules or TeamSite CLTs.
38
+ email:
39
+ - bacrossland@gmail.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - Gemfile
48
+ - lib/ruby_teamsite/teamsite.rb
49
+ - lib/ruby_teamsite/version.rb
50
+ - lib/ruby_teamsite/wftask.rb
51
+ - lib/ruby_teamsite/wfworkflow.rb
52
+ - lib/ruby_teamsite.rb
53
+ - LICENSE.txt
54
+ - Rakefile
55
+ - README
56
+ - ruby_teamsite.gemspec
57
+ has_rdoc: true
58
+ homepage: https://github.com/bacrossland/ruby_teamsite
59
+ licenses:
60
+ - MIT
61
+ post_install_message:
62
+ rdoc_options: []
63
+
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project: ruby_teamsite
87
+ rubygems_version: 1.3.7
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Ruby Gem for accessing and using Autonomy Interwoven TeamSite
91
+ test_files: []
92
+