social_catalog 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '065497fc29c66a8164808e92ca9c1d738d40990c7616b5efee708b83a1d3f8d9'
4
+ data.tar.gz: 5f02714ea10b7050d153c7f742a8f79368a8782ad8aa2ec51264dc4723433da4
5
+ SHA512:
6
+ metadata.gz: 8d5fff22b81903853f2a2186853c22c9718d45da59f141ebea3d7505e74c3c08720a17b1dffd62bcfc897a52c36a795da9fcb6a814cde4d4763ced7dc4976481
7
+ data.tar.gz: d4a17f6c30a465c9da49d7c70f062b5cb2fa855a28e9b3901f806fbfd5647eb57ae92ff2fb87d34df46a3723a2d79aad21dfbe5e117319b05e4a8f402794c281
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Alexander Merkulov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # SocialCatalog
2
+ Library to render xml & other formats especially for FB and others.
3
+
4
+ The project at the initial state, any great contribution are welcome.
5
+
6
+ ## Usage
7
+ Add to initializers folder social_catalog.rb
8
+
9
+ SocialCatalog.facebook_items = lambda { |xml|
10
+ data = [
11
+ { title: 'Test1',
12
+ link: SocialCatalog.base_url + '/items/some1',
13
+ some_field: 'field1',
14
+ updated: Time.now.to_s },
15
+ { title: 'Test2',
16
+ link: SocialCatalog.base_url + '/items/some2',
17
+ some_field: 'field2',
18
+ updated: Time.now.to_s },
19
+ { title: 'Test3',
20
+ link: SocialCatalog.base_url + '/items/some3',
21
+ some_field: 'field3',
22
+ updated: Time.now.to_s },
23
+ { title: 'Test4',
24
+ link: SocialCatalog.base_url + '/items/some4',
25
+ some_field: 'field4',
26
+ updated: Time.now.to_s }
27
+ ]
28
+ data.each do |d|
29
+ xml.item do
30
+ xml.title d[:title]
31
+ xml.description d[:title]
32
+ xml.link d[:link]
33
+ xml.image_link d[:link]
34
+ xml.brand d[:link]
35
+ xml.condition 'new'
36
+ xml.availability 'in stock'
37
+ xml.price '100000.99 RUB'
38
+ xml.shipping do
39
+ xml.country 'Russia'
40
+ xml.service 'Standard'
41
+ xml.price '1000 RUB'
42
+ end
43
+ end
44
+ end
45
+ }
46
+
47
+ ## Installation
48
+ Add this line to your application's Gemfile:
49
+
50
+ ```ruby
51
+ gem 'social_catalog'
52
+ ```
53
+
54
+ And then execute:
55
+ ```bash
56
+ $ bundle
57
+ ```
58
+
59
+ Or install it yourself as:
60
+ ```bash
61
+ $ gem install social_catalog
62
+ ```
63
+
64
+ ## Contributing
65
+ 1. Fork it ( https://github.com/merqlove/do_snapshot/fork )
66
+ 2. Create your feature branch (git checkout -b my-new-feature)
67
+ 3. Commit your changes (git commit -am 'Add some feature')
68
+ 4. Push to the branch (git push origin my-new-feature)
69
+ 5. Create a new Pull Request
70
+
71
+ ## License
72
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SocialCatalog'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,5 @@
1
+ module SocialCatalog
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery except: :index
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ require_dependency 'social_catalog/application_controller'
2
+
3
+ module SocialCatalog
4
+ # Facebook controller output
5
+ class FacebookController < ::SocialCatalog::ApplicationController
6
+ def index
7
+ result = catalog.call(&SocialCatalog.facebook_items)
8
+ render xml: result, status: 200
9
+ end
10
+
11
+ private
12
+
13
+ def catalog
14
+ @catalog ||= Formats::FacebookCatalog.new
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ SocialCatalog::Engine.routes.draw do
2
+ get 'facebook', to: 'facebook#index', format: :xml, as: :social_catalog_facebook
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'social_catalog/engine'
2
+
3
+ #
4
+ # Social catalog
5
+ #
6
+ module SocialCatalog
7
+ mattr_accessor :url_prefix, default: 'social-catalog'
8
+ mattr_accessor :author
9
+ mattr_accessor :title
10
+ mattr_accessor :description
11
+ mattr_accessor :base_url
12
+ mattr_accessor :facebook_items, default: proc {}
13
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'formats'
2
+
3
+ module SocialCatalog
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace SocialCatalog
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module SocialCatalog
2
+ # Formats
3
+ module Formats
4
+ autoload :FacebookCatalog, 'social_catalog/formats/facebook_catalog'
5
+ end
6
+ end
@@ -0,0 +1,35 @@
1
+ require 'nokogiri'
2
+
3
+ module SocialCatalog
4
+ module Formats
5
+ # Facebook RSS Feed
6
+ class FacebookCatalog
7
+ def initialize
8
+ super
9
+ end
10
+
11
+ # @param [Proc] block
12
+ # @return [String]
13
+ def call(&block)
14
+ Rails.cache.fetch('social-catalog:facebook') do
15
+ full_host = SocialCatalog.base_url
16
+
17
+ builder = Nokogiri::XML::Builder.new do |xml|
18
+ xml.rss('xmlns:g' => 'http://base.google.com/ns/1.0', 'version' => '2.0') do
19
+ xml.channel do
20
+ xml.title SocialCatalog.title
21
+ xml.description SocialCatalog.description
22
+ xml.link rel: 'self', href: "#{full_host}/#{SocialCatalog.url_prefix}/facebook.xml"
23
+ xml.id "#{full_host}/"
24
+
25
+ block.call(xml)
26
+ end
27
+ end
28
+ end
29
+
30
+ builder.to_xml
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module SocialCatalog
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :social_catalog do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: social_catalog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Merkulov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.2.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 5.2.2
41
+ description: Tools to generate usable social catalog RSS.
42
+ email:
43
+ - sasha@merqlove.ru
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - app/controllers/social_catalog/application_controller.rb
52
+ - app/controllers/social_catalog/facebook_controller.rb
53
+ - config/routes.rb
54
+ - lib/social_catalog.rb
55
+ - lib/social_catalog/engine.rb
56
+ - lib/social_catalog/formats.rb
57
+ - lib/social_catalog/formats/facebook_catalog.rb
58
+ - lib/social_catalog/version.rb
59
+ - lib/tasks/social_catalog_tasks.rake
60
+ homepage: https://github.com/merqlove/social-catalog
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.7.6
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Tools to generate usable social catalog RSS.
84
+ test_files: []