moodwall 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1a49854035765c11616966aa41cefdafd74e299ae654b4a5aad8b3ec595aac5
4
- data.tar.gz: 4f475c8464408151a7610bde11e9c013d8917bcb721de3597724aeb004b2a4bd
3
+ metadata.gz: e8a87e2546ffca4136d0c4a9b8a4981ae58e6121d1c28c80e8ea50f016f355d9
4
+ data.tar.gz: e449ab812e1043ffb4f428d90380572307314873cac98614ecdb5c4d4b39c87a
5
5
  SHA512:
6
- metadata.gz: ff2f57f261414b17eaa996932934b749a53f788904095ff6ceacae7844611863b9fc386b7518f0301af3ec859eadf0ab1bb1a04ef60f91be0a99fb9bbdb9fb1f
7
- data.tar.gz: e32905d8bdffee5d4d4bb49d1d681497f853ac95ebfe712ae5824a3822f420ed9d003a57e9af2c2a62f8b3e215c0bf59eab4f68dd047a8d4f885ae1d8ad5e7cd
6
+ metadata.gz: 9450dc43b2600adb20beed01a31734853aa02e200799152b67790329fc43ca051493cd7a091414ac24dee210105273c11e7aa676377013ffea57378c9cb73699
7
+ data.tar.gz: eb934e44f1f1a8f1cf4babc2af41a1f871a524026a7c01398e36ea2a4d427b964f1540e6cad3aa6a304b1ad1463d16b2c9ca7d019c007c19dcc901510bce6df7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- moodwall (0.1.2)
4
+ moodwall (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/ad73e69778bb4b5dcbdb/maintainability)](https://codeclimate.com/github/vmikhaliuk/moodwall/maintainability)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/vmikhaliuk/moodwall/badge.svg?branch=master)](https://coveralls.io/github/vmikhaliuk/moodwall?branch=master)
6
6
  [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
7
+ [![Gem Version](https://badge.fury.io/rb/moodwall.svg)](https://badge.fury.io/rb/moodwall)
7
8
 
8
9
  ![Alt text](assets/meme.jpg?raw=true)
9
10
 
@@ -31,6 +32,14 @@ moodwall -c -w or simply moodwall, since its a default option.
31
32
  <!-- To change current mood use: -->
32
33
 
33
34
  moodwall -c -m Winter
35
+
36
+ <!-- To list all moods -->
37
+
38
+ moodwall -l -m
39
+
40
+ <!-- To list all images -->
41
+
42
+ moodwall -l -w
34
43
  ```
35
44
 
36
45
 
@@ -14,13 +14,14 @@ require 'pp'
14
14
 
15
15
  class Moodwall::Optparse
16
16
  class ScriptOptions
17
- attr_accessor :change, :add, :mood, :wallpaper,
17
+ attr_accessor :change, :add, :list,
18
+ :mood, :wallpaper,
18
19
  :path, :mood_name
19
20
 
20
-
21
21
  def initialize
22
22
  self.change = true
23
23
  self.add = false
24
+ self.list = false
24
25
  self.mood = false
25
26
  self.wallpaper = true
26
27
  end
@@ -33,6 +34,8 @@ class Moodwall::Optparse
33
34
  # additional commands
34
35
  change_option(parser)
35
36
  add_option(parser)
37
+ list_option(parser)
38
+
36
39
  wallpaper_option(parser)
37
40
  mood_option(parser)
38
41
 
@@ -64,6 +67,14 @@ class Moodwall::Optparse
64
67
  end
65
68
  end
66
69
 
70
+ def list_option(parser)
71
+ parser.on("-l", "--list", "List [targets]") do
72
+ self.list = true
73
+ self.add = false
74
+ self.change = false
75
+ end
76
+ end
77
+
67
78
  def wallpaper_option(parser)
68
79
  parser.on("-w", "--wallpaper [PATH]", "Specifies wallpaper path") do |path, mood_name|
69
80
  self.wallpaper = true
@@ -73,7 +84,7 @@ class Moodwall::Optparse
73
84
  end
74
85
 
75
86
  def mood_option(parser)
76
- parser.on("-m", "--mood NAME", "Specifies mood name") do |mood_name|
87
+ parser.on("-m", "--mood [NAME]", "Specifies mood name") do |mood_name|
77
88
  self.mood = true
78
89
  self.mood_name = mood_name
79
90
  end
@@ -98,7 +109,7 @@ case
98
109
  when options.add && options.mood && !options.mood_name.nil? && options.path.nil?
99
110
  Moodwall::Mood.new({name: options.mood_name}).save
100
111
  when options.change && options.mood && !options.mood_name.nil?
101
- Moodwall::Mood.set_current(name: options.mood_name)
112
+ Moodwall::Mood.change_current(name: options.mood_name)
102
113
  when options.add && options.wallpaper && !options.path.nil? && !options.mood_name.nil?
103
114
  mood = Moodwall::Mood.find_by_name(options.mood_name)
104
115
  Moodwall::Wallpaper.new({path: options.path, mood_id: mood.id}).save
@@ -106,4 +117,8 @@ when options.change && options.wallpaper
106
117
  executable = Moodwall::Executable.new({ command: "feh", arguments: "--bg-fill" })
107
118
  wallpaper = Moodwall::Wallpaper.sample
108
119
  executable.execute(wallpaper.path)
120
+ when options.list && options.mood
121
+ puts Moodwall::Mood.list_names
122
+ when options.list && options.wallpaper
123
+ puts Moodwall::Wallpaper.list
109
124
  end
@@ -13,19 +13,33 @@ module Moodwall
13
13
  all.find { |m| m.current == true }
14
14
  end
15
15
 
16
- def set_current(name:)
17
- previous = current
18
- if !previous.nil?
19
- previous.current = false
20
- previous.save
21
- end
16
+ def choose_current(name:)
17
+ nullify_current
18
+ choose_new_current(name)
19
+ end
20
+
21
+ def find_by_name(name)
22
+ all.find { |m| m.name.casecmp(name).zero? }
23
+ end
24
+
25
+ def list_names
26
+ all.map(&:name)
27
+ end
28
+
29
+ private
30
+
31
+ def choose_new_current(name)
22
32
  new_one = find_by_name(name)
23
33
  new_one.current = true
24
34
  new_one.save
25
35
  end
26
36
 
27
- def find_by_name(name)
28
- all.find { |m| m.name.casecmp(name).zero? }
37
+ def nullify_current
38
+ previous = current
39
+ unless previous.nil?
40
+ previous.current = false
41
+ previous.save
42
+ end
29
43
  end
30
44
  end
31
45
  end
@@ -1,3 +1,3 @@
1
1
  module Moodwall
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -26,6 +26,10 @@ module Moodwall
26
26
  mood = Moodwall::Mood.current
27
27
  mood.nil? ? all : all.select { |w| w.mood_id == mood.id }
28
28
  end
29
+
30
+ def list
31
+ all.map(&:path)
32
+ end
29
33
  end
30
34
 
31
35
  def save
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = %q{Change wallpapers randomly depending on the moods.}
12
12
  spec.homepage = "https://github.com/vmikhaliuk/moodwall"
13
+ spec.license = "GPL-3.0"
13
14
 
14
15
  # Specify which files should be added to the gem when it is released.
15
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moodwall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valiantsin Mikhaliuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -138,7 +138,8 @@ files:
138
138
  - lib/moodwall/wallpaper.rb
139
139
  - moodwall.gemspec
140
140
  homepage: https://github.com/vmikhaliuk/moodwall
141
- licenses: []
141
+ licenses:
142
+ - GPL-3.0
142
143
  metadata: {}
143
144
  post_install_message:
144
145
  rdoc_options: []