mymedia-dynarex 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2d9519d8ea0a247936dbd67c89eb23be8266d2b2
4
+ data.tar.gz: 7c80a795d698ff272ef3baa5e6dbf543539cce18
5
+ SHA512:
6
+ metadata.gz: d9ee912b2918c763d78f6796a7d0f1f7c4613b42ca9ac765acc8d38fa2affc36ae2d300c128899dd7cfc6af45078236b36445edfce9fa2e1a5d63201ae46f0c9
7
+ data.tar.gz: 1f43a62bdd3e7217460c3d9a8a1cab7cf1e92a30bb06a3a68565f2901d4ef788fcd5829727d39fd29b75338539ee35fa87068c3f1b8ad5979b13f2b6279a728c
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ |� -8>��3��b5��?��Q]a���������~_p|C)"H0�k�x�� �!XN��.��T��y.������)�Żn O�Ɏ�`T`_}c�ɒ���v�F�W�jم��<\������������\<��f�Z�c�3����(k;=�ʔ}o
2
+ ��-z��?���m @v���d%;=S����-������|m|�h�iB��i(�"��ߋ��q Y��(�4f�Zж��o͎3d0j_�M��h�E&
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: mymedia-dynarex.rb
4
+
5
+ require 'fileutils'
6
+ require 'mymedia'
7
+
8
+
9
+ class MyMediaDynarexException < Exception
10
+ end
11
+
12
+ class MyMediaDynarex < MyMedia::Base
13
+
14
+ def initialize(media_type: 'mmdynarex', public_type: 'dynarex', config: nil)
15
+
16
+ @xsl = '/xsl/dynarex-c.xsl'
17
+ super(media_type: media_type, public_type: @public_type=public_type, config: config)
18
+ @media_src = "%s/media/%s" % [@home, public_type]
19
+ @target_ext = '.xml'
20
+ @rss = true
21
+ end
22
+
23
+ def copy_publish(filename, raw_msg='')
24
+
25
+ src_path = File.join(@media_src, filename)
26
+
27
+ unless File.exists? src_path then
28
+ raise MyMediaDynarexException, "file not found : " + src_path
29
+ end
30
+
31
+ file_publish(src_path, raw_msg) do |destination, raw_destination|
32
+
33
+ if not raw_msg or raw_msg.empty? then
34
+ raw_msg = File.basename(src_path) + " updated: " + Time.now.to_s
35
+ end
36
+
37
+ if File.extname(src_path) == '.txt' then
38
+ dynarex, raw_msg = copy_edit(src_path, destination)
39
+ copy_edit(src_path, raw_destination)
40
+ else
41
+
42
+ dynarex = Dynarex.new(src_path)
43
+ title = dynarex.summary['title'] || ''
44
+ dynarex.summary[:original_source] = File.basename(src_path)
45
+
46
+ dynarex.xslt = '/xsl/dynarex-c.xsl' unless dynarex.xslt
47
+ dynarex.save(destination)
48
+
49
+ end
50
+
51
+ if not File.basename(src_path)[/d\d{6}T\d{4}\.txt/] then
52
+ xml_filename = File.basename(src_path).sub(/txt$/,'xml')
53
+ FileUtils.cp destination, @home + '/dynarex/' + xml_filename
54
+ if File.extname(src_path) == '.txt' then
55
+ FileUtils.cp src_path, @home + '/dynarex/' + File.basename(src_path)
56
+ end
57
+
58
+ dynarex_filepath = @home + '/dynarex/static.xml'
59
+
60
+ if dynarex.type == 'feed' then
61
+ @static_baseurl = "%s/%s/%s/" % [@website, @public_type, \
62
+ File.basename(src_path)[/.*(?=\.\w+$)/]]
63
+ target_url = @static_baseurl + dynarex.records.first.last[:id]
64
+ else
65
+ target_url = "%s/dynarex/%s" % [@website, xml_filename]
66
+ end
67
+
68
+ publish_dynarex(dynarex_filepath, {title: xml_filename, url: target_url })
69
+
70
+ end
71
+
72
+ [raw_msg,target_url]
73
+ end
74
+
75
+ end
76
+
77
+ def copy_edit(src_path, destination, raw='')
78
+ txt_destination = destination.sub(/xml$/,'txt')
79
+ FileUtils.cp src_path, txt_destination
80
+
81
+ dynarex = Dynarex.new
82
+ buffer = File.read(src_path)
83
+
84
+ dynarex.parse(File.read(src_path))
85
+
86
+ title = dynarex.summary[:title]
87
+
88
+ if dynarex.summary['tags'] then
89
+ tags = '#' + dynarex.summary['tags'].split.join(' #')
90
+ else
91
+ tags = ''
92
+ end
93
+
94
+ raw_msg = ("%s %s" % [title, tags]).strip
95
+
96
+ if dynarex.type == 'feed' then
97
+
98
+ h = dynarex.to_h.first
99
+
100
+ if h[:tags] then
101
+ tags = h[:tags].gsub(/\b\w/,'#\0')
102
+ s = h.first.last
103
+ raw_msg = ((s + tags).length > 130 ? s[0..127] + '...' : s) \
104
+ + ' ' + tags
105
+ end
106
+ end
107
+
108
+ dynarex.summary[:original_source] = File.basename(src_path)
109
+ dynarex.summary[:source] = File.basename(txt_destination)
110
+
111
+ dynarex.xslt = @xsl unless dynarex.xslt
112
+ dynarex.save(destination)
113
+
114
+ [dynarex, raw_msg]
115
+ end
116
+
117
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mymedia-dynarex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE0MTIxMDE3MDI0OVoXDTE1MTIxMDE3MDI0OVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBALO8mF81kiosKeZrKgTRjgtoXREJLUPpBE0BvSUwW0obY87UnWj7SOLBcw+s
19
+ 6EuCOaJEdrMn5yD7eHALmiyflHmz+w0vf2cSbsV10n/LmbW0RDt0XepqYbkYEasZ
20
+ 72e9YkRc1y7K404BLdaSNz7o9tDJtvgQM7Et848qWmwVFQa8iWj1sIrPcsAxpqcT
21
+ SJPqerv+BFkFR9QfiqxWrtE/h6YUvF6t85bZW3XiDMZQVzLWtUKhQ19i/6aFTKQq
22
+ BTk+bsKI44D76ftY+L3rTog1s/s2H7gNIF9x4srOjxsUtP6F92lmH80PZyaJrmcg
23
+ FdYpBB48bmWQd0FRW3CfpT9O9V8CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUsApVwsZM+ZOKDfFwzqjqcCaKyqMwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEANPwaqz/K
27
+ HcdwS+mbhoUnRx7TD2WEqFiN4SEogqBzC4uaeCiO7PpEu/esPH+GaV3KDla2X00p
28
+ aYdT+yqDrlT2ILMiPPudMW2pAW5steu/vNC/puMWtxx+oj/CCM4fvjy8PYJ9hUbE
29
+ JfBwfswUN52nEBgiVWh6iS1uExOJF1TFolHF6D7RxoQqVNod0GNregaedr2954Wa
30
+ 3OsVPZ2A/KeIAn161hGU3aa0egllr0bkSTfVqIPyGYJIypch6YMAM2mWizQPECID
31
+ Kvp4vcZbrbtWbd3dbhTZO4vyrKTaYDC5I+bJrqqQS79Ee9i32us9I9vjda5VBbOD
32
+ LxIJBhL6Ema94A==
33
+ -----END CERTIFICATE-----
34
+ date: 2014-12-10 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: mymedia
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.1'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.1'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.1.1
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/mymedia-dynarex.rb
63
+ homepage: https://github.com/jrobertson/mymedia-dynarex
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Publish Dynarex files using the MyMedia gem
87
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ �|��M��JS��l�0̫v���
2
+ �k����`��
3
+ ��S���L *�b�|��� �