ramesh 1.1.0 → 1.2.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: 864cf2072c0d6e2fadf44f5f5bf45bca20b02ee4
4
- data.tar.gz: cebbb43a3842d404dd8a9f86b6e79f7a1aac9414
3
+ metadata.gz: f095feb67813f3fc287cae0facf015f91cb6a8ed
4
+ data.tar.gz: 7e375fa8880fa9cf421c74944c6cd8f9c4ec19ff
5
5
  SHA512:
6
- metadata.gz: f9172e4821c9e2f94fc3738b8905a408dfe11d145a64a01841099bcea2a4cdc82aa9d59aa1c200df347cc0d9428d5a0075232bb9c42f8608994c1fb5e3aa0084
7
- data.tar.gz: 8bed25633c866e135e3e26438fa14075c4afcda2fd0530cca94f5e869e53931503a76afcca3c58cefe1cddaa0d75c0d90fcf66fbe0f2db220c999442b9420c4e
6
+ metadata.gz: 6842b6ad926081e3f31064693b1505bbd26ae5cfbbb96d7136bb2ad4f0441bd94fe988b67db492638f59cf2db4e673fb134ee7644ca2740fca6f4a1b3bb62fe0
7
+ data.tar.gz: bab705ad4c7ff24a27b47f91efd0c86b6558725cd5fd3d829301da45616fb09ddc5fb8222dcba53b79899286f1431bfa3162265e856ce576d2e91cf592136691
data/README.md CHANGED
@@ -23,10 +23,10 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- ramesh download the latest image
27
- ramesh [0-120] download the image specified minutes before
28
- ramesh [0-120]-[0-120] download images within a specified range
29
- ramesh -h show this usage
26
+ ramesh [-d save_dir] download the latest image
27
+ ramesh [-d save_dir] 0-120 download the image specified minutes before
28
+ ramesh [-d save_dir] 0-120 0-120 download images within a specified range
29
+ ramesh -h, --help show this usage
30
30
 
31
31
  ## Contributing
32
32
 
@@ -12,7 +12,7 @@ module Ramesh
12
12
  end
13
13
 
14
14
  image_name = name_from_minute(minute)
15
- image = Image.new(image_name)
15
+ image = Image.new(image_name, background_image, mask_image)
16
16
  image.save(save_dir, image_name)
17
17
 
18
18
  @logger.info("Downloaded: #{image_name}.jpg")
@@ -30,6 +30,14 @@ module Ramesh
30
30
 
31
31
  private
32
32
 
33
+ def background_image
34
+ @background_image ||= Image.background_image
35
+ end
36
+
37
+ def mask_image
38
+ @mask_image ||= Image.mask_image
39
+ end
40
+
33
41
  def meshes_index
34
42
  @meshes_index ||= open(MESHES_INDEX_URL).read.gsub(/[^0-9,]/, "").split(",")
35
43
  end
@@ -1,4 +1,4 @@
1
- require "RMagick"
1
+ require "mini_magick"
2
2
  require "open-uri"
3
3
 
4
4
  module Ramesh
@@ -34,7 +34,7 @@ module Ramesh
34
34
  private
35
35
 
36
36
  def self.download_image(url)
37
- Magick::Image.from_blob(open(url).read).shift
37
+ MiniMagick::Image.read(open(url).read)
38
38
  end
39
39
 
40
40
  def moment_image_url(image_name)
@@ -43,7 +43,13 @@ module Ramesh
43
43
 
44
44
  def composite_images(image_list)
45
45
  image = image_list.shift
46
- image_list.each { |layer| image = image.composite(layer, 0, 0, Magick::OverCompositeOp) }
46
+
47
+ image_list.each do |layer|
48
+ image = image.composite(layer) do |c|
49
+ c.compose "Over"
50
+ end
51
+ end
52
+
47
53
  image
48
54
  end
49
55
  end
@@ -1,3 +1,3 @@
1
1
  module Ramesh
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "fakefs"
24
24
  spec.add_development_dependency "guard-rspec"
25
25
  spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rspec", "~> 3.0.0"
27
27
  spec.add_development_dependency "terminal-notifier-guard"
28
28
  spec.add_development_dependency "webmock"
29
29
 
30
- spec.add_dependency "rmagick"
30
+ spec.add_dependency "mini_magick"
31
31
  end
