ludo-roart 0.1.16 → 0.1.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/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ announcement.txt
3
+ coverage
4
+ doc
5
+ pkg
6
+ *.gem
7
+ **/.DS_Store
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ludo-roart (0.1.10)
4
+ ludo-roart (0.1.16)
5
5
  activesupport (>= 2.0.0)
6
6
  mechanize (>= 1.0.0)
7
7
 
@@ -9,16 +9,10 @@ GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
11
  activesupport (3.0.12)
12
- bones (3.8.0)
13
- little-plugger (~> 1.1.3)
14
- loquacious (~> 1.9.1)
15
- rake (>= 0.8.7)
16
12
  diff-lcs (1.1.3)
17
13
  domain_name (0.5.2)
18
14
  unf (~> 0.0.3)
19
15
  i18n (0.6.0)
20
- little-plugger (1.1.3)
21
- loquacious (1.9.1)
22
16
  mechanize (2.3)
23
17
  domain_name (~> 0.5, >= 0.5.1)
24
18
  mime-types (~> 1.17, >= 1.17.2)
@@ -29,10 +23,9 @@ GEM
29
23
  webrobots (~> 0.0, >= 0.0.9)
30
24
  mime-types (1.18)
31
25
  net-http-digest_auth (1.2)
32
- net-http-persistent (2.5.2)
26
+ net-http-persistent (2.6)
33
27
  nokogiri (1.5.2)
34
28
  ntlm-http (0.1.1)
35
- rake (0.9.2.2)
36
29
  rspec (2.8.0)
37
30
  rspec-core (~> 2.8.0)
38
31
  rspec-expectations (~> 2.8.0)
@@ -51,7 +44,6 @@ PLATFORMS
51
44
 
52
45
  DEPENDENCIES
53
46
  activesupport (= 3.0.12)
54
- bones (>= 2.5.1)
55
47
  i18n
56
48
  ludo-roart!
57
49
  rspec (= 2.8.0)
data/Rakefile CHANGED
@@ -1,35 +1,10 @@
1
- # Look in the tasks/setup.rb file for the various options that can be
2
- # configured in this Rakefile. The .rake files in the tasks directory
3
- # are where the options are used.
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
4
 
5
- begin
6
- require 'bones'
7
- Bones.setup
8
- rescue LoadError
9
- begin
10
- load 'tasks/setup.rb'
11
- rescue LoadError
12
- raise RuntimeError, '### please install the "bones" gem ###'
13
- end
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.rspec_opts = '-c -f progress'
14
8
  end
15
9
 
16
- ensure_in_path 'lib'
17
- require 'roart'
18
-
19
- task :default => 'spec:run'
20
-
21
- PROJ.name = 'roart'
22
- PROJ.ignore_file = '.gitignore'
23
- PROJ.authors = 'PJ Davis'
24
- PROJ.email = 'pj.davis@gmail.com'
25
- PROJ.url = 'http://github.com/pjdavis/roart'
26
- PROJ.version = Roart::VERSION
27
- PROJ.rubyforge.name = 'roart'
28
- PROJ.exclude = %w(.git pkg coverage)
29
- PROJ.description = "Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord."
30
- PROJ.rdoc.main = 'README.rdoc'
31
- depend_on 'mechanize' #this will go away when a stdlib adapter gets written
32
-
33
- PROJ.spec.opts << '--color'
34
-
35
- # EOF
10
+ task :default => 'spec'
data/lib/roart/ticket.rb CHANGED
@@ -307,7 +307,6 @@ module Roart
307
307
  page = page.split("\n")
308
308
  status = page.delete_at(0)
309
309
  if status.include?("200")
310
- page.delete_if{|x| !x.include?(":")}
311
310
  page
312
311
  else
313
312
  raise TicketSystemInterfaceError, "Error Getting Ticket: #{status}"
@@ -4,23 +4,43 @@ module Roart
4
4
 
5
5
  IntKeys = %w[id]
6
6
 
7
+ CUSTOM_FIELD_REGEXP = /^(?!\s)(?:CF-([^:.]+)|CF\.\{([^}^:.]+)\}):(.*)$/.freeze
8
+
9
+ REGULAR_FIELD_REGEXP = /^(?!\s)([^:.]+):(.*)$/.freeze
10
+
7
11
  def to_hash
8
12
  hash = HashWithIndifferentAccess.new
9
- self.delete_if{|x| !x.include?(":")}
13
+
10
14
  return false if self.size == 0
