act_as_pingback 0.1.1

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: '098eb701c7b808f79d700c91def8b713516e28b631bec21672ec9339e1d94df8'
4
+ data.tar.gz: 07c81eeea1617870e7ace72e3767e60055ead8144a2ab1ee76b189079907ae43
5
+ SHA512:
6
+ metadata.gz: 5bd17c2d2ac02f76a6688f12c9f91fa97e602ffc66a83076fb0784c3528ced3ed1c98bd1aa8f87fb3e913008571b34ba6ed34582898f656b7dd1381cf23dc02d
7
+ data.tar.gz: 0cbe057e07083219809a289633e6480792fe57d2963a7bc95d8a95f92bb865a596cf1bc7713477c003a2bb17ce430567a7fbb14ea1f2fd27d47b0dc5b8013822
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Myk Klemme
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,144 @@
1
+ # act_as_pingback
2
+
3
+ [![IHV](https://img.shields.io/badge/member%20of-Invisible%20Hat%20Ventures-blue.svg)](https://github.com/invisiblehats)
4
+
5
+ ---
6
+
7
+ A rails integration for [pingback-ruby](https://github.com/democracy-news/pingback-ruby)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'act_as_pingback', github: 'democracy-news/act_as_pingback'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install act_as_pingback
24
+
25
+ ## Usage
26
+ You need to create a free account [here](#) before using this gem.
27
+ ```ruby
28
+ Pingback.configure do |config|
29
+ config.api_token = ENV['PINGBACK_TOKEN']
30
+ end
31
+ ```
32
+
33
+ Install `act_as_pingback` in the models you want and enable which fields you want to include in the pingback:
34
+
35
+ ```ruby
36
+ class Post < ApplicationRecord
37
+ act_as_pingback fields: [
38
+ :title,
39
+ :body,
40
+ :url
41
+ ]
42
+ end
43
+ ```
44
+
45
+ This would send a request to `pingback.democracy.news` with:
46
+
47
+ ```ruby
48
+ {
49
+ title: "Hello world",
50
+ body: "<p>I created this using a tutorial from https://google.com and <a href=\"https://code.tutsplus.com/\">envato</a></p>",
51
+ url: "https://myblog.com/posts/hello-world"
52
+ }
53
+ ```
54
+
55
+ on `post#create` and `post#update` `post#delete` by default.
56
+
57
+ `url` by default will be `Rails.application.routes.url_helpers.url(self)`. To override this:
58
+ ```ruby
59
+ class Post < ApplicationRecord
60
+ act_as_pingback fields: [
61
+ :formatted_title,
62
+ :body,
63
+ :url
64
+ ],
65
+ callbacks: false,
66
+ on: [
67
+ :create
68
+ ],
69
+ async: true,
70
+ queue: 'cms'
71
+
72
+ def url
73
+ "https://myotherblog.com/posts/#{slug}"
74
+ end
75
+
76
+ def formatted_title
77
+ "[POST] #{title}"
78
+ end
79
+ end
80
+ ```
81
+
82
+ Becomes:
83
+
84
+ ```ruby
85
+ {
86
+ title: "[POST] Hello world",
87
+ body: "<p>I created this using a tutorial from https://google.com and <a href=\"https://code.tutsplus.com/\">envato</a></p>",
88
+ url: "https://myotherblog.com/posts/hello-world"
89
+ }
90
+ ```
91
+
92
+ ### Options
93
+ Argument | Type | Default | Description
94
+ --|--|--|--
95
+ `fields` | `Array` (symbols) | `[]` | A list of the fields to include in the request. These would be any with links to process.
96
+ `callbacks` | `Boolean` | `true` | Trigger on active record callbacks? _(Only enabled for `ActiveRecord` objects)_
97
+ `on` | `Array` | `:create, :update, :delete` | Which lifecycle events should this library fire for
98
+ `async` | `Boolean` | `false` | Should this be run in the background?
99
+ `queue` | `String` | `default` | The queue name for this to run in _(Only supports `Sidekiq` right now)_
100
+
101
+ ```ruby
102
+ # example
103
+ class Post < ApplicationRecord
104
+ act_as_pingback fields: [
105
+ :title,
106
+ :body,
107
+ :url
108
+ ],
109
+ callbacks: false,
110
+ on: [
111
+ :create
112
+ ],
113
+ async: true,
114
+ queue: 'cms'
115
+
116
+ end
117
+ ```
118
+
119
+
120
+ ## Development
121
+
122
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
123
+
124
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
125
+
126
+ ## Contributing
127
+
128
+ Bug reports and pull requests are welcome on GitHub at https://github.com/democracy-news/act_as_pingback. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
129
+
130
+ ## License
131
+
132
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
133
+
134
+ ## Code of Conduct
135
+
136
+ Everyone interacting in the ClassName project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/democracy-news/act_as_pingback/blob/master/CODE_OF_CONDUCT.md).
137
+
138
+ ## Development team
139
+ ### People
140
+ - [Myk Klemme - @mklemme](https://github.com/mklemme) Lead developer and maintainer for this project.
141
+ ### Partners
142
+ - [Invisible Hat Ventures - @invisiblehats](https://github.com/invisiblehats) A private startup development agency
143
+ - [Love.irish - @love-irish](https://github.com/love-irish) A lifestyle-as-a-service for the Irish language
144
+ - [League of Celts - @league-of-celts](https://github.com/league-of-celts) A non-profit focused on promoting Celtic languages
@@ -0,0 +1,27 @@
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 = 'ActAsPingback'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
@@ -0,0 +1,5 @@
1
+ require "act_as_pingback/railtie"
2
+
3
+ module ActAsPingback
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ module ActAsPingback
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ActAsPingback
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :act_as_pingback do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: act_as_pingback
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Myk Klemme
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.0.rc1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.0.rc1
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A rails engine for publishing updates to pingback.democracy.news
42
+ email:
43
+ - mykklemme@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/act_as_pingback.rb
52
+ - lib/act_as_pingback/railtie.rb
53
+ - lib/act_as_pingback/version.rb
54
+ - lib/tasks/act_as_pingback_tasks.rake
55
+ homepage: https://github.com/democracy-news/act_as_pingback
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ allowed_push_host: https://rubygems.org
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.0.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: A rails engine for publishing updates to pingback.democracy.news
79
+ test_files: []