imgclip 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 67ff4048dd87dad1c57c46ab032c6378e73bc077ba9765bda878f04cb012c5db
4
+ data.tar.gz: d4d0020fb558a91bf630ca93af85719289686d5f8127c172398e1e600ed9921d
5
+ SHA512:
6
+ metadata.gz: 938b69f34e98a679023bf13d272a0af612268eb77ac8ee9162c23534ffff657fdfb1a34d372942bb314dffbd9e5c631e3e80ea585303f7c2cf5e2c3d9606272e
7
+ data.tar.gz: 2254cf2c19158c1decae575ea8fc91915e91d71cb13584e4f993428654732046043abc50c740375a34e594c023424788016f468486852797107145e407405db2
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /ext/Makefile
10
+ /ext/extconf.h
11
+ /ext/imgclip.o
12
+ /ext/imgclip.so
13
+ /ext/mkmf.log
14
+ /ext/imgclip/Makefile
15
+ /ext/imgclip/imgclip.o
16
+ /ext/imgclip/imgclip.so
17
+ /ext/imgclip/mkmf.log
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.3
@@ -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 valiantsin.mikhaliuk@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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in imgclip.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ imgclip (0.1.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+ rake-compiler (1.0.5)
11
+ rake
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.17)
18
+ imgclip!
19
+ rake (~> 10.0)
20
+ rake-compiler
21
+
22
+ BUNDLED WITH
23
+ 1.17.1
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Imgclip
2
+
3
+ A simple gem with a native C extension, that allow storing images from clipboard directly into the file.
4
+
5
+ ## Installation
6
+
7
+ gtk is required since extension uses gtk library to retrieve image from clipboard.
8
+
9
+ ```ruby
10
+ gem 'imgclip'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install imgclip
20
+
21
+ ## Usage
22
+
23
+ ``` ruby
24
+ require "imgclip"
25
+ Imgclip.clipboard_to_file PATH #=> returns path or exception
26
+ ```
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/vmikhaliuk/imgclip. 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.
31
+
32
+ ## Code of Conduct
33
+
34
+ Everyone interacting in the Imgclip project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/vmikhaliuk/imgclip/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/extensiontask"
3
+
4
+ Rake::ExtensionTask.new(:imgclip) do |ext|
5
+ ext.lib_dir = "lib/imgclip"
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #endif
@@ -0,0 +1,12 @@
1
+ require "mkmf"
2
+
3
+ exit(1) unless find_executable("pkg-config")
4
+
5
+ $CFLAGS << " " + `pkg-config gtk+-2.0 --cflags`.strip
6
+ $LDFLAGS << " " + `pkg-config gtk+-2.0 --libs`.strip
7
+ $CFLAGS << " -W -Wall"
8
+
9
+ find_header("gtk/gtk.h") || exit(1)
10
+
11
+ create_header
12
+ create_makefile("imgclip/imgclip")
@@ -0,0 +1,40 @@
1
+ #include <ruby.h>
2
+ #include <gtk/gtk.h>
3
+ #include "extconf.h"
4
+
5
+ static VALUE clipboard_to_file(VALUE _self, VALUE path) {
6
+ char* c_path = StringValueCStr(path);
7
+
8
+ Check_Type(path, T_STRING);
9
+
10
+ GtkClipboard *clipboard;
11
+ GdkPixbuf *pixbuf;
12
+
13
+ clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
14
+ pixbuf = gtk_clipboard_wait_for_image(clipboard);
15
+
16
+ if (pixbuf == NULL) {
17
+ rb_raise(rb_eArgError, "Clipboard content could not be converted into an image.");
18
+ }
19
+
20
+ GError *gerror = NULL;
21
+ char* image_type = "jpeg";
22
+ gdk_pixbuf_save(pixbuf, c_path, image_type, &gerror, NULL);
23
+
24
+ if (gerror) {
25
+ g_error_free(gerror);
26
+ rb_raise(rb_eException, "Unable to save clipboard image to %s: %s\n", c_path, gerror->message);
27
+ }
28
+
29
+ if (pixbuf != NULL) {
30
+ g_object_unref(pixbuf);
31
+ }
32
+
33
+ return path;
34
+ }
35
+
36
+ void Init_imgclip() {
37
+ gtk_init(NULL, NULL);
38
+ VALUE mod = rb_define_module("Imgclip");
39
+ rb_define_module_function(mod, "clipboard_to_file", clipboard_to_file, 1);
40
+ }
data/imgclip.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "imgclip/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "imgclip"
7
+ spec.version = Imgclip::VERSION
8
+ spec.authors = ["Valiantsin Mikhaliuk"]
9
+ spec.email = ["valiantsin.mikhaliuk@gmail.com"]
10
+
11
+ spec.summary = %q{Save images from the clipboard!}
12
+ spec.homepage = "https://github.com/vmikhaliuk/imgclip"
13
+ spec.license = "GPL-3.0"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.require_paths = ["lib"]
18
+ spec.extensions = ["ext/imgclip/extconf.rb"]
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.17"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rake-compiler"
26
+ end
data/lib/imgclip.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "imgclip/version"
2
+ module Imgclip; end
3
+ require "imgclip/imgclip"
@@ -0,0 +1,3 @@
1
+ module Imgclip
2
+ VERSION = "0.1.2".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imgclip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Valiantsin Mikhaliuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - valiantsin.mikhaliuk@gmail.com
58
+ executables: []
59
+ extensions:
60
+ - ext/imgclip/extconf.rb
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".ruby-version"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - README.md
69
+ - Rakefile
70
+ - ext/imgclip/extconf.h
71
+ - ext/imgclip/extconf.rb
72
+ - ext/imgclip/imgclip.c
73
+ - imgclip.gemspec
74
+ - lib/imgclip.rb
75
+ - lib/imgclip/version.rb
76
+ homepage: https://github.com/vmikhaliuk/imgclip
77
+ licenses:
78
+ - GPL-3.0
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Save images from the clipboard!
100
+ test_files: []