nevzorov 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01fc947e1ba812590439111b2b750aca50f19883
4
+ data.tar.gz: d868757424bd7976be5f4d0f009431ccb2257745
5
+ SHA512:
6
+ metadata.gz: 1577cd7feb136a714e8521a6a376babd7074d4182d8fac700cc4e80d3ba02231e422bed69e01bebaae00c130d3156e8b86cd49fb602d87a85e7aeaf404927190
7
+ data.tar.gz: ba56695613a3b460062eb1bca27d45dde6028279703547ec13da2e47ac5c84f31ec19d2086f2d35af5154818be5fe40520ef3d8a4800e556788fb249c384ddbb
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ Metrics/LineLength:
2
+ Max: 120
3
+
4
+ Style/Documentation:
5
+ Exclude:
6
+ - 'spec/**/*'
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - 'spec/**/*'
11
+
12
+ Style/TrailingCommaInArguments:
13
+ EnforcedStyleForMultiline: consistent_comma
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nevzorov.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Nevzorov
2
+
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'nevzorov'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ ## Usage
17
+
18
+ ```
19
+ Usage:
20
+ nevzorov podcast FILE
21
+
22
+ Options:
23
+ -u, [--url=URL] # Original podcast URL
24
+ -i, [--image=IMAGE]
25
+ -c, [--categories=CATEGORIES] # Comma separated list of categories. See https://help.apple.com/itc/podcasts_connect/?lang=en#/itc9267a2f12
26
+
27
+ generate and write podcast RSS to the FILE
28
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'nevzorov'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/nevzorov ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'nevzorov'
5
+
6
+ Nevzorov.start
@@ -0,0 +1,39 @@
1
+ require 'net/http'
2
+ require 'nokogiri'
3
+
4
+ class Nevzorov
5
+ # Generates podcast feed
6
+ class Generator
7
+ class << self
8
+ def call(*args)
9
+ new.call(*args)
10
+ end
11
+ end
12
+
13
+ def call(url, image, categories, file)
14
+ source = Net::HTTP.get(URI(url))
15
+ xml = Nokogiri.XML(source)
16
+ replace_image(xml, image)
17
+ add_categories(xml, categories)
18
+
19
+ IO.write(file, xml)
20
+ end
21
+
22
+ def add_categories(feed_xml, names)
23
+ feed_xml.xpath('rss/channel/item/author').each do |item|
24
+ names.each do |name|
25
+ category = Nokogiri::XML::Node.new('itunes:category', feed_xml)
26
+ category['text'] = name
27
+ item.add_next_sibling(category)
28
+ end
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def replace_image(feed_xml, feed_image)
35
+ image_url = feed_xml.at_xpath('rss/channel/image/url')
36
+ image_url.content = feed_image
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ class Nevzorov
3
+ VERSION = '0.1.0'.freeze
4
+ end
data/lib/nevzorov.rb ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'dry/configurable'
3
+ require 'thor'
4
+
5
+ # CLI interface for generation podcast feed
6
+ class Nevzorov < Thor
7
+ extend Dry::Configurable
8
+ autoload :Generator, 'nevzorov/generator'
9
+ autoload :VERSION, 'nevzorov/version'
10
+
11
+ setting :url, 'http://echo.msk.ru/guests/813104-echo/rss-audio.xml'
12
+ setting :image, 'http://bm.img.com.ua/berlin/storage/news/orig/6/43/5845a212da3528b0897d488e9122a436.jpg'
13
+ setting :categories, 'News & Politics,Religion & Spirituality,Society & Culture' do |categories|
14
+ categories.split(',').map(&:strip)
15
+ end
16
+
17
+ desc 'podcast FILE', 'generate and write podcast RSS to the FILE'
18
+ method_option :url, aliases: '-u', desc: 'Original podcast URL'
19
+ method_option :image, aliases: '-i'
20
+ method_option :categories, aliases: '-c', desc: 'Comma separated list of categories. See https://help.apple.com/itc/podcasts_connect/?lang=en#/itc9267a2f12'
21
+
22
+ def podcast(file) # rubocop:disable Metrics/AbcSize
23
+ url = options.fetch(:url, self.class.config.url)
24
+ image = options.fetch(:image, self.class.config.image)
25
+ categories = options.fetch(:categories, self.class.config.categories)
26
+ Generator.call(url, image, categories, file)
27
+ end
28
+ end
data/nevzorov.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nevzorov'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'nevzorov'
8
+ spec.version = Nevzorov::VERSION
9
+ spec.authors = ['Tema Bolshakov']
10
+ spec.email = ['abolshakov@spbtv.com']
11
+
12
+ spec.summary = 'Generates Alexander Nevzorov podcast feed'
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.13'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '3.5.0'
24
+ spec.add_development_dependency 'rubocop', '0.47.1'
25
+ spec.add_runtime_dependency 'dry-configurable', '0.6.0'
26
+ spec.add_runtime_dependency 'nokogiri', '1.7.0.1'
27
+ spec.add_runtime_dependency 'thor', '0.19.4'
28
+ spec.add_runtime_dependency 'vcr', '3.0.3'
29
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nevzorov
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tema Bolshakov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-19 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.5.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.5.0
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.47.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.47.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: dry-configurable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.7.0.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.7.0.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.19.4
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.19.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 3.0.3
125
+ description:
126
+ email:
127
+ - abolshakov@spbtv.com
128
+ executables:
129
+ - nevzorov
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".rubocop.yml"
136
+ - ".travis.yml"
137
+ - Gemfile
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - exe/nevzorov
143
+ - lib/nevzorov.rb
144
+ - lib/nevzorov/generator.rb
145
+ - lib/nevzorov/version.rb
146
+ - nevzorov.gemspec
147
+ homepage:
148
+ licenses: []
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.5.1
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Generates Alexander Nevzorov podcast feed
170
+ test_files: []