forem_lite 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d48565de3831a44026c784304d5c5ee3cee6681cf51b4d7ce822f47f464a4bf4
4
+ data.tar.gz: 74416fef674abcf874291933244cb662548a1c4f0608f590c41da3e88255302a
5
+ SHA512:
6
+ metadata.gz: a6d9e8067c168a6fba7cb74a879189a2b7c2ed97a57b93adadb158594b03add991eea7af972dbd5f8e32713cfdd5c2733a212d75f5215b7a7b41a4c84ab85f0b
7
+ data.tar.gz: e5b229948a76603307c6a036271fefca2cacd4db8a1449aefac7cf55c670a74efb5911f0d9eb4f836f286ecc4dd6938c9ee047b67ab712cf76e4c5706db3a27c
@@ -0,0 +1,3 @@
1
+ bump:
2
+ file: lib/forem_lite/version.rb
3
+ message: "chore(release): :bookmark: Bump %{name} to %{version} [nodoc]"
@@ -0,0 +1,9 @@
1
+ # Also see https://github.com/github/gitignore/blob/master/Ruby.gitignore
2
+
3
+ Gemfile.lock
4
+ *.gem
5
+ .bundle
6
+ .env
7
+ rdoc
8
+ tmp
9
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ exclude:
5
+ - spec/**/*
6
+ - vendor/**/*
7
+ - ".bundle/**/*"
8
+ require: []
9
+ domains: []
10
+ reporters:
11
+ - require_not_found
12
+ require_paths: []
13
+ plugins: []
14
+ max_files: 5000
@@ -0,0 +1,7 @@
1
+ fix: true
2
+ parallel: true
3
+ format: progress
4
+ ruby_version: 2.7.1
5
+ ignore:
6
+ - "lib/**/*":
7
+ - Style/MissingRespondToMissing
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## [v1.1.0](https://github.com/andrewmcodes/bridgetown-inline-svg/tree/v1.1.0) (2020-07-21)
4
+
5
+ [Full Changelog](https://github.com/andrewmcodes/bridgetown-inline-svg/compare/v1.0.0...v1.1.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Update documentation [\#5](https://github.com/andrewmcodes/bridgetown-inline-svg/pull/5) ([andrewmcodes](https://github.com/andrewmcodes))
10
+ - bug: Allow svg in partial without passing "site: site" explicitly [\#4](https://github.com/andrewmcodes/bridgetown-inline-svg/pull/4) ([MikeRogers0](https://github.com/MikeRogers0))
11
+
12
+ ## [v1.0.0](https://github.com/andrewmcodes/bridgetown-inline-svg/tree/v1.0.0) (2020-07-11)
13
+
14
+ [Full Changelog](https://github.com/andrewmcodes/bridgetown-inline-svg/compare/dcf77a73d7fee38fdc00dfce3b6a7f50ebd27636...v1.0.0)
15
+
16
+
17
+
18
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at andrewmcodes@protonmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem "rake", "~> 13.0"
7
+ end
8
+
9
+ group :development do
10
+ gem "solargraph", "~> 0.39"
11
+ gem "standard", "~> 0.4"
12
+ end
13
+
14
+ group :test do
15
+ gem "coveralls", "~> 0.8.23"
16
+ gem "rspec", "~> 3.0"
17
+ gem "simplecov", "~> 0.16.1"
18
+ gem "webmock", "~> 3.0"
19
+ end
@@ -0,0 +1,21 @@
1
+ # MIT LICENSE
2
+
3
+ Copyright (c) 2020 Andrew Mason <andrewmcodes@protonmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ <div align="center">
2
+ <h1>ForemLite</h1>
3
+ <p>
4
+ <a href="LICENSE" target="_blank">
5
+ <img alt="License: MIT" src="https://img.shields.io/github/license/andrewmcodes/forem_lite" />
6
+ </a>
7
+ <a href="https://badge.fury.io/rb/forem_lite"><img src="https://badge.fury.io/rb/forem_lite.svg" alt="Gem Version" height="18"></a>
8
+ <a href="https://depfu.com"><img src="https://badges.depfu.com/badges/9cf174e17d58cbd60ea040722701e652/status.svg" alt="Depfu"></a>
9
+ <a href="https://depfu.com/github/andrewmcodes/forem_lite?project_id=14214"><img src="https://badges.depfu.com/badges/9cf174e17d58cbd60ea040722701e652/count.svg" alt="Depfu"></a>
10
+ <a href="https://codeclimate.com/github/andrewmcodes/forem_lite/maintainability"><img src="https://api.codeclimate.com/v1/badges/999e4e19ff915c1d4c8a/maintainability" /></a>
11
+ <a href="https://www.codacy.com/manual/andrewmcodes/forem_lite?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=andrewmcodes/forem_lite&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/4954986dea2e4732add795399a3c8c9d"/></a>
12
+ <a href='https://coveralls.io/github/andrewmcodes/forem_lite?branch=main'><img src='https://coveralls.io/repos/github/andrewmcodes/forem_lite/badge.svg?branch=main' alt='Coverage Status' /></a>
13
+ <img alt="inch ci" src="http://inch-ci.org/github/andrewmcodes/forem_lite.svg?branch=main&style=shields">
14
+ <img alt="Tests" src="https://github.com/andrewmcodes/forem_lite/workflows/Tests/badge.svg" />
15
+ <img alt="Linters" src="https://github.com/andrewmcodes/forem_lite/workflows/Linters/badge.svg" />
16
+ <img alt="Changelog" src="https://github.com/andrewmcodes/forem_lite/workflows/Changelog/badge.svg" />
17
+ </p>
18
+ </div>
19
+
20
+ A simple tool to help you get articles from Forem/Dev.to.
21
+
22
+ The patterns laid out in this gem could easily be used to finish building out the rest of the API, but I only needed articles so I am leaving the rest up to contributors or for when I eventually need to use it as well.
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem "forem_lite"
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ ```bash
35
+ bundle install
36
+ ```
37
+
38
+ Or install it yourself as:
39
+
40
+ ```bash
41
+ gem install forem_lite
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ```rb
47
+ require "forem_lite"
48
+
49
+ c = ForemLite::Client.new
50
+
51
+ # https://docs.dev.to/api/#operation/getArticles
52
+ articles = c.articles
53
+ articles.first.title # => "How do you keep notes?"
54
+
55
+ # https://docs.dev.to/api/#operation/getArticleById
56
+ article = c.article(279134)
57
+ article.title # => "A11Y in Rails: Automated Linting with AccessLint🎉"
58
+ article.url # => "https://dev.to/andrewmcodes/a11y-in-rails-automated-linting-with-accesslint-1618"
59
+ ```
60
+
61
+ ## Development
62
+
63
+ 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.
64
+
65
+ 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).
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andrewmcodes/forem_liteent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/andrewmcodes/forem_liteent/blob/master/CODE_OF_CONDUCT.md).
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
74
+
75
+ ## Code of Conduct
76
+
77
+ Everyone interacting in the DevApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/andrewmcodes/forem_liteent/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
7
+
8
+ desc "Open an irb session preloaded with this library"
9
+ task :console do
10
+ sh "irb -I lib -r forem_lite.rb"
11
+ end
@@ -0,0 +1,13 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security backports will be provided for some previous release series if needed.
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 0.0.x | :white_check_mark: |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ If you find a security issue with this gem, please open an issue, or contact [Andrew Mason](https://github.com/andrewmcodes) directly.
@@ -0,0 +1,31 @@
1
+ require_relative "lib/forem_lite/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "forem_lite"
5
+ s.version = ForemLite::VERSION
6
+ s.authors = ["Andrew Mason"]
7
+ s.email = ["andrewmcodes@protonmail.com"]
8
+ s.licenses = "MIT"
9
+ s.homepage = "https://github.com/andrewmcodes/forem_lite"
10
+
11
+ s.summary = "A minimal API wrapper to retrieve Forem articles."
12
+ s.description = s.summary
13
+ s.metadata = {
14
+ "bug_tracker_uri" => "#{s.homepage}/forem_lite/issues",
15
+ "changelog_uri" => "#{s.homepage}/blob/main/CHANGELOG.md",
16
+ "documentation_uri" => "#{s.homepage}/forem_lite",
17
+ "homepage_uri" => "#{s.homepage}/forem_lite",
18
+ "source_code_uri" => "#{s.homepage}/forem_lite"
19
+ }
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ s.files = Dir.chdir(File.expand_path("..", __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|bin|tmp|.github)/}) }
25
+ end
26
+
27
+ s.require_paths = ["lib"]
28
+
29
+ s.add_dependency "httparty", "~> 0.18.1"
30
+ s.add_dependency "zeitwerk", "< 3.0"
31
+ end
@@ -0,0 +1,9 @@
1
+ require "httparty"
2
+ require "zeitwerk"
3
+
4
+ loader = Zeitwerk::Loader.for_gem
5
+ loader.setup
6
+
7
+ module ForemLite
8
+ class Error < StandardError; end
9
+ end
@@ -0,0 +1,47 @@
1
+ module ForemLite
2
+ class Article
3
+ attr_accessor :raw
4
+
5
+ #
6
+ # Article Initializer
7
+ #
8
+ # @param [Hash] options <the article attributes returned by Forem>
9
+ #
10
+ def initialize(options)
11
+ @raw = options
12
+ end
13
+
14
+ #
15
+ # Intercept NoMethodError exceptions and handle gracefully.
16
+ #
17
+ # @param [Symbol] method_sym <symbolized name of the method being called>
18
+ # @param [Hash] *arguments <the arguments passed in to this method. Can be any number, or none>
19
+ # @param [Object] &block <the block of the method called>
20
+ #
21
+ # @return [String, Object] the method return value or NoMethodError
22
+ #
23
+ def method_missing(method_sym, *arguments, &block)
24
+ if @raw&.keys&.include?(method_sym.to_s)
25
+ @raw[method_sym.to_s]
26
+ else
27
+ super
28
+ end
29
+ end
30
+
31
+ #
32
+ # Hook method to return whether the obj can respond to id method or not.
33
+ #
34
+ # @param [Symbol] method_sym <symbolized name of the method being called>
35
+ # @param [Boolean] include_private <indicates whether to include private methods in the search scope>
36
+ #
37
+ # @return [Boolean, Object] <returns true if we can respond to the method, otherwise NoMethodError>
38
+ #
39
+ def respond_to?(method_sym, include_private = false)
40
+ if @raw&.keys&.include?(method_sym.to_s)
41
+ true
42
+ else
43
+ super
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ module ForemLite
2
+ class Client
3
+ include HTTParty
4
+ base_uri "https://dev.to/api/"
5
+
6
+ #
7
+ # Create a new client object with your Forem API key.
8
+ #
9
+ # @param [String] api_key <Forem/Dev.to API Key>
10
+ #
11
+ def initialize(api_key = nil)
12
+ self.class.default_options[:headers] = {"api-key" => api_key} if api_key
13
+ end
14
+
15
+ #
16
+ # Retrieve a list of articles.
17
+ #
18
+ # @return [Array<Object>] collection of ForemLite::Article objects
19
+ #
20
+ def articles
21
+ self.class.get("/articles").tap { |z| ForemLite::Article.new(z) }
22
+ end
23
+
24
+ #
25
+ # Retrieve a single published article given its id.
26
+ #
27
+ # @param [Integer, String] id <a string or integer representing the article id>
28
+ #
29
+ # @return [Object] a FormCli::Article object
30
+ #
31
+ def article(id)
32
+ ForemLite::Article.new(self.class.get("/articles/#{id}"))
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module ForemLite
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forem_lite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Mason
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "<"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: A minimal API wrapper to retrieve Forem articles.
42
+ email:
43
+ - andrewmcodes@protonmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gem_release.yml"
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".solargraph.yml"
52
+ - ".standard.yml"
53
+ - CHANGELOG.md
54
+ - CODE_OF_CONDUCT.md
55
+ - Gemfile
56
+ - LICENSE.md
57
+ - README.md
58
+ - Rakefile
59
+ - SECURITY.md
60
+ - forem_lite.gemspec
61
+ - lib/forem_lite.rb
62
+ - lib/forem_lite/article.rb
63
+ - lib/forem_lite/client.rb
64
+ - lib/forem_lite/version.rb
65
+ homepage: https://github.com/andrewmcodes/forem_lite
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ bug_tracker_uri: https://github.com/andrewmcodes/forem_lite/forem_lite/issues
70
+ changelog_uri: https://github.com/andrewmcodes/forem_lite/blob/main/CHANGELOG.md
71
+ documentation_uri: https://github.com/andrewmcodes/forem_lite/forem_lite
72
+ homepage_uri: https://github.com/andrewmcodes/forem_lite/forem_lite
73
+ source_code_uri: https://github.com/andrewmcodes/forem_lite/forem_lite
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.1.2
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: A minimal API wrapper to retrieve Forem articles.
93
+ test_files: []