11
- self.each do |ln|
12
- ln = ln.split(":")
13
- key = nil
14
- if ln[0] && ln[0].match(/^CF-.+/)
15
- key = ln.delete_at(0)
16
- key = "cf_" + key[3..key.length].gsub(/ /, "_")
15
+
16
+ current_key = nil
17
+
18
+ self.each do |line|
19
+ case line
20
+ when CUSTOM_FIELD_REGEXP
21
+ data = $3
22
+ current_key = "cf_#{($1 || $2)}".gsub(/ /, '_')
23
+ when REGULAR_FIELD_REGEXP
24
+ data = $2
25
+ current_key = $1.strip.underscore
17
26
  else
18
- key = ln.delete_at(0).strip.underscore
27
+ data = line
28
+ end
29
+
30
+ if current_key
31
+ hash[current_key] ||= ""
32
+ hash[current_key] << data << "\n"
19
33
  end
20
- value = ln.join(":").strip
21
- hash[key] = value if key
22
34
  end
35
+
36
+ return false if hash.empty?
37
+
38
+ # strip values
39
+ hash.each { |k, v| hash[k].strip! if hash[k] }
40
+
41
+ # id is integer
23
42
  hash["id"] = hash["id"].split("/").last.to_i
43
+
24
44
  hash
25
45
  end
26
46
 
@@ -75,4 +95,4 @@ module Roart
75
95
 
76
96
  end
77
97
 
