otrs-sopm 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2265650b8a30d454e0c1a06e31873e75f45c168b
4
- data.tar.gz: f96228d95f0a98cb3a88cd1968fec04882f7ccc4
3
+ metadata.gz: 91edf1fcda4ff9b663c3225b502c43ed8a8c9df1
4
+ data.tar.gz: e7ecd8115331276d98e2062f604603a2c36a6bcf
5
5
  SHA512:
6
- metadata.gz: dadf68cd3c616ab1160c44bcc24eb7339a53f61709caa03f47a7e381a2a8e0c743fa977984e2ffe903d48388d90a8806775b1ccd1ef06606fc4b3c4ae2ed34a4
7
- data.tar.gz: 09683ea7295d64c279faad5379abd886e9ea6ffb344bfc7be5261ea5bec1b3aa11bf6d5d333e0484484668d4f54cb76dc2fbde87e27fd7c03b7d2796f20ccf95
6
+ metadata.gz: cc8a21b952e7e91001c443224001227c3cfcd9fe5a4f96906e64f04f904c8653b5d53998881dca13ff4748ee0b9260b75add3901e0bcd6f575eb080b40243e96
7
+ data.tar.gz: 0973e8f5392698ca4ce3589b3b53601df23582a72c0f9d1e0ede5f70c95e78a4b0d90a626a1f73b429831c51e64da871c671077c8d00b2735d57e8346dacf82d
data/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 4
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  # Default enabled cops
2
2
  # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
3
3
 
4
+ # Zammad StyleGuide
4
5
  Metrics/LineLength:
5
6
  Description: 'Limit lines to 80 characters.'
6
7
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
@@ -20,8 +21,13 @@ Style/IfUnlessModifier:
20
21
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
21
22
  Enabled: false
22
23
 
23
- Style/TrailingComma:
24
- Description: 'Checks for trailing comma in parameter lists and literals.'
24
+ Style/TrailingCommaInLiteral:
25
+ Description: 'Checks for trailing comma in array and hash literals.'
26
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
27
+ Enabled: false
28
+
29
+ Style/TrailingCommaInArguments:
30
+ Description: 'Checks for trailing comma in argument lists.'
25
31
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
26
32
  Enabled: false
27
33
 
@@ -37,12 +43,6 @@ Style/SpaceAfterMethodName:
37
43
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
38
44
  Enabled: false
39
45
 
40
- Style/SingleSpaceBeforeFirstArg:
41
- Description: >-
42
- Checks that exactly one space is used between a method name
43
- and the first argument for method calls without parentheses.
44
- Enabled: false
45
-
46
46
  Style/LeadingCommentSpace:
47
47
  Description: 'Comments should start with a space.'
48
48
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
@@ -168,12 +168,3 @@ Metrics/CyclomaticComplexity:
168
168
  A complexity metric that is strongly correlated to the number
169
169
  of test cases needed to validate a method.
170
170
  Enabled: false
171
-
172
- Metrics/BlockNesting:
173
- Description: 'Avoid excessive block nesting'
174
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
175
- Enabled: false
176
-
177
- Metrics/ModuleLength:
178
- Description: 'Avoid modules longer than 100 lines of code.'
179
- Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.1.0
5
+ - 1.9.3
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  This gem provides a class to parse, manipulate and store SOPM files and create OPM strings from them.
4
4
 
