gal 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afa3d56d51b9e0093e5a195317fe3fc25c0c84f90b28ac760382aae3ff793300
4
- data.tar.gz: add5b306d106947b1834da8c726d375b93eabe26fe7bebb8968ee0bdf6971fa7
3
+ metadata.gz: 229ca30d0fdf83eda0af07ac1bb6b45d9545d6a9e3f4c57a5200e65ea815d666
4
+ data.tar.gz: 8a6b4d92500b172f8da06c1111b588edb6aefa464a88ae2eb5f2077c50d99ba0
5
5
  SHA512:
6
- metadata.gz: 6373b776a005c89f907eefe8101ff669729ae83f781dc8e9435861d7948989b494d1112857daaa80e64b015cf9e958028e80f6e9d97c132fc5551b1c9ff0ee46
7
- data.tar.gz: 24c8ef6a20f2225e59964a1c38e37982fd21462ba621287456e18421ec267e43d1ab21f5ef878412d44a9ac957edfcd6c946f789c6daacfc3378cc8a691a2c9e
6
+ metadata.gz: bd1ed00acc247cdf8bbb4bb216250b8f04cd2f2095675942e5f831354b4a774783f3bb5d49588ba5c9f1704ad103f8f0fb243ff5a0b2190b885b9e4fda3a6713
7
+ data.tar.gz: 62b24666e7284e137cf643081f78f90f8bdc399903034b36bae537cc8496dee731631c1fd09e124d4d8c8d21600d54be9bfee14df4f7ff82da5c61d45cfc5163
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.7
17
+ bundle install
18
+ bundle exec rake
data/.gitignore CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ # env
14
+ .env
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md CHANGED
@@ -0,0 +1,5 @@
1
+ # Change log
2
+
3
+ ## 1.0.0 (3.2.2021)
4
+
5
+ - v1.0.0
data/Gemfile CHANGED
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
+ # Specify your gem's dependencies in gal.gemspec
5
6
  gemspec
6
7
 
7
- gem 'rake', '~> 12.0'
8
- gem 'rspec', '~> 3.0'
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock CHANGED
@@ -1,34 +1,75 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gal (0.1.1)
4
+ gal (1.0.0)
5
+ dotenv
6
+ rest-client
5
7
 
6
8
  GEM
7
9
  remote: https://rubygems.org/
8
10
  specs:
11
+ ast (2.4.2)
9
12
  diff-lcs (1.4.4)
10
- rake (12.3.3)
11
- rspec (3.9.0)
12
- rspec-core (~> 3.9.0)
13
- rspec-expectations (~> 3.9.0)
14
- rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.2)
16
- rspec-support (~> 3.9.3)
17
- rspec-expectations (3.9.2)
13
+ domain_name (0.5.20190701)
14
+ unf (>= 0.0.5, < 1.0.0)
15
+ dotenv (2.7.6)
16
+ http-accept (1.7.0)
17
+ http-cookie (1.0.3)
18
+ domain_name (~> 0.5)
19
+ mime-types (3.3.1)
20
+ mime-types-data (~> 3.2015)
21
+ mime-types-data (3.2020.1104)
22
+ netrc (0.11.0)
23
+ parallel (1.20.1)
24
+ parser (3.0.0.0)
25
+ ast (~> 2.4.1)
26
+ rainbow (3.0.0)
27
+ rake (13.0.3)
28
+ regexp_parser (2.0.3)
29
+ rest-client (2.1.0)
30
+ http-accept (>= 1.7.0, < 2.0)
31
+ http-cookie (>= 1.0.2, < 2.0)
32
+ mime-types (>= 1.16, < 4.0)
33
+ netrc (~> 0.8)
34
+ rexml (3.2.4)
35
+ rspec (3.10.0)
36
+ rspec-core (~> 3.10.0)
37
+ rspec-expectations (~> 3.10.0)
38
+ rspec-mocks (~> 3.10.0)
39
+ rspec-core (3.10.1)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-expectations (3.10.1)
18
42
  diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.9.0)