78
- end
98
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["PJ Davis", "Andriy Yanko"]
5
+ gem.email = ["pj.davis@gmail.com", "andriy.yanko@gmail.com"]
6
+ gem.description = %q{Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.}
7
+ gem.summary = %q{Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord}
8
+ gem.homepage = "https://github.com/ludo/roart"
9
+
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "ludo-roart"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = "0.1.17"
16
+
17
+ gem.add_runtime_dependency "mechanize", ">= 1.0.0"
18
+ gem.add_runtime_dependency "activesupport", ">= 2.0.0"
19
+ end
@@ -1,9 +1,9 @@
1
- require File.join(File.dirname(__FILE__), %w[ .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'ticket page' do
4
-
4
+
5
5
  describe 'ticket hash' do
6
-
6
+
7
7
  it 'should convert an array to a hash' do
8
8
  array = ["id : 10", "subject : asdf"]
9
9
  array.extend(Roart::TicketPage)
@@ -12,82 +12,117 @@ describe 'ticket page' do
12
12
  hash[:id].should == 10
13
13
  hash[:subject].should == 'asdf'
14
14
  end
15
-
15
+
16
16
  end
17
17
 
18
- describe 'reading a ticket' do
19
-
20
- before do
21
- @page = File.open(File.join(File.dirname(__FILE__), %w[ .. test_data ticket.txt])).readlines.join
22
- @page = @page.split("\n")
18
+ describe 'reading a ticket' do
19
+
20
+ before do
21
+ @page = File.open(File.join(File.dirname(__FILE__), %w[ .. test_data ticket.txt])).readlines.join
22
+ @page = @page.split("\n")
23
23
  @page.extend(Roart::TicketPage)
24
- end
25
-
26
- it 'should include custom fields' do
27
- @page.to_hash[:cf_BTN].should == '1035328269'
28
- end
29
-
30
- it 'should be a hash' do
31
- @page.to_hash.class.should == HashWithIndifferentAccess
32
- end
33
-
34
- end
35
-
24
+ end
25
+
26
+ subject { @page.to_hash }
27
+
28
+ it 'should be a hash' do
29
+ subject.class.should == HashWithIndifferentAccess
30
+ end
31
+
32
+ it 'should include id' do
33
+ subject[:id].should == 358171
34
+ end
35
+
36
+ it 'should include regular fields' do
37
+ subject[:subject].should == 'MyQueue - some_guy - 1035328269 - DSL Modem Reset ESCALATED'
38
+ end
39
+
40
+ it 'should include custom fields with old format' do
41
+ subject[:cf_BTN].should == '1035328269'
42
+ end
43
+
44
+ it 'should include custom fields with new format' do
45
+ subject[:cf_NEW_BTN].should == '2035328269'
46
+ end
47
+
48
+ it 'should properly build old formatted custom fields with multiple line value' do
49
+ subject['cf_Contact_Source'].should == (<<-DATA).strip
50
+ <contact-info>
51
+ <name>Jane Smith</name>
52
+ <company>AT&amp;T</company>
53
+ <phone>(212) 555-4567</phone>
54
+ </contact-info>
55
+ DATA
56
+ end
57
+
58
+ it 'should properly build new formatted custom fields with multiple line value' do
59
+ subject['cf_Feed_Source'].should == (<<-DATA).strip
60
+ <item>
61
+ <title>Example entry</title>
62
+ <description>Here is some text containing an interesting description.</description>
63
+ <link>http://www.wikipedia.org/</link>
64
+ <guid>unique string per item</guid>
65
+ <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
66
+ </item>
67
+ DATA
68
+ end
69
+ end
70
+
36
71
  describe 'search array' do
37
-
72
+
38
73
  before do
39
74
  @array = ["123 : Subject", "234 : Subject"]
40
75
  @array.extend(Roart::TicketPage)
41
76
  @array = @array.to_search_array
42
77
  end
43
-
78
+
44
79
  it 'should make an array of search results' do
45
80
  @array.size.should == 2
46
81
  end
47
-
82
+
48
83
  it 'should put search elements into the search array' do
49
84
  @array.first[:id].should == 123
50
85
  @array.last[:id].should == 234
51
86
  end
52
-
87
+
53
88
  end
54
89
 
55
- describe "search list array" do
56
- before do
57
- @array = [['id:234', 'subject:SomeTicket', ], ['id:432','subject:Another']]
90
+ describe "search list array" do
91
+ before do
92
+ @array = [['id:234', 'subject:SomeTicket', ], ['id:432','subject:Another']]
58
93
  @array.extend(Roart::TicketPage)
59
94
  @array = @array.to_search_list_array
60
- end
61
-
62
- it "should return an array of hashes" do
63
- @array.first.class.should == HashWithIndifferentAccess
64
- end
65
-
66
- it "should put the search elements into the array" do
67
- @array.first[:id].should == 234
68
- end
69
- end
70
-
95
+ end
96
+
97
+ it "should return an array of hashes" do
98
+ @array.first.class.should == HashWithIndifferentAccess
99
+ end
100
+
101
+ it "should put the search elements into the array" do
102
+ @array.first[:id].should == 234
103
+ end
104
+ end
105
+
71
106
  describe 'ticket history hash' do
72
-
107
+
73
108
  before do
74
109
  @page = File.open(File.join(File.dirname(__FILE__), %w[ .. test_data single_history.txt])).readlines.join
75
110
  @page = @page.split("\n")
76
111
  @page.extend(Roart::TicketPage)
77
112
  end
78
-
113
+
79
114
  it 'should give back the hash of history' do
80
115
  @page.to_history_hash.class.should == HashWithIndifferentAccess
81
116
  end
82
-
117
+
83
118
  it 'should have some content' do
84
- @page.to_history_hash[:content].should_not be_nil
119
+ @page.to_history_hash[:content].should == "Now you can get big real fast at an affordable price\nhttp://www.lameppe.com/"
85
120
  end
86
-
121
+
87
122
  it 'should have the create type' do
88
123
  @page.to_history_hash[:type].should == 'Create'
89
124
  end
90
-
125
+
91
126
  end
92
-
93
- end
127
+
128
+ end
@@ -60,9 +60,9 @@ describe "Ticket" do
60
60
  end
61
61
 
62
62
  it 'should give back an array of strings' do
63
- connection = mock('connection', :get => "200 OK\n23:SomeTicket\n33:Another")
63
+ connection = mock('connection', :get => "200 OK\n23:SomeTicket\n33:Another\nMultilineValue")
64
64
  Roart::Ticket.should_receive(:connection).and_return(connection)
65
- Roart::Ticket.send(:page_array, 'uri').should == ['23:SomeTicket', '33:Another']
65
+ Roart::Ticket.send(:page_array, 'uri').should == ['23:SomeTicket', '33:Another', 'MultilineValue']
66
66
  end
67
67
 
68
68
  end
@@ -29,3 +29,18 @@ CF-Contact Name: some_guy
29
29
  CF-Contact Phone:
30
30
  CF-CMSID:
31
31
  CF-IssueCategory: DSL - Modem/Router Config
32
+
33
+ CF-Contact Source: <contact-info>
34
+ <name>Jane Smith</name>
35
+ <company>AT&amp;T</company>
36
+ <phone>(212) 555-4567</phone>
37
+ </contact-info>
38
+
39
+ CF.{NEW BTN}: 2035328269
40
+ CF.{Feed Source}: <item>
41
+ <title>Example entry</title>
42
+ <description>Here is some text containing an interesting description.</description>
43
+ <link>http://www.wikipedia.org/</link>
44
+ <guid>unique string per item</guid>
45
+ <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
46
+ </item>
metadata CHANGED
@@ -1,21 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ludo-roart
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 16
10
- version: 0.1.16
9
+ - 17
10
+ version: 0.1.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - PJ Davis
14
+ - Andriy Yanko
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-09-15 00:00:00 Z
19
+ date: 2012-04-05 00:00:00 +03:00
20
+ default_executable:
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: mechanize
@@ -49,37 +51,24 @@ dependencies:
49
51
  version: 2.0.0
50
52
  type: :runtime
51
53
  version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: bones
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 25
61
- segments:
62
- - 2
63
- - 5
64
- - 1
65
- version: 2.5.1
66
- type: :development
67
- version_requirements: *id003
68
54
  description: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.
69
- email: pj.davis@gmail.com
55
+ email:
56
+ - pj.davis@gmail.com
57
+ - andriy.yanko@gmail.com
70
58
  executables: []
71
59
 
72
60
  extensions: []
73
61
 
74
- extra_rdoc_files:
75
- - spec/test_data/full_history.txt
76
- - spec/test_data/lorem.txt
77
- - spec/test_data/search_ticket.txt
78
- - spec/test_data/single_history.txt
79
- - spec/test_data/ticket.txt
62
+ extra_rdoc_files: []
63
+
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - Gemfile.lock
80
68
  - History.txt
81
69
  - README.rdoc
82
- files:
70
+ - Rakefile
71
+ - lib/roart.rb
83
72
  - lib/roart/attachment.rb
84
73
  - lib/roart/callbacks.rb
85
74
  - lib/roart/connection.rb
@@ -93,7 +82,7 @@ files:
93
82
  - lib/roart/ticket.rb
94
83
  - lib/roart/ticket_page.rb
95
84
  - lib/roart/validations.rb
96
- - lib/roart.rb
85
+ - ludo-roart.gemspec
97
86
  - spec/roart/attachment_spec.rb
98
87
  - spec/roart/callbacks_spec.rb
99
88
  - spec/roart/connection_adapter_spec.rb
@@ -112,19 +101,13 @@ files:
112
101
  - spec/test_data/search_ticket.txt
113
102
  - spec/test_data/single_history.txt
114
103
  - spec/test_data/ticket.txt
115
- - Gemfile
116
- - Gemfile.lock
117
- - History.txt
118
- - Rakefile
119
- - README.rdoc
120
- - roart.gemspec
121
- homepage: http://github.com/pjdavis/roart
104
+ has_rdoc: true
105
+ homepage: https://github.com/ludo/roart
122
106
  licenses: []
123
107
 
124
108
  post_install_message:
125
- rdoc_options:
126
- - --main
127
- - README.rdoc
109
+ rdoc_options: []
110
+
128
111
  require_paths:
129
112
  - lib
130
113
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -147,8 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
130
  version: "0"
148
131
  requirements: []
149
132
 
150
- rubyforge_project: roart
151
- rubygems_version: 1.8.15
133
+ rubyforge_project:
134
+ rubygems_version: 1.5.2
152
135
  signing_key:
153
136
  specification_version: 3
154
137
  summary: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord
data/roart.gemspec DELETED
@@ -1,40 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{ludo-roart}
5
- s.version = "0.1.16"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["PJ Davis"]
9
- s.date = %q{2010-09-15}
10
- s.description = %q{Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.}
11
- s.email = %q{pj.davis@gmail.com}
12
- s.extra_rdoc_files = Dir['{lib,spec}/**/*.txt', "[a-zA-Z]*.txt", "[a-zA-Z]*.rdoc"]
13
- s.files = Dir['{lib,spec}/**/*', "[a-zA-Z]*"]
14
- s.test_files = Dir['spec/**/*']
15
- s.homepage = %q{http://github.com/pjdavis/roart}
16
- s.rdoc_options = ["--main", "README.rdoc"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{roart}
19
- s.rubygems_version = %q{1.3.7}
20
- s.summary = %q{Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord}
21
-
22
- if s.respond_to? :specification_version then
23
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 3
25
-
26
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<mechanize>, [">= 1.0.0"])
28
- s.add_runtime_dependency(%q<activesupport>, [">= 2.0.0"])
29
- s.add_development_dependency(%q<bones>, [">= 2.5.1"])
30
- else
31
- s.add_dependency(%q<mechanize>, [">= 1.0.0"])
32
- s.add_dependency(%q<activesupport>, [">= 2.0.0"])
33
- s.add_dependency(%q<bones>, [">= 2.5.1"])
34
- end
35
- else
36
- s.add_dependency(%q<mechanize>, [">= 1.0.0"])
37
- s.add_dependency(%q<activesupport>, [">= 2.0.0"])
38
- s.add_dependency(%q<bones>, [">= 2.5.1"])
39
- end
40
- end