trollme 0.1.0

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
+ SHA1:
3
+ metadata.gz: 73e456b46f30bd41d1aa3690b18bc44741b92c36
4
+ data.tar.gz: d13d1f1ba3b50836878b64e6aaadc58dc22a6430
5
+ SHA512:
6
+ metadata.gz: 4a896689dbfbd54df365c2ed3897e453f97a8c7bd9fb425f6dae5f128ffdd5f2ea443137eaaf0a30cc6235de344ae18ac222e75a1dffdf025696e0e7cc2deaf9
7
+ data.tar.gz: 6f6e096c62050244a55379ae8e9e405b4fbf7659bbce417358831eccbc4723bf5c10731187ab2d1befbf0057d51738d7316d444b084b2f62eda7e3f48926f69f
@@ -0,0 +1,16 @@
1
+ /.DS_STORE
2
+ *.gem
3
+ /.bundle/
4
+ /.yardoc
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ #swap file
16
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.0
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 trollme.gemspec
6
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trollme (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ fakefs (0.13.3)
12
+ method_source (0.9.0)
13
+ pry (0.11.3)
14
+ coderay (~> 1.1.0)
15
+ method_source (~> 0.9.0)
16
+ rake (10.5.0)
17
+ rspec (3.7.0)
18
+ rspec-core (~> 3.7.0)
19
+ rspec-expectations (~> 3.7.0)
20
+ rspec-mocks (~> 3.7.0)
21
+ rspec-core (3.7.1)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-expectations (3.7.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-mocks (3.7.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-support (3.7.1)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler (~> 1.16)
36
+ fakefs
37
+ pry
38
+ rake (~> 10.0)
39
+ rspec (~> 3.0)
40
+ trollme!
41
+
42
+ BUNDLED WITH
43
+ 1.16.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ruffeng
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,39 @@
1
+ # Trollme
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/trollme`. 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
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'trollme'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install trollme
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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
+
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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/trollme.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "trollme"
5
+
6
+ Trollme.run
7
+ require "irb"
8
+ 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,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trollme'
4
+
5
+ Trollme.run
@@ -0,0 +1,12 @@
1
+ require 'trollme/version'
2
+ require 'trollme/downloader'
3
+ require 'trollme/change_background'
4
+
5
+ module Trollme
6
+ module_function
7
+
8
+ def run
9
+ path = Downloader.call
10
+ ChangeBackground.call(path)
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Trollme
2
+ module ChangeBackground
3
+ module_function
4
+
5
+ def call(path)
6
+ result = system("osascript -e 'tell application \"System Events\" to set picture of every desktop to (\"#{path}\" as POSIX file as alias)' ")
7
+ raise 'an error ocurred when changing the background' unless result
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,65 @@
1
+ require 'pry'
2
+ require 'open-uri'
3
+ module Trollme
4
+ module Downloader
5
+ module_function
6
+
7
+ SetFolder = Class.new(RuntimeError)
8
+ OpenFile = Class.new(RuntimeError)
9
+ SaveFile = Class.new(RuntimeError)
10
+
11
+ PICTURE = 'mairena.jpg'.freeze
12
+ URL = 'https://ep00.epimg.net/elpais/imagenes/2017/06/14/fotorrelato/1497431610_448226_1497432498_album_normal.jpg'.freeze
13
+
14
+ def call
15
+ set_folder
16
+ if File.exist?(PICTURE)
17
+ get_existing_file(PICTURE)
18
+ else
19
+ download_image_and_return_path
20
+ end
21
+ rescue SetFolder
22
+ abort "Something went wrong to set your folder's download directory"
23
+ rescue OpenFile
24
+ abort 'Was not possible to open the image from internet'
25
+ rescue SaveFile
26
+ abort 'Was not possible to create a file'
27
+ end
28
+
29
+ class << self
30
+ private
31
+
32
+ def set_folder
33
+ Dir.chdir(File.expand_path('~/Downloads'))
34
+ rescue Errno::ENOENT
35
+ raise SetFolder
36
+ end
37
+
38
+ def get_existing_file(path)
39
+ "#{Dir.pwd}/#{path}"
40
+ end
41
+
42
+ def download_image_and_return_path
43
+ file = File.open(PICTURE, 'wb') { |new_file| write_image(new_file) }
44
+ get_existing_file(file.path)
45
+ rescue Errno::ENOENT
46
+ rollback
47
+ raise SaveFile
48
+ end
49
+
50
+ def write_image(file)
51
+ file << open(URL).read
52
+ rescue Errno::ENOENT
53
+ rollback
54
+ raise OpenFile
55
+ rescue SocketError
56
+ rollback
57
+ raise OpenFile
58
+ end
59
+
60
+ def rollback
61
+ File.delete(PICTURE)
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Trollme
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "trollme/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trollme"
8
+ spec.version = Trollme::VERSION
9
+ spec.authors = ["Ruffeng"]
10
+ spec.email = ["ruffeng@gmail.com"]
11
+ spec.homepage = 'http://rubygems.org/gems/trollme'
12
+ spec.summary = %q{Gem to troll your colleagues from the office.}
13
+ spec.description = %q{This gem let's you change the desktop background from your colleagues. Perfect for trolling those who left the computer unlocked}
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = 'trollme'
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'fakefs', '~> 0.13'
25
+ spec.add_development_dependency 'pry', '~> 0.11'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trollme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ruffeng
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-25 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fakefs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.11'
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: This gem let's you change the desktop background from your colleagues.
84
+ Perfect for trolling those who left the computer unlocked
85
+ email:
86
+ - ruffeng@gmail.com
87
+ executables:
88
+ - trollme
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - exe/trollme
103
+ - lib/trollme.rb
104
+ - lib/trollme/change_background.rb
105
+ - lib/trollme/downloader.rb
106
+ - lib/trollme/version.rb
107
+ - trollme.gemspec
108
+ homepage: http://rubygems.org/gems/trollme
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.6.11
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Gem to troll your colleagues from the office.
132
+ test_files: []