quotewall 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f05ef141079e1bdf1eddd5ddcc34bcfd1d656426
4
+ data.tar.gz: 3f24da29be3b10263280cc46a68ceb5caaddff3c
5
+ SHA512:
6
+ metadata.gz: 8ae5a5133a7e86c17690b50a0929fc243e4a134ced4df10a8fc3c0219b8b74e28df2f8ace8cd4782e2dd9ec6a77aaddc848c7ac09cd34482466ae10ed6c850f6
7
+ data.tar.gz: baedb590d561ac217cc74bc4cf4999cce300649c3dcd10dd2d2b1df3f3cc66d615d01211cbdb3e640779214117e2f4d3c314fa8be13720e32050ef39a7c75812
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.un~
19
+ *.swp
20
+ wallpaper.jpg
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in quotewall.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Mauro Morales
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Quotewall
2
+
3
+ Generate a beautiful wallpaper from a specified quote
4
+
5
+ ## Dependencies
6
+
7
+ Install dependencies using homebrew
8
+
9
+ ### Imagemagick
10
+
11
+ Brew imagemagick
12
+
13
+ brew install imagemagick
14
+
15
+ ### Ghostscript
16
+
17
+ brew install ghostscript
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ gem 'quotewall'
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install quotewall
32
+
33
+ ## Usage
34
+
35
+ TODO: Write usage instructions here
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
4
+ require 'rspec/core/rake_task'
5
+
6
+ Cucumber::Rake::Task.new(:features) do |t|
7
+ t.cucumber_opts = "features --format pretty -x"
8
+ t.fork = false
9
+ end
10
+
11
+ Cucumber::Rake::Task.new(:wip) do |t|
12
+ t.cucumber_opts = "features --format pretty -x --tags @wip"
13
+ t.fork = false
14
+ end
15
+
16
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'optparse'
5
+ require 'quotewall'
6
+
7
+ options = {}
8
+ option_parser = OptionParser.new do |opts|
9
+ executable_name = File.basename($PROGRAM_NAME)
10
+ opts.banner = "Usage: #{executable_name} [options] QUOTE AUTHOR
11
+
12
+ Example: #{executable_name} \"The way to get started is to quit talking and begin doing.\" \"Walt Disney\"
13
+ "
14
+
15
+ opts.on("-h","--help", 'Print this message') do
16
+ options[:help] = true
17
+ end
18
+
19
+ end
20
+
21
+ begin
22
+ option_parser.parse!
23
+ if options.empty? and ARGV.empty?
24
+ puts option_parser.help
25
+ elsif options[:help]
26
+ puts option_parser.help
27
+ elsif !ARGV.empty?
28
+ Quotewall.run(ARGV)
29
+ end
30
+ rescue OptionParser::InvalidArgument => ex
31
+ STDERR.puts ex.message
32
+ STDERR.puts option_parser
33
+ end
@@ -0,0 +1,19 @@
1
+ Feature: CLI functionality
2
+
3
+ Scenario: Get the quotewall help text when no arguments are passed
4
+ When I run `quotewall`
5
+ Then the stdout should contain "help"
6
+
7
+ Scenario: Get the quotewall help text when requested
8
+ When I successfully run `quotewall -h`
9
+ Then the stdout should contain "help"
10
+
11
+ Scenario: Generate a wallpaper from a quote with author
12
+ When I successfully run `quotewall "The way to get started is to quit talking and begin doing" "Walt Disney"
13
+ Then a file named "quotewall.jpg" should exist in the Pictures folder
14
+ And it should be the default wallpaper
15
+
16
+ Scenario: Generate a wallpaper from a quote without author
17
+ When I successfully run `quotewall "The way to get started is to quit talking and begin doing"
18
+ Then a file named "quotewall.jpg" should exist in the Pictures folder
19
+ And it should be the default wallpaper
@@ -0,0 +1,15 @@
1
+ require 'quotewall'
2
+
3
+ When(/^I successfully run `quotewall "(.*?)"$/) do |quote|
4
+ `quotewall "#{quote}"`
5
+ end
6
+
7
+ Then(/^a file named "(.*?)" should exist in the Pictures folder$/) do |file_name|
8
+ pictures_path = File.expand_path("~/Pictures")
9
+ @wall_path = File.join(pictures_path, file_name)
10
+ File.exists?(@wall_path)
11
+ end
12
+
13
+ Then(/^it should be the default wallpaper$/) do
14
+ Quotewall.read_default_background.include?(@wall_path).should be_true
15
+ end
@@ -0,0 +1,12 @@
1
+ require 'aruba/cucumber'
2
+
3
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
4
+
5
+ Before do
6
+ @original_rubylib = ENV['RUBYLIB']
7
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
8
+ end
9
+
10
+ After do
11
+ ENV['RUBYLIB'] = @original_rubylib
12
+ end
@@ -0,0 +1,84 @@
1
+ require 'rubygems'
2
+ require 'rmagick'
3
+ require 'plist'
4
+ require "quotewall/version"
5
+
6
+ module Quotewall
7
+
8
+ def self.check_osx
9
+ `sw_vers -productName`.include?("Mac OS X")
10
+ end
11
+
12
+ def self.display
13
+ result = Plist::parse_xml(`system_profiler -xml SPDisplaysDataType`)
14
+ width, height = result[0]["_items"][0]["spdisplays_ndrvs"][0]["spdisplays_resolution"].split("x")
15
+ {:width => width.to_i,
16
+ :height => height.to_i
17
+ }
18
+ end
19
+
20
+ def self.rearange(string)
21
+ if string.size < 35
22
+ return [string]
23
+ else
24
+ lines = []
25
+ idx = 0
26
+ string.split(" ").each do |word|
27
+ lines[idx] = "" if lines[idx].nil?
28
+ if lines[idx].size + word.size < 35
29
+ lines[idx] = "#{lines[idx]} #{word}"
30
+ else
31
+ idx += 1
32
+ lines[idx] = word
33
+ end
34
+ end
35
+ return lines
36
+ end
37
+ end
38
+
39
+ def self.run(args)
40
+ img = Magick::Image.new(display[:width],display[:height]) { self.background_color = "#0d1030" }
41
+ text = Magick::Draw.new
42
+ who = args.size == 2 ? args[1] : "Anonymous"
43
+ lines = rearange(args[0])
44
+ lines.each_with_index do |line, idx|
45
+ y = ( (idx + 1) * 76) - ((lines.size + 1) * 35)
46
+ text.annotate(img, 0, 0, 0, y, line.strip) {
47
+ self.font_family = 'Geneva'
48
+ self.gravity = Magick::CenterGravity
49
+ self.pointsize = 64
50
+ self.stroke = 'transparent'
51
+ self.fill = '#79c7e3'
52
+ self.font_weight = Magick::BoldWeight
53
+ }
54
+ end
55
+
56
+ text.annotate(img, 0, 0, 300, 100, "- #{who}") {
57
+ self.font_family = 'Geneva'
58
+ self.gravity = Magick::SouthEastGravity
59
+ self.pointsize = 64
60
+ self.stroke = 'transparent'
61
+ self.fill = '#f70352'
62
+ self.font_weight = Magick::NormalWeight
63
+ }
64
+
65
+ pictures_path = File.expand_path("~/Pictures")
66
+ img.write(File.join(pictures_path, "quotewall.jpg"))
67
+ wall_path = File.join(pictures_path, "quotewall.jpg")
68
+ set_default_background(wall_path)
69
+ refresh_background
70
+
71
+ end
72
+
73
+ def self.set_default_background(wall_path)
74
+ `defaults write com.apple.desktop Background '{default = {ImageFilePath = "#{wall_path}"; }; }'`
75
+ end
76
+
77
+ def self.read_default_background
78
+ `defaults read com.apple.desktop Background`
79
+ end
80
+
81
+ def self.refresh_background
82
+ `killall Dock`
83
+ end
84
+ end
@@ -0,0 +1,3 @@
1
+ module Quotewall
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'quotewall/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "quotewall"
8
+ spec.version = Quotewall::VERSION
9
+ spec.authors = ["Mauro Morales"]
10
+ spec.email = ["contact@mauromorales.com"]
11
+ spec.description = "Generate a beautiful wallpaper from a specified quote"
12
+ spec.summary = "Generate a beautiful wallpaper from a specified quote"
13
+ spec.homepage = "https://github.com/mauromorales/quotewall"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = ['quotewall'] #spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rmagick"
22
+ spec.add_dependency "plist"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "aruba"
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'rubygems'
3
+ require 'quotewall'
4
+
5
+ describe "Dependencies" do
6
+
7
+ it "should be running on OS X" do
8
+ Quotewall::check_osx.should be_true
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'rubygems'
3
+ require 'quotewall'
4
+
5
+ describe "Display" do
6
+
7
+ it "should detect the display size" do
8
+ Quotewall::display[:width].should > 0
9
+ Quotewall::display[:height].should > 0
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'rubygems'
3
+ require 'quotewall'
4
+
5
+ describe "Images" do
6
+
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+ require 'quotewall'
4
+
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quotewall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mauro Morales
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
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: plist
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: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '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: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aruba
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Generate a beautiful wallpaper from a specified quote
98
+ email:
99
+ - contact@mauromorales.com
100
+ executables:
101
+ - quotewall
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .ruby-version
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/quotewall
112
+ - features/app.feature
113
+ - features/step_definitions/app_steps.rb
114
+ - features/support/env.rb
115
+ - lib/quotewall.rb
116
+ - lib/quotewall/version.rb
117
+ - quotewall.gemspec
118
+ - spec/quotewall/dependencies_spec.rb
119
+ - spec/quotewall/display_spec.rb
120
+ - spec/quotewall/images_spec.rb
121
+ - spec/spec.opts
122
+ - spec/spec_helper.rb
123
+ homepage: https://github.com/mauromorales/quotewall
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.0.3
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Generate a beautiful wallpaper from a specified quote
147
+ test_files:
148
+ - features/app.feature
149
+ - features/step_definitions/app_steps.rb
150
+ - features/support/env.rb
151
+ - spec/quotewall/dependencies_spec.rb
152
+ - spec/quotewall/display_spec.rb
153
+ - spec/quotewall/images_spec.rb
154
+ - spec/spec.opts
155
+ - spec/spec_helper.rb