get_happy 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27b12400a66d33ca6bcfe1e9ea17c2eb29d618be
4
- data.tar.gz: a572a984ac4f493982fbba578d2f5a8cf46c2352
3
+ metadata.gz: f70c53798f7c41f99d0566fe0290e8a02a7d20f8
4
+ data.tar.gz: 2282f78b01a237555507c1374a13513227044940
5
5
  SHA512:
6
- metadata.gz: d3ac59572d4c2e20b5cbe6f9259aae463fb7b0549c273428e890b393efffd7a928c5f1ed91312e08a2d18d6875741d41e4eef3ae148f232bbf3829d3726753b1
7
- data.tar.gz: b37bbd0223959d4218f5d1da3a6a0acc431d7436f681c622ca12c693b06515731b33e268944928654369d2a8d4799be854c596e68a7fc34ed59e0058fc6f69b0
6
+ metadata.gz: 695fdb1ff5f852f0828c2ac6919b10d50a4266001630760090b95d1c048f5114431f630f9ad79f2b143cc273466b9a6ed9600eab80648b27cff65f891a3d6520
7
+ data.tar.gz: 97a02dd86e53a8715489ab5e8ce0a26b001e1bb9047cd4b2ea7bf8cf3b6b8867cf8761236ae80986a2343ce3a5ea95493fb48fe222eab19c2a7e305debcc9299
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
12
+
data/README.md CHANGED
@@ -40,34 +40,35 @@ Play a random song
40
40
  List collection
41
41
 
42
42
  $ get_happy list
43
- => ["https://www.youtube.com/watch?v=s3Q80mk7bxE", "https://www.youtube.com/watch?v=s3Q80mk7bxE,"]
43
+ Ioannis Total 4
44
+ 🚀 https://www.youtube.com/watch?v=s3Q80mk7bxE
45
+ 🚀 https://www.youtube.com/watch?v=LxDhlzJR4XQ
46
+ 🚀 https://www.youtube.com/watch?v=HqYnevHibaI
47
+ 🚀 https://www.youtube.com/watch?v=8kMZcA5oEAA
44
48
 
45
49
  Seed with some sample urls
46
50
 
47
51
  $ get_happy seed
48
- => ["https://www.youtube.com/watch?v=s3Q80mk7bxE"]
52
+
49
53
 
50
54
  Clean collection
51
55
 
52
56
  $ get_happy clean
53
- => []
57
+ => Collection is empty
54
58
 
55
59
  Add a link to collection
56
60
 
57
61
  $ get_happy add https://www.youtube.com/watch?v=s3Q80mk7bxE
58
- => ["https://www.youtube.com/watch?v=s3Q80mk7bxE", "https://www.youtube.com/watch?v=s3Q80mk7bxE"]
59
62
 
60
63
  Or add multiply
61
64
 
62
65
 
63
66
  $ get_happy add https://www.youtube.com/watch?v=s3Q80mk7bxE, https://www.youtube.com/watch?v=PWgvGjAhvIw
64
- => ["https://www.youtube.com/watch?v=s3Q80mk7bxE", "https://www.youtube.com/watch?v=s3Q80mk7bxE"]
65
67
 
66
68
  Delete a url
67
69
 
68
70
 
69
71
  $ get_happy delete https://www.youtube.com/watch?v=s3Q80mk7bxE
70
- => ["https://www.youtube.com/watch?v=s3Q80mk7bxE", "https://www.youtube.com/watch?v=s3Q80mk7bxE"]
71
72
 
72
73
 
73
74
  ## Contributing
data/Rakefile CHANGED
@@ -1,5 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'bundler/gem_tasks'
2
4
 
3
5
  task :build_local do
4
- system "rake build && rake install && get_happy"
5
- end
6
+ system "rake build && rake install"
7
+ end
8
+
9
+ task :default => :spec
10
+
data/get_happy.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = GetHappy::VERSION
9
9
  spec.authors = ["Ioannis Kolovos"]
10
10
  spec.email = ["yannis.kolovos@gmail.com"]
11
- spec.summary = "Get Happy"
12
- spec.description = "Get Happy"
11
+ spec.summary = "A Gem to make you happy!"
12
+ spec.description = "Creates a collection with your music favorite links and opens a random one"
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -20,6 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = ['get_happy']
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_runtime_dependency "thor"
24
-
23
+ spec.add_development_dependency "coveralls", "~> 0.7.11"
24
+ spec.add_development_dependency "minitest", "~> 5.5.1"
25
+ spec.add_development_dependency "rspec", "~> 3.2.0"
26
+ spec.add_development_dependency "guard", "~> 2.12.5"
27
+ spec.add_development_dependency "guard-rspec", "~> 4.5.0"
28
+ spec.add_runtime_dependency "thor", "~> 0.19.1"
25
29
  end
