forward-calendar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e19c788be0b8a9f2315cb0cb880fd3ef18cf553a
4
+ data.tar.gz: 60044f8927eeadfff3f4bf658588e14c91a4745d
5
+ SHA512:
6
+ metadata.gz: 323346552d3b5fcb5886a6cdf65f7369d7bb3e172c6a8561990e9611a39df063900702cd1ea62f8c6844cb0192823b8bdec4bb6ac579ef86e12f481663e29c66
7
+ data.tar.gz: 518f6433307a73959b4cb18fff4fa43c895d3537934c7088bb29683971dd320f7783e836eadacc7af02e58d24404562b1092d99cb9386d95935f13a8cd4250c4
@@ -0,0 +1,3 @@
1
+ .byebug_history
2
+ *.gem
3
+ *.bak
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format documentation
@@ -0,0 +1,15 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+ Metrics/ClassLength:
4
+ Max: 120
5
+ Metrics/LineLength:
6
+ Max: 120
7
+ Metrics/AbcSize:
8
+ Max: 18
9
+ AllCops:
10
+ TargetRubyVersion: 2.3
11
+ DisplayCopNames: true
12
+ DisplayStyleGuide: true
13
+ Exclude:
14
+ - 'spec/**/*'
15
+ - 'vendor/**/*'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ gemspec
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ forward-calendar (0.0.0)
5
+ activesupport (>= 4.0.0)
6
+ nokogiri (~> 1.5)
7
+ nokogiri-happymapper (~> 0.6.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (5.1.4)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (~> 0.7)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ addressable (2.5.2)
18
+ public_suffix (>= 2.0.2, < 4.0)
19
+ ansi (1.5.0)
20
+ ast (2.3.0)
21
+ byebug (9.1.0)
22
+ concurrent-ruby (1.0.5)
23
+ crack (0.4.3)
24
+ safe_yaml (~> 1.0.0)
25
+ diff-lcs (1.3)
26
+ docile (1.1.5)
27
+ hashdiff (0.3.7)
28
+ hirb (0.7.3)
29
+ i18n (0.8.6)
30
+ json (2.1.0)
31
+ mini_portile2 (2.3.0)
32
+ minitest (5.10.1)
33
+ nokogiri (1.8.1)
34
+ mini_portile2 (~> 2.3.0)
35
+ nokogiri-happymapper (0.6.0)
36
+ nokogiri (~> 1.5)
37
+ parser (2.4.0.2)
38
+ ast (~> 2.3)
39
+ powerpack (0.1.1)
40
+ public_suffix (3.0.1)
41
+ rainbow (2.2.2)
42
+ rake
43
+ rake (11.3.0)
44
+ rspec (3.7.0)
45
+ rspec-core (~> 3.7.0)
46
+ rspec-expectations (~> 3.7.0)
47
+ rspec-mocks (~> 3.7.0)
48
+ rspec-core (3.7.0)
49
+ rspec-support (~> 3.7.0)
50
+ rspec-expectations (3.7.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.7.0)
53
+ rspec-mocks (3.7.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.7.0)
56
+ rspec-support (3.7.0)
57
+ rubocop (0.45.0)
58
+ parser (>= 2.3.1.1, < 3.0)
59
+ powerpack (~> 0.1)
60
+ rainbow (>= 1.99.1, < 3.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (~> 1.0, >= 1.0.1)
63
+ ruby-progressbar (1.9.0)
64
+ safe_yaml (1.0.4)
65
+ simplecov (0.15.1)
66
+ docile (~> 1.1.0)
67
+ json (>= 1.8, < 3)
68
+ simplecov-html (~> 0.10.0)
69
+ simplecov-console (0.4.2)
70
+ ansi
71
+ hirb
72
+ simplecov
73
+ simplecov-html (0.10.2)
74
+ thread_safe (0.3.6)
75
+ tzinfo (1.2.3)
76
+ thread_safe (~> 0.1)
77
+ unicode-display_width (1.3.0)
78
+ webmock (3.0.1)
79
+ addressable (>= 2.3.6)
80
+ crack (>= 0.3.2)
81
+ hashdiff
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ bundler (~> 1.12)
88
+ byebug
89
+ forward-calendar!
90
+ rake (~> 11.3)
91
+ rspec (~> 3.6)
92
+ rubocop (~> 0.45.0)
93
+ simplecov
94
+ simplecov-console
95
+ webmock (~> 3.0.1)
96
+
97
+ BUNDLED WITH
98
+ 1.14.6
@@ -0,0 +1,31 @@
1
+ # ONEAccess Forward Calendar Parser for Ruby
2
+ This is a Ruby gem to Parse ONEAccess Forward Calendar XML files.
3
+
4
+ ## Installation & Setup
5
+ Install the gem directly:
6
+ ```
7
+ gem install forward_calendar
8
+ ```
9
+
10
+ or add it to your `Gemfile`:
11
+ ```
12
+ gem 'forward_calendar'
13
+ ```
14
+
15
+ ## Tests
16
+ The tests are written in RSpec. Run the `rspec` in the root directory of the project.
17
+ A coverage report is automatically generated and stored under `/coverage`.
18
+
19
+
20
+ ## Usage
21
+ Basic usage:
22
+
23
+ ```ruby
24
+ require 'rixml'
25
+
26
+ #parse from file
27
+ forward_calendar = ForwardCalendar.parse_from_file('./path/to/forward_calendar.xml')
28
+
29
+ #parse from string
30
+ forward_calendar = ForwardCalendar.parse('<xml></xml>')
31
+ ```
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
8
+ desc 'Run tests'
9
+
10
+ task default: :test
@@ -0,0 +1,8 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.3.3
4
+ test:
5
+ override:
6
+ - bundle exec rspec
7
+ post:
8
+ - bundle exec rubocop
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'forward-calendar'
5
+ s.version = '0.0.1'
6
+ s.date = '2017-11-22'
7
+ s.summary = 'Forward Calendar XML parser'
8
+ s.description = 'Parser for Forward Calendar XML files'
9
+ s.homepage = 'https://github.com/AlphaExchange/forward-calendar-rb'
10
+ s.authors = ['João Simões']
11
+ s.email = ['joao.simoes@visible-alpha.com']
12
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
13
+ s.require_paths = ['lib']
14
+ s.license = 'MIT'
15
+
16
+ s.required_ruby_version = '>= 2.2.2'
17
+
18
+ s.add_development_dependency 'bundler', '~> 1.12'
19
+ s.add_development_dependency 'rspec', '~> 3.6'
20
+ s.add_development_dependency 'rake', '~> 11.3'
21
+ s.add_development_dependency 'rubocop', '~> 0.45.0'
22
+ s.add_development_dependency 'webmock', '~> 3.0.1'
23
+ s.add_development_dependency 'simplecov'
24
+ s.add_development_dependency 'simplecov-console'
25
+ s.add_development_dependency 'byebug'
26
+
27
+ s.add_runtime_dependency 'nokogiri', '~> 1.5'
28
+ s.add_runtime_dependency 'activesupport', '>= 4.0.0'
29
+ s.add_runtime_dependency 'nokogiri-happymapper', '~> 0.6.0'
30
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './forward_calendar/forward_calendar'
4
+
5
+ module ForwardCalendar
6
+ def self.parse(xml)
7
+ ForwardCalendar.parse(xml)
8
+ end
9
+
10
+ def self.parse_from_file(filename)
11
+ xml = File.read(filename)
12
+ parse(xml)
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'happymapper'
4
+ require_relative './node'
5
+ require_relative './updated'
6
+
7
+ module ForwardCalendar
8
+ class ForwardCalendar < Node
9
+ include HappyMapper
10
+ tag 'forwardcalendar'
11
+
12
+ has_one :updated, Updated, tag: 'updated', xpath: './'
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+ module ForwardCalendar
3
+ class Node
4
+ def to_hash
5
+ hash = {}
6
+ attributes = self.class.instance_variable_get(:@attributes)
7
+ elements = self.class.instance_variable_get(:@elements)
8
+ content = retrieve_content_tag
9
+ (attributes.to_a + elements.to_a + content.to_a).each do |k, _|
10
+ value = send(k)
11
+ hash[k] = serialize_attribute(value)
12
+ end
13
+ hash
14
+ end
15
+
16
+ private
17
+
18
+ def retrieve_content_tag
19
+ content = self.class.instance_variable_get(:@content)
20
+ return {} if content.nil?
21
+ { content.name.to_sym => content }
22
+ end
23
+
24
+ def serialize_attribute(attribute)
25
+ if attribute.is_a?(Array)
26
+ attribute.map { |a| serialize_attribute(a) }
27
+ elsif attribute.respond_to?(:to_hash)
28
+ attribute.to_hash
29
+ else
30
+ attribute
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'happymapper'
4
+ require_relative './node'
5
+
6
+ module ForwardCalendar
7
+ class Updated < Node
8
+ include HappyMapper
9
+ tag 'updated'
10
+
11
+ element :datetime, Time, tag: 'datetime'
12
+ element :timezone, String, tag: 'timezone'
13
+ end
14
+ end
data/release ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ cp forward_calendar.gemspec forward_calendar.gemspec.backup
3
+ sed -i.bak s/0.0.0/$1/g forward_calendar.gemspec
4
+ sed -i.bak s/2001-01-01/`date +%Y-%m-%d`/g forward_calendar.gemspec
5
+ gem build forward_calendar.gemspec
6
+ mv forward_calendar.gemspec.backup forward_calendar.gemspec
7
+ gem push forward_calendar-$1.gem
8
+ git tag -a v$1 -m "Release v$1"
9
+ git push origin --tags
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forward-calendar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - João Simões
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.45.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.45.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-console
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: nokogiri
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.5'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.5'
139
+ - !ruby/object:Gem::Dependency
140
+ name: activesupport
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 4.0.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 4.0.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: nokogiri-happymapper
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.6.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.6.0
167
+ description: Parser for Forward Calendar XML files
168
+ email:
169
+ - joao.simoes@visible-alpha.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".rubocop.yml"
177
+ - Gemfile
178
+ - Gemfile.lock
179
+ - README.md
180
+ - Rakefile
181
+ - circle.yml
182
+ - forward_calendar.gemspec
183
+ - lib/forward_calendar.rb
184
+ - lib/forward_calendar/forward_calendar.rb
185
+ - lib/forward_calendar/node.rb
186
+ - lib/forward_calendar/updated.rb
187
+ - release
188
+ homepage: https://github.com/AlphaExchange/forward-calendar-rb
189
+ licenses:
190
+ - MIT
191
+ metadata: {}
192
+ post_install_message:
193
+ rdoc_options: []
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 2.2.2
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ requirements: []
207
+ rubyforge_project:
208
+ rubygems_version: 2.5.1
209
+ signing_key:
210
+ specification_version: 4
211
+ summary: Forward Calendar XML parser
212
+ test_files: []