ae_rss_maker 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: 760599c2192a49761941e0d7d80d7bd41f7ae5d7
4
+ data.tar.gz: 36d193161945f477dd06603d05d9768adcd02a38
5
+ SHA512:
6
+ metadata.gz: 008fff70b0e62fcae09e6fdee23f755c9b9023b2b466034c30d8e99997dc3fadcbe259ce1d49309d519252fbffb72dcbcf128bd67cdc682119f2932e4dd3b7b8
7
+ data.tar.gz: 08f4a7ae43a9892275843b8ac4e8e9abc4d194c3fc6814c42668256f384c83ec7ba1103d575fd6f5e87d48fb66ead2713729d62b3a80caa483a591a88e8c35e2
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
24
+ .rbenv-gemsets
25
+ spec/spec_config.rb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ae_rss_maker.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 utahta
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # AeRssMaker
2
+
3
+ Make Momoiro Clover Z Angel Eyes RSS
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ae_rss_maker'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ae_rss_maker
18
+
19
+ ## Usage
20
+
21
+ Make News RSS:
22
+
23
+ rss = AeRssMaker.news(id, password)
24
+
25
+ Make Kwkm dairy RSS:
26
+
27
+ rss = AeRssMaker.kwkm(id, password)
28
+
29
+ Make Momorikobuta dairy RSS:
30
+
31
+ rss = AeRssMaker.momorikobuta(id, password)
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/utahta/ae_rss_maker/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ae_rss_maker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ae_rss_maker'
8
+ spec.version = AeRssMaker::VERSION
9
+ spec.authors = ['utahta']
10
+ spec.email = ['labs.ninxit@gmail.com']
11
+ spec.summary = %q{Make Momoiro Clover Z Angel Eyes RSS}
12
+ spec.description = %q{Make Momoiro Clover Z Angel Eyes RSS}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'mechanize', '~> 2.7.3'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec', '~> 2.14.1'
26
+
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'mechanize'
2
+ require 'date'
3
+ require 'open-uri'
4
+ require 'ae_rss_maker/version'
5
+ require 'ae_rss_maker/feed'
6
+ require 'ae_rss_maker/make'
7
+ require 'ae_rss_maker/news/fetch'
8
+ require 'ae_rss_maker/kwkm/fetch'
9
+ require 'ae_rss_maker/momorikobuta/fetch'
10
+
11
+ module AeRssMaker
12
+ module_function
13
+
14
+ def news(id, password)
15
+ feeds = News.fetch(id, password)
16
+ make(feeds, title: 'News')
17
+ end
18
+
19
+ def kwkm(id, password)
20
+ feeds = Kwkm.fetch(id, password)
21
+ make(feeds, title: 'Kwkm')
22
+ end
23
+
24
+ def momorikobuta(id, password)
25
+ feeds = Momorikobuta.fetch(id, password)
26
+ make(feeds, title: 'Momorikobuta')
27
+ end
28
+
29
+ end
@@ -0,0 +1,14 @@
1
+ # coding: utf-8
2
+
3
+ module AeRssMaker
4
+ class Feed
5
+ attr_accessor :title, :url, :date, :description
6
+ def initialize
7
+ @title = ''
8
+ @url = ''
9
+ @date = ''
10
+ @description = ''
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,66 @@
1
+ # coding: utf-8
2
+
3
+ module AeRssMaker
4
+ class Kwkm
5
+ def initialize
6
+ @agent = Mechanize.new
7
+ end
8
+
9
+ def self.fetch(id, password)
10
+ Kwkm.new.fetch(id, password)
11
+ end
12
+
13
+ def fetch(id, password)
14
+ login(id, password)
15
+
16
+ feeds = []
17
+ diary_list.each do |node|
18
+ feed = Feed.new
19
+ feed.title = title(node)
20
+ feed.url = url(node)
21
+ feed.date = date(node)
22
+ feed.description = description(feed.url)
23
+ feeds.push(feed)
24
+ end
25
+ feeds
26
+ end
27
+
28
+ private
29
+
30
+ def login(id, password)
31
+ page = @agent.get('https://fc.momoclo.net/pc/login.php')
32
+ page.forms_with(action: '/pc/login.php').each do |form|
33
+ form.login_id = id
34
+ form.password = password
35
+ @agent.submit(form)
36
+ end
37
+ end
38
+
39
+ def diary_list
40
+ page = @agent.get('http://fc.momoclo.net/pc/diary/')
41
+ page.search('//div[@id="inmain"]/div[@class="cont"]/ul/li')
42
+ end
43
+
44
+ def title(node)
45
+ elm = node.xpath('./h3/a')
46
+ elm.empty? ? '' : elm[0].text
47
+ end
48
+
49
+ def url(node)
50
+ elm = node.xpath('./h3/a')
51
+ elm.empty? ? '' : URI.join('http://fc.momoclo.net', elm[0][:href]).to_s
52
+ end
53
+
54
+ def date(node)
55
+ elm = node.xpath('./p[@class="date"]')
56
+ elm.empty? ? '' : elm.text[/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/]
57
+ end
58
+
59
+ def description(url)
60
+ page = @agent.get(url)
61
+ body = page.search('//p[@class="body"]')
62
+ body.empty? ? '' : body.to_html
63
+ end
64
+ end
65
+ end
66
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ require 'rss'
3
+
4
+ module AeRssMaker
5
+ module_function
6
+
7
+ def make(feeds, opts={})
8
+ title = opts[:title].nil? ? '' : " | #{opts[:title]}"
9
+ RSS::Maker.make('atom') do |maker|
10
+ maker.channel.author = 'Momoiro Clover Z'
11
+ maker.channel.updated = Time.now.to_s
12
+ maker.channel.about = 'http://fc.momoclo.net/pc/'
13
+ maker.channel.title = "ANGEL EYES#{title}"
14
+
15
+ feeds.each do |feed|
16
+ maker.items.new_item do |item|
17
+ item.link = feed.url
18
+ item.title = feed.title
19
+ item.updated = feed.date
20
+ item.description = feed.description
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,66 @@
1
+ # coding: utf-8
2
+
3
+ module AeRssMaker
4
+ class Momorikobuta
5
+ def initialize
6
+ @agent = Mechanize.new
7
+ end
8
+
9
+ def self.fetch(id, password)
10
+ Momorikobuta.new.fetch(id, password)
11
+ end
12
+
13
+ def fetch(id, password)
14
+ login(id, password)
15
+
16
+ feeds = []
17
+ diary_list.each do |node|
18
+ feed = Feed.new
19
+ feed.title = title(node)
20
+ feed.url = url(node)
21
+ feed.date = date(node)
22
+ feed.description = description(feed.url)
23
+ feeds.push(feed)
24
+ end
25
+ feeds
26
+ end
27
+
28
+ private
29
+
30
+ def login(id, password)
31
+ page = @agent.get('https://fc.momoclo.net/pc/login.php')
32
+ page.forms_with(action: '/pc/login.php').each do |form|
33
+ form.login_id = id
34
+ form.password = password
35
+ @agent.submit(form)
36
+ end
37
+ end
38
+
39
+ def diary_list
40
+ page = @agent.get('http://fc.momoclo.net/pc/diary2/')
41
+ page.search('//div[@id="inmain"]/div[@class="cont"]/ul/li')
42
+ end
43
+
44
+ def title(node)
45
+ elm = node.xpath('./div/h3/a')
46
+ elm.empty? ? '' : elm[0].text
47
+ end
48
+
49
+ def url(node)
50
+ elm = node.xpath('./div/h3/a')
51
+ elm.empty? ? '' : URI.join('http://fc.momoclo.net', elm[0][:href]).to_s
52
+ end
53
+
54
+ def date(node)
55
+ elm = node.xpath('./div/p[@class="date"]')
56
+ elm.empty? ? '' : elm.text[/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/]
57
+ end
58
+
59
+ def description(url)
60
+ page = @agent.get(url)
61
+ body = page.search('//p[@class="body"]')
62
+ body.empty? ? '' : body.to_html
63
+ end
64
+ end
65
+ end
66
+
@@ -0,0 +1,66 @@
1
+ # coding: utf-8
2
+
3
+ module AeRssMaker
4
+ class News
5
+ def initialize
6
+ @agent = Mechanize.new
7
+ end
8
+
9
+ def self.fetch(id, password)
10
+ News.new.fetch(id, password)
11
+ end
12
+
13
+ def fetch(id, password)
14
+ login(id, password)
15
+
16
+ feeds = []
17
+ news_list.each do |node|
18
+ feed = Feed.new
19
+ feed.title = title(node)
20
+ feed.url = url(node)
21
+ feed.date = date(node)
22
+ feed.description = description(feed.url)
23
+ feeds.push(feed)
24
+ end
25
+ feeds
26
+ end
27
+
28
+ private
29
+
30
+ def login(id, password)
31
+ page = @agent.get('https://fc.momoclo.net/pc/login.php')
32
+ page.forms_with(action: '/pc/login.php').each do |form|
33
+ form.login_id = id
34
+ form.password = password
35
+ @agent.submit(form)
36
+ end
37
+ end
38
+
39
+ def news_list
40
+ page = @agent.get('http://fc.momoclo.net/pc/information/')
41
+ page.search('//div[@id="news"]/ul/li')
42
+ end
43
+
44
+ def title(node)
45
+ elm = node.xpath('./h3/a')
46
+ elm.empty? ? '' : elm[0].text
47
+ end
48
+
49
+ def url(node)
50
+ elm = node.xpath('./h3/a')
51
+ elm.empty? ? '' : URI.join('http://fc.momoclo.net/pc/information/', elm[0][:href]).to_s
52
+ end
53
+
54
+ def date(node)
55
+ elm = node.xpath('./p[@class="date"]')
56
+ elm.empty? ? '' : elm.text[/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/]
57
+ end
58
+
59
+ def description(url)
60
+ page = @agent.get(url)
61
+ body = page.search('//div[@class="body"]')
62
+ body.empty? ? '' : body.to_html
63
+ end
64
+ end
65
+ end
66
+
@@ -0,0 +1,3 @@
1
+ module AeRssMaker
2
+ VERSION = '0.1.0'
3
+ end
data/spec/kwkm_spec.rb ADDED
@@ -0,0 +1,13 @@
1
+ # coding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe AeRssMaker::Kwkm do
5
+
6
+ describe '#fetch' do
7
+ it '1つ以上のフィードが取れること' do
8
+ feeds = AeRssMaker::Kwkm.fetch(ID, PASSWORD)
9
+ expect(feeds.length).to be > 0
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # coding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe AeRssMaker::Momorikobuta do
5
+
6
+ describe '#fetch' do
7
+ it '1つ以上のフィードが取れること' do
8
+ feeds = AeRssMaker::Momorikobuta.fetch(ID, PASSWORD)
9
+ expect(feeds.length).to be > 0
10
+ end
11
+ end
12
+
13
+ end
data/spec/news_spec.rb ADDED
@@ -0,0 +1,13 @@
1
+ # coding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe AeRssMaker::News do
5
+
6
+ describe '#fetch' do
7
+ it '1つ以上のフィードが取れること' do
8
+ feeds = AeRssMaker::News.fetch(ID, PASSWORD)
9
+ expect(feeds.length).to be > 0
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,4 @@
1
+ # coding: utf-8
2
+
3
+ ID = ''
4
+ PASSWORD = ''
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'ae_rss_maker'
8
+ require 'spec_config'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ae_rss_maker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - utahta
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.7.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.7.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ description: Make Momoiro Clover Z Angel Eyes RSS
70
+ email:
71
+ - labs.ninxit@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - ae_rss_maker.gemspec
83
+ - lib/ae_rss_maker.rb
84
+ - lib/ae_rss_maker/feed.rb
85
+ - lib/ae_rss_maker/kwkm/fetch.rb
86
+ - lib/ae_rss_maker/make.rb
87
+ - lib/ae_rss_maker/momorikobuta/fetch.rb
88
+ - lib/ae_rss_maker/news/fetch.rb
89
+ - lib/ae_rss_maker/version.rb
90
+ - spec/kwkm_spec.rb
91
+ - spec/momorikobuta_spec.rb
92
+ - spec/news_spec.rb
93
+ - spec/spec_config.rb.sample
94
+ - spec/spec_helper.rb
95
+ homepage: ''
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.2.2
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Make Momoiro Clover Z Angel Eyes RSS
119
+ test_files:
120
+ - spec/kwkm_spec.rb
121
+ - spec/momorikobuta_spec.rb
122
+ - spec/news_spec.rb
123
+ - spec/spec_config.rb.sample
124
+ - spec/spec_helper.rb