data/lib/get_happy/cli.rb CHANGED
@@ -1,15 +1,18 @@
1
1
  module GetHappy
2
2
  class CLI < Thor
3
+ include Thor::Actions
4
+
5
+ CAPTURE_COMMANDS_OUTPUT = !ENV['GH_CAPTURE_COMMANDS_OUTPUT'].nil?
3
6
 
4
7
  desc "play", "play a random song"
5
8
  def play
6
9
  @collection ||= GetHappy.get_collection
7
- system("open", @collection.sample) unless @collection.empty?
8
- puts "Collection is empty! get_happy seed to seed" if @collection.empty?
10
+ run("open #{@collection.sample}", :capture => CAPTURE_COMMANDS_OUTPUT) unless @collection.empty?
11
+ say "Collection is empty! get_happy seed to seed" if @collection.empty?
9
12
  end
10
13
 
11
-
12
- desc "add [LINKS]", "add a link to collection"
14
+
15
+ desc "add [LINKS]", "add a link to collection"
13
16
  def add(*links)
14
17
  @collection ||= GetHappy.get_collection
15
18
  links.each {|link| @collection << link.to_s}
@@ -22,20 +25,19 @@ module GetHappy
22
25
  @collection ||= GetHappy.get_collection
23
26
  user = `echo $USER`.gsub("\n", "")
24
27
 
25
- puts " \n"
26
- puts "\e[1m\e[4m#{user} Total #{@collection.size}\e[0m \n"
27
- # puts @collection.join("\n")
28
+ say " \n"
29
+ say "\e[1m\e[4m#{user} Total #{@collection.size}\e[0m \n\n"
28
30
  @collection.each do |item|
29
- puts "\e[92m🚀 #{item}"
31
+ say "🚀 #{item}" , :green
30
32
  end
31
- puts "\e[0m\n"
33
+ say "\n"
32
34
  end
33
35
 
34
36
  desc "clean", "clean collection"
35
37
  def clean
36
38
  @collection = []
37
39
  GetHappy.write_collection([])
38
- puts "Collection is empty"
40
+ say "Collection is empty"
39
41
  end
40
42
 
41
43
  desc "seed", "seed with some sample urls"
@@ -54,4 +56,7 @@ module GetHappy
54
56
  end
55
57
 
56
58
  end
57
- end
59
+ end
60
+
61
+
62
+
@@ -27,11 +27,11 @@ module GetHappy
27
27
  FileUtils.mkdir_p(COLLECTION_DIR)
28
28
  end
29
29
 
30
- File.open(COLLECTION, "w+") do |file|
30
+ File.open(COLLECTION, "w") do |file|
31
31
  file.write [].to_yaml
32
32
  end unless File.file?(COLLECTION)
33
33
 
34
- YAML::load_file(COLLECTION) || []
34
+ YAML::load_file(COLLECTION)
35
35
  end
36
36
 
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module GetHappy
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/get_happy.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require "get_happy/version"
2
2
  require "thor"
3
3
  require 'yaml'
4
- require 'fileutils'
5
4
  require "get_happy/cli"
6
5
  require "get_happy/engine"
7
6
 
8
7
 
8
+
9
9
  module GetHappy
10
10
  class CLI