@@ -1,2 +1,2 @@
1
- Amesh.setIndexList(["201405091845","201405091840","201405091835","201405091830","201405091825","201405091820","201405091815","201405091810","201405091805","201405091800","201405091755","201405091750","201405091745","201405091740","201405091735","201405091730","201405091725","201405091720","201405091715","201405091710","201405091705","201405091700","201405091655","201405091650","201405091645"]);
2
-
1
+ Amesh.setIndexList(["201405091845","201405091840","201405091835","201405091830","201405091825","201405091820","201405091815","201405091810","201405091805","201405091800","201405091755","201405091750","201405091745","201405091740","201405091735","201405091730","201405091725","201405091720","201405091715","201405091710","201405091705","201405091700","201405091655","201405091650","201405091645"]);
2
+
@@ -28,8 +28,8 @@ module Ramesh
28
28
  describe "#download_image" do
29
29
  before do
30
30
  image = double(write: true)
31
- Image.stub(download_image: image)
32
- Image.any_instance.stub(composite_images: image)
31
+ allow(Image).to receive(:download_image).and_return(image)
32
+ allow_any_instance_of(Image).to receive(:composite_images).and_return(image)
33
33
  end
34
34
 
35
35
  context "when minute is not specified" do
@@ -23,13 +23,17 @@ module Ramesh
23
23
  "http://tokyo-ame.jwa.or.jp/map/msk000.png"
24
24
  end
25
25
 
26
+ let(:fixture_image) do
27
+ open(fixture_path("lena.png")).read
28
+ end
29
+
26
30
  before do
27
31
  stub_request(:get, mesh_url)
28
- .to_return(status: 200, body: open(fixture_path("lena.png")).read)
32
+ .to_return(status: 200, body: fixture_image)
29
33
  stub_request(:get, background_url)
30
- .to_return(status: 200, body: open(fixture_path("lena.png")).read)
34
+ .to_return(status: 200, body: fixture_image)
31
35
  stub_request(:get, mask_url)
32
- .to_return(status: 200, body: open(fixture_path("lena.png")).read)
36
+ .to_return(status: 200, body: fixture_image)
33
37
  end
34
38
 
35
39
  describe "#background_image" do
@@ -47,11 +51,26 @@ module Ramesh
47
51
  end
48
52
 
49
53
  describe "#initialize" do
50
- it "should composite the moment image" do
51
- described_class.new(image_name)
52
- expect(a_request(:get, mesh_url)).to have_been_made.once
53
- expect(a_request(:get, background_url)).to have_been_made.once
54
- expect(a_request(:get, mask_url)).to have_been_made.once
54
+ context "without cached images" do
55
+ it "should composite the moment image" do
56
+ described_class.new(image_name)
57
+ expect(a_request(:get, mesh_url)).to have_been_made.once
58
+ expect(a_request(:get, background_url)).to have_been_made.once
59
+ expect(a_request(:get, mask_url)).to have_been_made.once
60
+ end
61
+ end
62
+
63
+ context "with cached images" do
64
+ it "should composite the moment image" do
65
+ image = double(composite: true)
66
+ background_image = double(composite: image)
67
+ mask_image = double(composite: image)
68
+
69
+ described_class.new(image_name, background_image, mask_image)
70
+ expect(a_request(:get, mesh_url)).to have_been_made.once
71
+ expect(a_request(:get, background_url)).not_to have_been_made
72
+ expect(a_request(:get, mask_url)).not_to have_been_made
73
+ end
55
74
  end
56
75
  end
57
76
 
@@ -63,7 +82,7 @@ module Ramesh
63
82
  it "should save itself to the file" do
64
83
  image = described_class.new(image_name)
65
84
  image.save(tmpdir, image_name)
66
- expect(File.exist?(File.join(tmpdir, "#{image_name}.jpg"))).to be_true
85
+ expect(File.exist?(File.join(tmpdir, "#{image_name}.jpg"))).to be_truthy
67
86
  end
68
87
 
69
88
  after do
@@ -1,21 +1,11 @@
1
1
  require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+
4
6
  require 'ramesh'
5
7
  require 'webmock/rspec'
6
8
 
7
- RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
- config.run_all_when_everything_filtered = true
10
- config.filter_run :focus
11
-
12
- # Run specs in random order to surface order dependencies. If you find an
13
- # order dependency and want to debug it, you can fix the order by providing
14
- # the seed, which is printed after each run.
15
- # --seed 1234
16
- config.order = 'random'
17
- end
18
-
19
9
  def fixture_path(name)
20
10
  File.expand_path(File.join("..", "fixtures", name), __FILE__)
21
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramesh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dtan4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 3.0.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 3.0.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: terminal-notifier-guard
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rmagick
126
+ name: mini_magick
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="