gal 0.1.0

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: be0666dba7d4a25953263ee054302b97e0bc78a108796fc79418e1acbca39c28
4
+ data.tar.gz: 4d67fab2226e95621aa56133e1cf19c8d8905ea324ad8069ced53beafafa3854
5
+ SHA512:
6
+ metadata.gz: 89c08eae2a3d60b562d399ab100a0c82bb28c015f05334f379cbc6d2234048b5e939d5a2aada9dcc5a84229d347c512cd58e8299ae022ec785a94c9b0308b146
7
+ data.tar.gz: '009a96a5beeeb072186c8f69092763838760e493070fac352383021b99a4370c705e4912c54e4cb7cb82b1455b34227854462d951a41b44b75ebbaa7ac6a3dd9'
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # env files
14
+ .env
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.5
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,5 @@
1
+ # Change log
2
+
3
+ ## 0.1.0 (17.10.2019)
4
+
5
+ - initial release
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in gal.gemspec
6
+ gemspec
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gal (0.1.0)
5
+ dotenv
6
+ rest-client
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.3)
12
+ domain_name (0.5.20190701)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ dotenv (2.7.5)
15
+ ffi (1.11.1-x64-mingw32)
16
+ http-accept (1.7.0)
17
+ http-cookie (1.0.3)
18
+ domain_name (~> 0.5)
19
+ mime-types (3.3)
20
+ mime-types-data (~> 3.2015)
21
+ mime-types-data (3.2019.1009)
22
+ netrc (0.11.0)
23
+ rake (10.5.0)
24
+ rest-client (2.1.0-x64-mingw32)
25
+ ffi (~> 1.9)
26
+ http-accept (>= 1.7.0, < 2.0)
27
+ http-cookie (>= 1.0.2, < 2.0)
28
+ mime-types (>= 1.16, < 4.0)
29
+ netrc (~> 0.8)
30
+ rspec (3.9.0)
31
+ rspec-core (~> 3.9.0)
32
+ rspec-expectations (~> 3.9.0)
33
+ rspec-mocks (~> 3.9.0)
34
+ rspec-core (3.9.0)
35
+ rspec-support (~> 3.9.0)
36
+ rspec-expectations (3.9.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.9.0)
39
+ rspec-mocks (3.9.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.9.0)
42
+ rspec-support (3.9.0)
43
+ unf (0.1.4)
44
+ unf_ext
45
+ unf_ext (0.0.7.6)
46
+
47
+ PLATFORMS
48
+ x64-mingw32
49
+
50
+ DEPENDENCIES
51
+ bundler (~> 2.0)
52
+ gal!
53
+ rake (~> 10.0)
54
+ rspec (~> 3.0)
55
+
56
+ BUNDLED WITH
57
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 vedran
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,37 @@
1
+ # gal
2
+
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.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gal'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gal
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
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.
28
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/vedranvinko/gal.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'gal'
6
+
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'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'gal/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'gal'
9
+ spec.version = Gal::VERSION
10
+ spec.authors = ['vedranvinko']
11
+ spec.email = ['vinkovedran@gmail.com']
12
+
13
+ spec.summary = 'Pastebin API wrapper'
14
+ spec.description = 'A small wrapper for Pastebin API.'
15
+ spec.homepage = 'https://gitlab.com/vedranvinko/gal'
16
+ spec.license = 'MIT'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://gitlab.com/vedranvinko/gal'
20
+ spec.metadata['changelog_uri'] = 'https://gitlab.com/vedranvinko/gal/CHANGELOG.md'
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'dotenv'
30
+ spec.add_runtime_dependency 'rest-client'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 2.0'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gal/version'
4
+
5
+ require 'dotenv'
6
+ require 'rest-client'
7
+
8
+ Dotenv.load
9
+
10
+ class Gal
11
+ attr_accessor :default
12
+
13
+ def initialize
14
+ @url = 'http://pastebin.com/api/api_'
15
+ @raw = 'http://pastebin.com/raw/'
16
+
17
+ @default = {
18
+ api_dev_key: ENV['token'],
19
+ api_user_name: ENV['name'],
20
+ api_user_password: ENV['password'],
21
+ api_user_key: nil,
22
+ api_option: nil,
23
+ api_paste_key: nil,
24
+ api_paste_name: nil,
25
+ api_paste_code: nil,
26
+ api_paste_format: 'ruby',
27
+ api_paste_private: '0',
28
+ api_paste_expire_date: 'N'
29
+ }
30
+
31
+ user_key
32
+ end
33
+
34
+ # rubocop:disable Style/MethodMissingSuper
35
+ # rubocop:disable Style/MissingRespondToMissing
36
+ def method_missing(m, *_args)
37
+ puts "There is no method called #{m} - please try again."
38
+ puts "Available methods are:\n"
39
+ puts public_methods(false)
40
+ end
41
+ # rubocop:enable Style/MethodMissingSuper
42
+ # rubocop:enable Style/MissingRespondToMissing
43
+
44
+ # User API
45
+
46
+ # Creation
47
+ def create(options)
48
+ raise 'Options must be a hash' unless options.is_a?(Hash)
49
+
50
+ @default[:api_paste_name] = options[:api_paste_name] || 'AutoPaste: ' + Time.now.strftime('%d/%m/%Y %H:%M:%S')
51
+ @default[:api_option] = 'paste'
52
+ @default[:api_paste_code] = options[:api_paste_code]
53
+
54
+ rsp = RestClient.post @url + 'post.php', @default
55
+
56
+ rsp.body
57
+ end
58
+
59
+ def delete(pkey)
60
+ raise 'Paste key must be a string' unless pkey.is_a?(String)
61
+
62
+ @default[:api_option] = 'delete'
63
+ @default[:api_paste_key] = pkey
64
+ rsp = RestClient.post @url + 'post.php', @default
65
+
66
+ rsp.body
67
+ end
68
+
69
+ # User info methods
70
+ def user
71
+ @default[:api_option] = 'userdetails'
72
+ rsp = RestClient.post @url + 'post.php', @default
73
+
74
+ rsp.body
75
+ end
76
+
77
+ # Collections
78
+ def list_user_entries(num)
79
+ raise 'Please provide integer as an argument' unless num.is_a?(Integer)
80
+
81
+ @default[:api_results_limit] = num
82
+ @default[:api_option] = 'list'
83
+ rsp = RestClient.post @url + 'post.php', @default
84
+
85
+ rsp.body
86
+ end
87
+
88
+ alias pastes list_user_entries
89
+
90
+ def raw_paste(pkey)
91
+ raise 'Paste key must be a string' unless pkey.is_a?(String)
92
+
93
+ rsp = RestClient.post @raw + pkey, @default
94
+
95
+ rsp.body
96
+ end
97
+
98
+ # Misc
99
+
100
+ def options
101
+ @default
102
+ end
103
+
104
+ protected
105
+
106
+ def user_key
107
+ rsp = RestClient.post @url + 'login.php', @default
108
+ @default[:api_user_key] = rsp.body
109
+ end
110
+
111
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gal
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - vedranvinko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-17 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
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: A small wrapper for Pastebin API.
84
+ email:
85
+ - vinkovedran@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - gal.gemspec
102
+ - lib/gal.rb
103
+ - lib/gal/version.rb
104
+ homepage: https://gitlab.com/vedranvinko/gal
105
+ licenses:
106
+ - MIT
107
+ metadata:
108
+ homepage_uri: https://gitlab.com/vedranvinko/gal
109
+ source_code_uri: https://gitlab.com/vedranvinko/gal
110
+ changelog_uri: https://gitlab.com/vedranvinko/gal/CHANGELOG.md
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.6.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Pastebin API wrapper
131
+ test_files: []