5
+ Current build state: ![Build Status](https://travis-ci.org/znuny/otrs-sopm.svg?branch=master)
5
6
  ## Installation
6
7
 
7
8
  Add this line to your application's Gemfile:
@@ -23,6 +24,8 @@ Or install it yourself as:
23
24
  First create an instance via passing the location to the .sopm file.
24
25
 
25
26
  ```ruby
27
+ require 'otrs/sopm'
28
+
26
29
  sopm = OTRS::SOPM.new 'path/to/Znuny4OTRS-Package.sopm'
27
30
  ```
28
31
 
@@ -34,6 +37,18 @@ A new version can be created via passing the wanted version number and a changel
34
37
  sopm_hash_structure = sopm.version('1.0.1', 'Created first bug fix.')
35
38
  ```
36
39
 
40
+ ### Delete version
41
+
42
+ A version can be deleted via passing the wanted version number or nothing for deleting the latest. If the current version gets deleted, the version number gets replaced by the previous one if one exisits:
43
+
44
+ ```ruby
45
+ sopm_hash_structure = sopm.version_delete('1.0.1')
46
+
47
+ # or for the latest
48
+
49
+ sopm_hash_structure = sopm.version_delete()
50
+ ```
51
+
37
52
  ### Add build information
38
53
 
39
54
  It's recommended to add the build host and build date to the OPM file. Give the build host as a parameter with to add the build information via:
@@ -94,10 +109,6 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
94
109
 
95
110
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
96
111
 
97
- ## Tests
98
-
99
- The tests are currently in an external project since there is business logic in them. In future releases this tests will be added to this gem repository as it should be.
100
-
101
112
  ## Contributing
102
113
 
103
114
  Bug reports and pull requests are welcome on GitHub at https://github.com/znuny/otrs-sopm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
- task default: :spec
2
+ require 'rake/testtask'
3
+
4
+ task default: :test
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ end
@@ -2,6 +2,6 @@
2
2
  class OTRS
3
3
  # Contains just the version number, bundler / gem default design
4
4
  class SOPM
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'.freeze
6
6
  end
7
7
  end
data/lib/otrs/sopm.rb CHANGED
@@ -32,6 +32,10 @@ class OTRS
32
32
  # @return (see #parse)
33
33
  def version(version, change_log)
34
34
 
35
+ fail ArgumentError, 'Version has to be a string' unless version.is_a? String
36
+ fail ArgumentError, 'Version has to be in the format "1.0.1" for releases or "1.0.1.1" for test releases' unless /\A\d+(?:\.\d+){2,3}\z/ =~ version
37
+ fail ArgumentError, 'Change_log hast to be a string' unless change_log.is_a? String
38
+
35
39
  # change Version
36
40
  @sopm.xpath('/otrs_package/Version').children[0].content = version
37
41
 
@@ -49,7 +53,7 @@ class OTRS
49
53
 
50
54
  new_change_log_entry = Nokogiri::XML::Node.new 'ChangeLog', sopm
51
55
  new_change_log_entry['Version'] = version
52
- new_change_log_entry['Date'] = Time.zone.now
56
+ new_change_log_entry['Date'] = Time.now
53
57
  new_change_log_entry.content = change_log
54
58
 
55
59
  change_log_nodes.first.previous = new_change_log_entry.to_xml + "\n "
@@ -57,11 +61,47 @@ class OTRS
57
61
  store
58
62
  end
59
63
 
64
+ # Removes the given or latest (if no parameter is passed) version and removes the matching changelog from the SOPM file.
65
+ #
66
+ # @param version [String, nil] the version number or nil if the latest should get removed.
67
+ # @return (see #parse)
68
+ def version_delete(version_delete = nil)
69
+
70
+ change_log_nodes = @sopm.xpath('/otrs_package/ChangeLog')
71
+
72
+ if !version_delete || version_delete == @structure['version']
73
+
74
+ new_version = nil
75
+ if change_log_nodes.length > 0
76
+ @sopm.xpath('/otrs_package/ChangeLog').first.remove
77
+ if @sopm.xpath('/otrs_package/ChangeLog').length > 0
78
+ new_version = @sopm.xpath('/otrs_package/ChangeLog').first['Version']
79
+ end
80
+ end
81
+
82
+ @sopm.xpath('/otrs_package/Version').children[0].content = new_version
83
+ elsif change_log_nodes.length > 0
84
+
85
+ change_log_nodes.each { |change_log_node|
86
+
87
+ next if !change_log_node['Version'].is_a? String
88
+ next if change_log_node['Version'] != version_delete
89
+
90
+ change_log_node.remove
91
+
92
+ break
93
+ }
94
+ end
95
+
96
+ store
97
+ end
98
+
60
99
  # Adds the buildhost and builddate to the SOPM file.
61
100
  #
62
101
  # @param build_host [String] build host on which the OPM file was created.
63
102
  # @return (see #parse)
64
103
  def add_build_information(build_host)
104
+ fail ArgumentError, 'Build_host has to be a string' unless build_host.is_a? String
65
105
 
66
106
  # add BuildHost
67
107
  if @sopm.xpath('/otrs_package/BuildHost').children.length == 0
@@ -345,6 +385,10 @@ class OTRS
345
385
  @structure[ 'database_' + block_type ] = []
346
386
  intro_block_nodes.each { |intro_block_node|
347
387
 
388
+ next if !intro_block_node
389
+ next if !intro_block_node.children.is_a?(Array)
390
+ next if intro_block_node.children.empty?
391
+
348
392
  @structure[ 'database_' + block_type ].push intro_block_node.children[0].content
349
393
  }
350
394
  }
data/otrs-sopm.gemspec CHANGED
@@ -16,9 +16,10 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.require_paths = ['lib']
18
18
 
19
- spec.add_runtime_dependency 'nokogiri', '~> 0'
19
+ spec.add_runtime_dependency 'nokogiri'
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.11'
22
- spec.add_development_dependency 'rake', '~> 10.0'
23
- spec.add_development_dependency 'rubocop', '~> 0'
21
+ spec.add_development_dependency 'bundler', '>= 1.6.9'
22
+ spec.add_development_dependency 'rake', '>= 10.0'
23
+ spec.add_development_dependency 'rubocop', '>= 0'
24
+ spec.add_development_dependency 'minitest', '>= 4.7.5'
24
25
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: otrs-sopm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Eckel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.11'
33
+ version: 1.6.9
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.11'
40
+ version: 1.6.9
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 4.7.5
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 4.7.5
69
83
  description:
70
84
  email:
71
85
  - thorsten.eckel@znuny.com
@@ -73,8 +87,10 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - ".editorconfig"
76
91
  - ".gitignore"
77
92
  - ".rubocop.yml"
93
+ - ".travis.yml"
78
94
  - CODE_OF_CONDUCT.md
79
95
  - Gemfile
80
96
  - LICENSE.txt