11
11
  default_task :play
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe GetHappy do
4
+ before(:each) do
5
+ FileUtils.rm_rf(GetHappy::COLLECTION_DIR)
6
+ end
7
+
8
+ it 'create directories' do
9
+ expect(File.directory?(GetHappy::COLLECTION_DIR)).to be false
10
+ expect(File.file?(GetHappy::COLLECTION)).to be false
11
+ out = capture_io{ GetHappy::CLI.start %w{ list} }.join ''
12
+ expect(File.directory?(GetHappy::COLLECTION_DIR)).to be true
13
+ expect(File.file?(GetHappy::COLLECTION)).to be true
14
+ end
15
+
16
+
17
+ it "methods" do
18
+ script = GetHappy::CLI.new
19
+ script.respond_to? :add
20
+ %i(add clean delete list play seed).each do |method|
21
+ expect(script.methods).to include method
22
+ expect(script).to respond_to method
23
+ end
24
+ end
25
+
26
+ it "should list" do
27
+ out = capture_io{ GetHappy::CLI.start %w{ list} }.join ''
28
+ expect(out).to match /Ioannis Total./
29
+ end
30
+
31
+
32
+ it "should delete" do
33
+ GetHappy::CLI.start %w{ }
34
+ expect(YAML::load_file(GetHappy::COLLECTION)).to be_empty
35
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
36
+ expect(YAML::load_file(GetHappy::COLLECTION)).to include("https://www.youtube.com/watch?v=u9h7Teiyvc8")
37
+
38
+ GetHappy::CLI.start %w{ delete https://www.youtube.com/watch?v=u9h7Teiyvc8}
39
+ expect(YAML::load_file(GetHappy::COLLECTION)).not_to include("https://www.youtube.com/watch?v=u9h7Teiyvc8")
40
+ end
41
+
42
+ it "should clean" do
43
+ GetHappy::CLI.start %w{ seed}
44
+ expect(YAML::load_file(GetHappy::COLLECTION)).not_to be_empty
45
+ GetHappy::CLI.start %w{ clean}
46
+ expect(YAML::load_file(GetHappy::COLLECTION)).to be_empty
47
+ end
48
+
49
+ it "should play" do
50
+ GetHappy::CLI.start %w{ seed}
51
+
52
+ out, err = capture_io do
53
+ GetHappy::CLI.start %w{ play}
54
+ end
55
+
56
+ expect(out.strip).to include "run open https://www.youtube.com/watch?v="
57
+ expect(err).to be_empty
58
+ end
59
+
60
+
61
+ it "should seed" do
62
+ GetHappy::CLI.start %w{}
63
+ expect(YAML::load_file(GetHappy::COLLECTION)).to be_empty
64
+ GetHappy::CLI.start %w{ seed}
65
+ expect(YAML::load_file(GetHappy::COLLECTION)).not_to be_empty
66
+ end
67
+
68
+ it "should add" do
69
+ GetHappy::CLI.start %w{}
70
+ before = YAML::load_file(GetHappy::COLLECTION)
71
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
72
+ after = YAML::load_file(GetHappy::COLLECTION)
73
+
74
+ expect(before).to_not be after
75
+ expect(after.first).to match /u9h7Teiyvc8/
76
+ end
77
+
78
+
79
+
80
+ it "should not add duplicates" do
81
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
82
+ expect(YAML::load_file(GetHappy::COLLECTION).size).to eq 1
83
+ GetHappy::CLI.start %w{ add https://www.youtube.com/watch?v=u9h7Teiyvc8}
84
+ expect(YAML::load_file(GetHappy::COLLECTION).size).to eq 1
85
+ end
86
+
87
+
88
+
89
+ end
90
+
@@ -0,0 +1,18 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
7
+ require 'minitest'
8
+ require 'minitest/unit'
9
+ require 'yaml'
10
+ require 'thor'
11
+ require 'fileutils'
12
+ require 'get_happy'
13
+ require 'rspec'
14
+
15
+
16
+ RSpec.configure do |c|
17
+ c.include MiniTest::Assertions
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_happy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ioannis Kolovos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-28 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,21 +38,92 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.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.7.11
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.5.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.5.1
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.2.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.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.12.5
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.12.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 4.5.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 4.5.0
41
111
  - !ruby/object:Gem::Dependency
42
112
  name: thor
43
113
  requirement: !ruby/object:Gem::Requirement
44
114
  requirements:
45
- - - ">="
115
+ - - "~>"
46
116
  - !ruby/object:Gem::Version
47
- version: '0'
117
+ version: 0.19.1
48
118
  type: :runtime
49
119
  prerelease: false
50
120
  version_requirements: !ruby/object:Gem::Requirement
51
121
  requirements:
52
- - - ">="
122
+ - - "~>"
53
123
  - !ruby/object:Gem::Version
54
- version: '0'
55
- description: Get Happy
124
+ version: 0.19.1
125
+ description: Creates a collection with your music favorite links and opens a random
126
+ one
56
127
  email:
57
128
  - yannis.kolovos@gmail.com
58
129
  executables:
@@ -62,6 +133,7 @@ extra_rdoc_files: []
62
133
  files:
63
134
  - ".gitignore"
64
135
  - Gemfile
136
+ - Guardfile
65
137
  - LICENSE.txt
66
138
  - README.md
67
139
  - Rakefile
@@ -71,7 +143,9 @@ files:
71
143
  - lib/get_happy/cli.rb
72
144
  - lib/get_happy/engine.rb
73
145
  - lib/get_happy/version.rb
146
+ - spec/get_happpy_spec.rb
74
147
  - spec/screen_shot.png
148
+ - spec/spec_helper.rb
75
149
  homepage: ''
76
150
  licenses:
77
151
  - MIT
@@ -95,6 +169,8 @@ rubyforge_project:
95
169
  rubygems_version: 2.2.2
96
170
  signing_key:
97
171
  specification_version: 4
98
- summary: Get Happy
172
+ summary: A Gem to make you happy!
99
173
  test_files:
174
+ - spec/get_happpy_spec.rb
100
175
  - spec/screen_shot.png
176
+ - spec/spec_helper.rb