rubygems-sing 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +8 -0
- data/lib/rubygems/commands/sing_command.rb +68 -20
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 1.2.0 / 2010-01-27
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
|
5
|
+
* Added --verbose, to print more like a player piano (blank lines in between).
|
6
|
+
* Added -r to sing gems you REALLY don't want to install (rails, sans deps).
|
7
|
+
* Added musical notes to output. (topFUNkay! OW!)
|
8
|
+
|
1
9
|
=== 1.1.0 / 2010-01-26
|
2
10
|
|
3
11
|
* 1 minor enhancement:
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'rubygems/command'
|
2
3
|
require 'rubygems/version_option'
|
3
4
|
require 'rubygems/text'
|
5
|
+
require 'rubygems/installer'
|
4
6
|
|
5
7
|
require 'midiator'
|
6
8
|
require 'English'
|
@@ -9,19 +11,20 @@ require 'English'
|
|
9
11
|
# gem command to "sing" the implementation of a gem.
|
10
12
|
|
11
13
|
class Gem::Commands::SingCommand < Gem::Command
|
12
|
-
VERSION = '1.
|
14
|
+
VERSION = '1.2.0'
|
13
15
|
|
14
16
|
include MIDIator::Notes
|
15
17
|
include MIDIator::Drums
|
16
18
|
|
17
19
|
include Gem::VersionOption
|
18
|
-
|
20
|
+
include Gem::LocalRemoteOptions
|
19
21
|
|
20
22
|
def initialize
|
21
23
|
super("sing", "\"Sing\" a gem's implementation",
|
22
24
|
:version => Gem::Requirement.default)
|
23
25
|
|
24
26
|
add_version_option
|
27
|
+
add_local_remote_options
|
25
28
|
end
|
26
29
|
|
27
30
|
def arguments # :nodoc:
|
@@ -39,16 +42,53 @@ class Gem::Commands::SingCommand < Gem::Command
|
|
39
42
|
def execute
|
40
43
|
name = get_one_gem_name
|
41
44
|
|
42
|
-
|
43
|
-
specs = Gem.source_index.search dep
|
45
|
+
base = files = nil
|
44
46
|
|
45
|
-
if
|
46
|
-
|
47
|
-
|
47
|
+
if remote? then
|
48
|
+
version = options[:version] || Gem::Requirement.default
|
49
|
+
all = Gem::Requirement.default
|
50
|
+
dep = Gem::Dependency.new name, version
|
51
|
+
|
52
|
+
specs_and_sources = Gem::SpecFetcher.fetcher.fetch dep
|
53
|
+
|
54
|
+
spec, source_uri = specs_and_sources.sort_by { |spec,| spec.version }.last
|
55
|
+
|
56
|
+
alert_error "Could not find #{name} in any repository" unless spec
|
57
|
+
|
58
|
+
gem_path = File.join "/tmp", spec.file_name
|
59
|
+
|
60
|
+
unless File.file? gem_path then
|
61
|
+
path = Gem::RemoteFetcher.fetcher.download spec, source_uri
|
62
|
+
FileUtils.mv path, gem_path
|
63
|
+
end
|
64
|
+
|
65
|
+
dir_path = File.join "/tmp", File.basename(gem_path, '.gem')
|
66
|
+
|
67
|
+
unless File.directory? dir_path then
|
68
|
+
FileUtils.mkdir_p dir_path
|
69
|
+
Gem::Installer.new(gem_path, :unpack => true).unpack dir_path
|
70
|
+
end
|
71
|
+
|
72
|
+
Dir.chdir dir_path do
|
73
|
+
files = spec.require_paths.map { |d| Dir["#{d}/**/*.rb"] }.flatten.sort
|
74
|
+
end
|
75
|
+
|
76
|
+
base = dir_path
|
77
|
+
else
|
78
|
+
dep = Gem::Dependency.new name, options[:version]
|
79
|
+
specs = Gem.source_index.search dep
|
80
|
+
|
81
|
+
if specs.empty? then
|
82
|
+
alert_error "No installed gem #{dep}"
|
83
|
+
terminate_interaction 1
|
84
|
+
end
|
85
|
+
|
86
|
+
spec = specs.last
|
87
|
+
base = spec.full_gem_path
|
88
|
+
files = spec.lib_files
|
48
89
|
end
|
49
90
|
|
50
|
-
|
51
|
-
base = spec.full_gem_path
|
91
|
+
$stdout.sync = true
|
52
92
|
|
53
93
|
##
|
54
94
|
# Special thanks to Ben Bleything for midiator and help getting
|
@@ -67,31 +107,39 @@ class Gem::Commands::SingCommand < Gem::Command
|
|
67
107
|
|
68
108
|
# TODO: eventually add ability to play actual AST
|
69
109
|
|
70
|
-
|
110
|
+
files.each do |path|
|
71
111
|
full_path = File.join base, path
|
112
|
+
|
113
|
+
next unless File.file? full_path # rails is run by MORONS
|
114
|
+
|
72
115
|
warn path
|
73
116
|
|
74
117
|
line_number_of_last_end = 0
|
75
|
-
File.foreach
|
118
|
+
File.foreach full_path do |line|
|
76
119
|
if line =~ /^(\s+)end$/ then
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
120
|
+
distance = $INPUT_LINE_NUMBER - line_number_of_last_end
|
121
|
+
note_character = "♩"
|
122
|
+
duration = case distance
|
123
|
+
when 0 .. 3
|
124
|
+
note_character = "♪"
|
125
|
+
0.125
|
126
|
+
when 4 .. 10
|
127
|
+
note_character = "♩"
|
82
128
|
0.25
|
83
129
|
when 11 .. 30
|
130
|
+
note_character = "d"
|
84
131
|
0.5
|
85
132
|
else
|
133
|
+
note_character = "o"
|
86
134
|
1.0
|
87
135
|
end
|
88
|
-
|
89
|
-
duration *= 0.8 # tweaking for now...
|
90
|
-
|
91
136
|
line_number_of_last_end = $INPUT_LINE_NUMBER
|
92
137
|
num_spaces = $1.size
|
93
|
-
|
138
|
+
|
139
|
+
print "#{note_character} "
|
94
140
|
print line
|
141
|
+
midi.play scale[ num_spaces / 2 ], duration
|
142
|
+
print "\n" * (duration * 4).to_i if Gem.configuration.really_verbose
|
95
143
|
end
|
96
144
|
end
|
97
145
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-sing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
FBHgymkyj/AOSqKRIpXPhjC6
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2010-01-
|
33
|
+
date: 2010-01-27 00:00:00 -08:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|