oldness 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -3
- data/Gemfile +2 -1
- data/lib/oldness/cli.rb +1 -1
- data/lib/oldness/medium.rb +13 -9
- data/lib/oldness/version.rb +7 -1
- data/spec/cli_spec.rb +27 -14
- data/spec/medium_spec.rb +17 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks.thor +11 -16
- metadata +51 -1
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/oldness/cli.rb
CHANGED
@@ -23,7 +23,7 @@ module Oldness
|
|
23
23
|
|
24
24
|
desc "media", "List what mediums can be used in other commands"
|
25
25
|
def media
|
26
|
-
print
|
26
|
+
print "#{Medium.list(:formatted=>true)}"
|
27
27
|
end
|
28
28
|
map "mediums" => "media"
|
29
29
|
map "list" => "media"
|
data/lib/oldness/medium.rb
CHANGED
@@ -2,16 +2,8 @@ require 'date'
|
|
2
2
|
require 'oldness/work'
|
3
3
|
|
4
4
|
module Oldness
|
5
|
-
def self.media
|
6
|
-
list = []
|
7
|
-
ObjectSpace.each_object(Class) do |c|
|
8
|
-
next unless c.superclass == Medium
|
9
|
-
list << c
|
10
|
-
end
|
11
|
-
list
|
12
|
-
end
|
13
|
-
|
14
5
|
class Medium
|
6
|
+
@descendents = []
|
15
7
|
def self.ranges(args={})
|
16
8
|
current_date = args[:when] ? args[:when] : Date.today
|
17
9
|
span = (current_date-first.date)
|
@@ -53,6 +45,18 @@ module Oldness
|
|
53
45
|
end
|
54
46
|
end
|
55
47
|
|
48
|
+
def self.list(opts={})
|
49
|
+
if opts[:formatted]
|
50
|
+
@descendents.collect(&:to_s).sort.inject("") { |l, c| l + c.downcase.sub("oldness::", "")+"\n" }
|
51
|
+
else
|
52
|
+
@descendents
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.inherited(child)
|
57
|
+
@descendents << child
|
58
|
+
end
|
59
|
+
|
56
60
|
private
|
57
61
|
def self.parse_date(date)
|
58
62
|
begin
|
data/lib/oldness/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -1,31 +1,44 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'stringio'
|
2
3
|
|
3
4
|
module Oldness
|
4
|
-
describe
|
5
|
-
before :
|
6
|
-
|
5
|
+
describe CLI do
|
6
|
+
before :each do
|
7
|
+
@io = StringIO.new
|
8
|
+
$stdout = @io
|
7
9
|
end
|
10
|
+
let(:cli) {CLI.new}
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
def compare(method, medium, date=nil)
|
13
|
+
cli.invoke(method, [medium, date].compact)
|
14
|
+
args = [method, date]
|
15
|
+
args << {:formatted => true} unless method == :first
|
16
|
+
@io.string.should == eval(medium.capitalize).send(*args.compact).to_s + "\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
describe "rate" do
|
21
|
+
it "calls the rating method of the named Medium class with :formatted=>true" do
|
22
|
+
compare(:rate, "film", "1999")
|
23
|
+
end
|
11
24
|
end
|
12
25
|
|
13
26
|
describe "range" do
|
14
|
-
it "calls the range method of the named Medium class with :formatted=>true"
|
27
|
+
it "calls the range method of the named Medium class with :formatted=>true" do
|
28
|
+
compare(:ranges,"film")
|
29
|
+
end
|
15
30
|
end
|
16
31
|
|
17
32
|
describe "first" do
|
18
|
-
it "
|
33
|
+
it "calls the first method of named Medium class" do
|
34
|
+
compare(:first, "film")
|
35
|
+
end
|
19
36
|
end
|
20
37
|
|
21
38
|
describe "media" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
|
25
|
-
next unless c.superclass == Medium
|
26
|
-
list << c
|
27
|
-
end
|
28
|
-
`./oldness media`.should == list.collect(&:to_s).sort.inject("") { |l, c| l + c.downcase.sub("oldness::", "")+"\n" }
|
39
|
+
it "calls the list method of Medium with :formatted => true" do
|
40
|
+
cli.media
|
41
|
+
@io.string.should == Medium.list(:formatted => true)
|
29
42
|
end
|
30
43
|
end
|
31
44
|
end
|
data/spec/medium_spec.rb
CHANGED
@@ -59,5 +59,22 @@ module Oldness
|
|
59
59
|
RubyPrograms.first.to_s.should == "Hello World (1979), by Matz"
|
60
60
|
end
|
61
61
|
end
|
62
|
+
describe ".list" do
|
63
|
+
def all_media
|
64
|
+
classes = []
|
65
|
+
ObjectSpace.each_object(Class) do |c|
|
66
|
+
next unless c.superclass == Medium
|
67
|
+
classes << c
|
68
|
+
end
|
69
|
+
classes
|
70
|
+
end
|
71
|
+
it "returns all the objects which inherit from Media" do
|
72
|
+
all_media.each { |i| Medium.list.should include(i) }
|
73
|
+
Medium.list.each { |i| all_media.should include(i) }
|
74
|
+
end
|
75
|
+
it "can have formatted output instead" do
|
76
|
+
Medium.list(:formatted => true).should == Medium.list.collect(&:to_s).sort.inject("") { |l, c| l + c.downcase.sub("oldness::", "")+"\n" }
|
77
|
+
end
|
78
|
+
end
|
62
79
|
end
|
63
80
|
end
|
data/spec/spec_helper.rb
CHANGED
data/tasks.thor
CHANGED
@@ -34,38 +34,32 @@ end
|
|
34
34
|
class VersionBump < Thor
|
35
35
|
desc "manual MAJOR MINOR PATCH", "Set version number to 'MAJOR.MINOR.PATCH'"
|
36
36
|
def manual(major, minor, patch)
|
37
|
-
|
38
|
-
update_version
|
37
|
+
update_version(major, minor, patch)
|
39
38
|
end
|
40
39
|
|
41
40
|
desc "major", "Bump by a major version"
|
42
41
|
def major
|
43
|
-
version[
|
44
|
-
version[1] = 0
|
45
|
-
version[2] = 0
|
46
|
-
update_version
|
42
|
+
invoke :manual, [version[:major] + 1, 0, 0]
|
47
43
|
end
|
48
44
|
desc "minor", "Bump by a minor version"
|
49
45
|
def minor
|
50
|
-
version[
|
51
|
-
version[2] = 0
|
52
|
-
update_version
|
46
|
+
invoke :manual, [version[:major], version[:minor] + 1, 0]
|
53
47
|
end
|
54
48
|
desc "patch", "Bump by a patch version"
|
55
49
|
def patch
|
56
|
-
version[
|
57
|
-
update_version
|
50
|
+
invoke :manual [version[:major], version[:minor], version[:patch] + 1]
|
58
51
|
end
|
52
|
+
|
59
53
|
no_tasks do
|
60
54
|
def version
|
61
55
|
$:.push File.expand_path("../lib", __FILE__)
|
62
56
|
require 'oldness/version'
|
63
|
-
Oldness::
|
64
|
-
@version ||= [$1.to_i, $2.to_i, $3.to_i]
|
57
|
+
@version ||= {:major=>Oldness::Version::MAJOR, :minor=>Oldness::Version::MINOR, :patch=>Oldness::Version::PATCH}
|
65
58
|
end
|
66
|
-
def update_version
|
59
|
+
def update_version(major, minor, patch)
|
67
60
|
path = File.expand_path("./lib/oldness/version.rb")
|
68
|
-
new_source = File.read(path)
|
61
|
+
new_source = File.read(path)
|
62
|
+
new_source.sub!(/MAJOR\s*=.*/, %Q{MAJOR = #{major}}).sub!(/MINOR\s*=.*/, %Q{MINOR = #{minor}}).sub!(/PATCH\s*=.*/, %Q{PATCH = #{patch}})
|
69
63
|
File.open(path, 'w') { |f| f.puts new_source }
|
70
64
|
end
|
71
65
|
end
|
@@ -95,4 +89,5 @@ class Publish < Thor
|
|
95
89
|
@gemspec ||= eval(File.read(Dir["*.gemspec"].first))
|
96
90
|
end
|
97
91
|
end
|
98
|
-
end
|
92
|
+
end
|
93
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: oldness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nick Novitski
|
@@ -56,6 +56,56 @@ extra_rdoc_files: []
|
|
56
56
|
files:
|
57
57
|
- bin/oldness
|
58
58
|
- config.ru
|
59
|
+
- coverage/assets/0.5.3/app.js
|
60
|
+
- coverage/assets/0.5.3/fancybox/blank.gif
|
61
|
+
- coverage/assets/0.5.3/fancybox/fancy_close.png
|
62
|
+
- coverage/assets/0.5.3/fancybox/fancy_loading.png
|
63
|
+
- coverage/assets/0.5.3/fancybox/fancy_nav_left.png
|
64
|
+
- coverage/assets/0.5.3/fancybox/fancy_nav_right.png
|
65
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_e.png
|
66
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_n.png
|
67
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png
|
68
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png
|
69
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_s.png
|
70
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_se.png
|
71
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png
|
72
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_w.png
|
73
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_left.png
|
74
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_main.png
|
75
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_over.png
|
76
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_right.png
|
77
|
+
- coverage/assets/0.5.3/fancybox/fancybox-x.png
|
78
|
+
- coverage/assets/0.5.3/fancybox/fancybox-y.png
|
79
|
+
- coverage/assets/0.5.3/fancybox/fancybox.png
|
80
|
+
- coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css
|
81
|
+
- coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js
|
82
|
+
- coverage/assets/0.5.3/favicon_green.png
|
83
|
+
- coverage/assets/0.5.3/favicon_red.png
|
84
|
+
- coverage/assets/0.5.3/favicon_yellow.png
|
85
|
+
- coverage/assets/0.5.3/highlight.css
|
86
|
+
- coverage/assets/0.5.3/highlight.pack.js
|
87
|
+
- coverage/assets/0.5.3/jquery-1.6.2.min.js
|
88
|
+
- coverage/assets/0.5.3/jquery.dataTables.min.js
|
89
|
+
- coverage/assets/0.5.3/jquery.timeago.js
|
90
|
+
- coverage/assets/0.5.3/jquery.url.js
|
91
|
+
- coverage/assets/0.5.3/loading.gif
|
92
|
+
- coverage/assets/0.5.3/magnify.png
|
93
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
94
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
95
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
96
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
97
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
98
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
99
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
100
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
101
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png
|
102
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png
|
103
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png
|
104
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png
|
105
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png
|
106
|
+
- coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css
|
107
|
+
- coverage/assets/0.5.3/stylesheet.css
|
108
|
+
- coverage/index.html
|
59
109
|
- Gemfile
|
60
110
|
- lib/oldness/cli.rb
|
61
111
|
- lib/oldness/medium.rb
|