20
- rspec-mocks (3.9.1)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-mocks (3.10.2)
21
45
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.9.0)
23
- rspec-support (3.9.3)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-support (3.10.2)
48
+ rubocop (1.9.1)
49
+ parallel (~> 1.10)
50
+ parser (>= 3.0.0.0)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 1.8, < 3.0)
53
+ rexml
54
+ rubocop-ast (>= 1.2.0, < 2.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (>= 1.4.0, < 3.0)
57
+ rubocop-ast (1.4.1)
58
+ parser (>= 2.7.1.5)
59
+ ruby-progressbar (1.11.0)
60
+ unf (0.1.4)
61
+ unf_ext
62
+ unf_ext (0.0.7.7)
63
+ unicode-display_width (2.0.0)
24
64
 
25
65
  PLATFORMS
26
- ruby
66
+ x86_64-linux
27
67
 
28
68
  DEPENDENCIES
29
69
  gal!
30
- rake (~> 12.0)
70
+ rake (~> 13.0)
31
71
  rspec (~> 3.0)
72
+ rubocop (~> 1.7)
32
73
 
33
74
  BUNDLED WITH
34
- 2.1.4
75
+ 2.2.7
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 vedranvinko
3
+ Copyright (c) 2021 vedran
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Gal
1
+ # gal
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gal`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ gal is a small wrapper for [Pastebin](https://pastebin.com/) API written in Ruby. Main idea was to use it as a library instead inside utility scripts, etc.
6
4
 
7
5
  ## Installation
8
6
 
@@ -28,17 +26,12 @@ TODO: Write usage instructions here
28
26
 
29
27
  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.
30
28
 
31
- 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).
29
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
30
 
33
31
  ## Contributing
34
32
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gal. 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/[USERNAME]/gal/blob/master/CODE_OF_CONDUCT.md).
36
-
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/vedranvinko/gal.
37
34
 
38
35
  ## License
39
36
 
40
37
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
-
42
- ## Code of Conduct
43
-
44
- Everyone interacting in the Gal project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gal/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- task default: :spec
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console CHANGED
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'gal'
4
+ require "bundler/setup"
5
+ require "gal"
6
6
 
7
- require 'irb'
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
8
15
  IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -4,3 +4,5 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/gal.gemspec CHANGED
@@ -1,28 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/gal/version'
3
+ require_relative "lib/gal/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'gal'
6
+ spec.name = "gal"
7
7
  spec.version = Gal::VERSION
8
- spec.authors = ['vedranvinko']
9
- spec.email = ['vinkovedran@gmail.com']
8
+ spec.authors = ["vedranvinko"]
9
+ spec.email = ["vinkovedran@gmail.com"]
10
10
 
11
- spec.summary = 'Pastebin API wrapper'
12
- spec.description = 'A small wrapper for Pastebn API'
13
- spec.homepage = 'https://github.com/vedranvinko/gal'
14
- spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
11
+ spec.summary = "Pastebin API wrapper"
12
+ spec.description = "A small wrapper for Pastebin API"
13
+ spec.homepage = "https://github.com/vedranvinko/gal"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
16
 
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = 'https://github.com/vedranvinko/gal'
19
- spec.metadata['changelog_uri'] = 'https://github.com/vedranvinko/gal/CHANGELOG.md'
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/vedranvinko/gal"
19
+ spec.metadata["changelog_uri"] = "https://github.com/vedranvinko/gal/CHANGELOG.md"
20
20
 
21
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
23
23
  end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
24
27
 
25
- spec.bindir = 'exe'
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ['lib']
28
+ spec.add_runtime_dependency "dotenv"
29
+ spec.add_runtime_dependency "rest-client"
28
30
  end
data/lib/gal.rb CHANGED
@@ -1,7 +1,100 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gal/version'
3
+ require_relative "gal/version"
4
4
 
5
- module Gal
6
- class Error < StandardError; end
5
+ require "dotenv"
6
+ require "rest-client"
7
+
8
+ Dotenv.load
9
+
10
+ class Gal
11
+ attr_accessor :default
12
+
13
+ def initialize
14
+ @login = "https://pastebin.com/api/api_login.php"
15
+ @url = "https://pastebin.com/api/api_post.php"
16
+ @raw = "https://pastebin.com/api/api_raw.php"
17
+
18
+ @default = {
19
+ api_dev_key: ENV["token"],
20
+ api_user_name: ENV["name"],
21
+ api_user_password: ENV["password"],
22
+ api_user_key: nil,
23
+ api_option: nil,
24
+ api_paste_key: nil,
25
+ api_paste_name: nil,
26
+ api_paste_code: nil,
27
+ api_paste_format: "ruby",
28
+ api_paste_private: "0",
29
+ api_paste_expire_date: "N"
30
+ }
31
+
32
+ user_key
33
+ end
34
+
35
+ def create(options)
36
+ raise "Options must be a hash" unless options.is_a? Hash
37
+
38
+ @default[:api_paste_name] = options[:api_paste_name] || "AutoPaste: #{Time.now.strftime("%d/%m/%Y %H:%M:%S")}"
39
+ @default[:api_option] = "paste"
40
+ @default[:api_paste_code] = options[:api_paste_code]
41
+
42
+ rsp = RestClient.post @url, @default
43
+
44
+ rsp.body
45
+ end
46
+
47
+ def delete(pkey)
48
+ raise "Paste key must be a string" unless pkey.is_a? String
49
+
50
+ @default[:api_option] = "delete"
51
+ @default[:api_paste_key] = pkey
52
+
53
+ rsp = RestClient.post @url, @default
54
+
55
+ rsp.body
56
+ end
57
+
58
+ def user
59
+ @default[:api_option] = "userdetails"
60
+
61
+ rsp = RestClient.post @url, @default
62
+
63
+ rsp.body
64
+ end
65
+
66
+ def list_user_entries(num)
67
+ raise "Please provide integer as an argument" unless num.is_a? Integer
68
+
69
+ @default[:api_results_limit] = num
70
+ @default[:api_option] = "list"
71
+
72
+ rsp = RestClient.post @url, @default
73
+
74
+ rsp.body
75
+ end
76
+
77
+ alias pastes list_user_entries
78
+
79
+ def show_options
80
+ @default
81
+ end
82
+
83
+ def raw_paste(pkey)
84
+ raise "Paste key must be a string" unless pkey.is_a? String
85
+
86
+ @default[:api_paste_key] = pkey
87
+ @default[:api_option] = "show_paste"
88
+
89
+ rsp = RestClient.post @raw, @default
90
+
91
+ rsp.body
92
+ end
93
+
94
+ protected
95
+
96
+ def user_key
97
+ rsp = RestClient.post @login, @default
98
+ @default[:api_user_key] = rsp.body
99
+ end
7
100
  end
data/lib/gal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Gal
4
- VERSION = '0.1.1'
3
+ class Gal
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,27 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vedranvinko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
12
- dependencies: []
13
- description: A small wrapper for Pastebn API
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A small wrapper for Pastebin API
14
42
  email:
15
43
  - vinkovedran@gmail.com
16
44
  executables: []
17
45
  extensions: []
18
46
  extra_rdoc_files: []
19
47
  files:
48
+ - ".github/workflows/main.yml"
20
49
  - ".gitignore"
21
50
  - ".rspec"
22
- - ".travis.yml"
51
+ - ".rubocop.yml"
23
52
  - CHANGELOG.md
24
- - CODE_OF_CONDUCT.md
25
53
  - Gemfile
26
54
  - Gemfile.lock
27
55
  - LICENSE.txt
@@ -39,7 +67,7 @@ metadata:
39
67
  homepage_uri: https://github.com/vedranvinko/gal
40
68
  source_code_uri: https://github.com/vedranvinko/gal
41
69
  changelog_uri: https://github.com/vedranvinko/gal/CHANGELOG.md
42
- post_install_message:
70
+ post_install_message:
43
71
  rdoc_options: []
44
72
  require_paths:
45
73
  - lib
@@ -47,15 +75,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
75
  requirements:
48
76
  - - ">="
49
77
  - !ruby/object:Gem::Version
50
- version: 2.3.0
78
+ version: 2.4.0
51
79
  required_rubygems_version: !ruby/object:Gem::Requirement
52
80
  requirements:
53
81
  - - ">="
54
82
  - !ruby/object:Gem::Version
55
83
  version: '0'
56
84
  requirements: []
57
- rubygems_version: 3.1.2
58
- signing_key:
85
+ rubygems_version: 3.2.3
86
+ signing_key:
59
87
  specification_version: 4
60
88
  summary: Pastebin API wrapper
61
89
  test_files: []
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
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 vinkovedran@gmail.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/