furoshiki 0.2.0 → 0.3.0

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.ruby-version +1 -1
  4. data/Gemfile +0 -1
  5. data/Rakefile +5 -0
  6. data/furoshiki.gemspec +1 -1
  7. data/lib/furoshiki/configuration.rb +142 -0
  8. data/lib/furoshiki/jar.rb +41 -0
  9. data/lib/furoshiki/jar_app.rb +225 -0
  10. data/lib/furoshiki/util.rb +27 -0
  11. data/lib/furoshiki/validator.rb +42 -0
  12. data/lib/furoshiki/version.rb +1 -1
  13. data/lib/furoshiki/warbler_extensions.rb +12 -0
  14. data/lib/furoshiki.rb +4 -3
  15. data/lib/warbler/traits/furoshiki.rb +31 -0
  16. data/spec/{shoes/swt_app_spec.rb → app_spec.rb} +29 -22
  17. data/spec/configuration_spec.rb +12 -0
  18. data/spec/fixtures/config.yaml +1 -0
  19. data/spec/{shoes → fixtures}/test_app/app.yaml +0 -0
  20. data/spec/{shoes → fixtures}/test_app/bin/hello_world +0 -0
  21. data/spec/{shoes → fixtures}/test_app/dir_to_ignore/file_to_ignore.txt +0 -0
  22. data/spec/{shoes → fixtures}/test_app/img/boots.icns +0 -0
  23. data/spec/{shoes → fixtures}/test_app/img/boots.ico +0 -0
  24. data/spec/{shoes → fixtures}/test_app/img/boots_512x512x32.png +0 -0
  25. data/spec/{shoes → fixtures}/test_app/sibling.rb +0 -0
  26. data/spec/fixtures/test_project/bin/hello.rb +1 -0
  27. data/spec/fixtures/test_project/dir_to_ignore/file_to_ignore.txt +1 -0
  28. data/spec/{shoes/swt_jar_spec.rb → jar_spec.rb} +25 -12
  29. data/spec/spec_helper.rb +51 -0
  30. data/spec/support/shared_config.rb +19 -0
  31. data/spec/support/shared_zip.rb +1 -1
  32. data/spec/util_spec.rb +57 -0
  33. metadata +73 -45
  34. data/lib/furoshiki/shoes/configuration.rb +0 -184
  35. data/lib/furoshiki/shoes/swt_app.rb +0 -230
  36. data/lib/furoshiki/shoes/swt_jar.rb +0 -67
  37. data/lib/furoshiki/shoes.rb +0 -15
  38. data/lib/warbler/traits/shoes.rb +0 -51
  39. data/spec/shoes/configuration_spec.rb +0 -198
  40. data/spec/shoes/spec_helper.rb +0 -70
  41. data/spec/shoes/support/shared_config.rb +0 -8
@@ -1,198 +0,0 @@
1
- require_relative 'spec_helper'
2
- require 'furoshiki/shoes/configuration'
3
-
4
- describe Furoshiki::Shoes::Configuration do
5
- context "defaults" do
6
- subject { Furoshiki::Shoes::Configuration.new }
7
-
8
- its(:name) { should eq('Shoes App') }
9
- its(:shortname) { should eq('shoesapp') }
10
- its(:ignore) { should eq(['pkg']) }
11
- its(:gems) { should include('shoes') }
12
- its(:version) { should eq('0.0.0') }
13
- its(:release) { should eq('Rookie') }
14
- its(:icons) { should be_an_instance_of(Hash) }
15
- its(:dmg) { should be_an_instance_of(Hash) }
16
- its(:run) { should be_nil }
17
- its(:working_dir) { should eq(Pathname.new(Dir.pwd)) }
18
- it { is_expected.not_to be_valid } # no :run
19
-
20
- describe "#icons" do
21
- it 'osx is nil' do
22
- expect(subject.icons[:osx]).to be_nil
23
- end
24
-
25
- it 'gtk is nil' do
26
- expect(subject.icons[:gtk]).to be_nil
27
- end
28
-
29
- it 'win32 is nil' do
30
- expect(subject.icons[:win32]).to be_nil
31
- end
32
- end
33
-
34
- describe "#dmg" do
35
- it "has ds_store" do
36
- expect(subject.dmg[:ds_store]).to eq('path/to/default/.DS_Store')
37
- end
38
-
39
- it "has background" do
40
- expect(subject.dmg[:background]).to eq('path/to/default/background.png')
41
- end
42
- end
43
-
44
- describe "#to_hash" do
45
- it "round-trips" do
46
- expect(Furoshiki::Shoes::Configuration.new(subject.to_hash)).to eq(subject)
47
- end
48
- end
49
- end
50
-
51
- context "with options" do
52
- include_context 'config'
53
- subject { Furoshiki::Shoes::Configuration.load(@config_filename) }
54
-
55
- its(:name) { should eq('Sugar Clouds') }
56
- its(:shortname) { should eq('sweet-nebulae') }
57
- its(:ignore) { should include('pkg') }
58
- its(:run) { should eq('bin/hello_world') }
59
- its(:gems) { should include('rspec') }
60
- its(:gems) { should include('shoes') }
61
- its(:version) { should eq('0.0.1') }
62
- its(:release) { should eq('Mindfully') }
63
- its(:icons) { should be_an_instance_of(Hash) }
64
- its(:dmg) { should be_an_instance_of(Hash) }
65
- its(:working_dir) { should eq(@config_filename.dirname) }
66
- it { is_expected.to be_valid }
67
-
68
- describe "#icons" do
69
- it 'has osx' do
70
- expect(subject.icons[:osx]).to eq('img/boots.icns')
71
- end
72
-
73
- it 'has gtk' do
74
- expect(subject.icons[:gtk]).to eq('img/boots_512x512x32.png')
75
- end
76
-
77
- it 'has win32' do
78
- expect(subject.icons[:win32]).to eq('img/boots.ico')
79
- end
80
- end
81
-
82
- describe "#dmg" do
83
- it "has ds_store" do
84
- expect(subject.dmg[:ds_store]).to eq('path/to/custom/.DS_Store')
85
- end
86
-
87
- it "has background" do
88
- expect(subject.dmg[:background]).to eq('path/to/custom/background.png')
89
- end
90
- end
91
-
92
- it "incorporates custom features" do
93
- expect(subject.custom).to eq('my custom feature')
94
- end
95
-
96
- it "round-trips" do
97
- expect(Furoshiki::Shoes::Configuration.new(subject.to_hash)).to eq(subject)
98
- end
99
- end
100
-
101
- context "with name, but without explicit shortname" do
102
- let(:options) { {:name => "Sugar Clouds"} }
103
- subject { Furoshiki::Shoes::Configuration.new options }
104
-
105
- its(:name) { should eq("Sugar Clouds") }
106
- its(:shortname) { should eq("sugarclouds") }
107
- end
108
-
109
- context "when the file to run doens't exist" do
110
- let(:options) { {:run => "path/to/non-existent/file"} }
111
- subject { Furoshiki::Shoes::Configuration.new options }
112
-
113
- it { is_expected.not_to be_valid }
114
- end
115
-
116
- context "when osx icon is not specified" do
117
- include_context 'config'
118
- let(:valid_config) { Furoshiki::Shoes::Configuration.load(@config_filename) }
119
- let(:options) { valid_config.to_hash.merge(:icons => {}) }
120
- subject { Furoshiki::Shoes::Configuration.new(options) }
121
-
122
- it "sets osx icon path to nil" do
123
- expect(subject.icons[:osx]).to be_nil
124
- end
125
-
126
- it "is valid" do
127
- expect(subject).to be_valid
128
- end
129
- end
130
-
131
- context "when osx icon is specified, but doesn't exist" do
132
- let(:options) { ({:icons => {:osx => "path/to/non-existent/file"}}) }
133
- subject { Furoshiki::Shoes::Configuration.new options }
134
-
135
- it "sets osx icon path" do
136
- expect(subject.icons[:osx]).to eq("path/to/non-existent/file")
137
- end
138
-
139
- it { is_expected.not_to be_valid }
140
- end
141
-
142
- context "auto-loading" do
143
- include_context 'config'
144
-
145
- context "without a path" do
146
- it "looks for 'app.yaml' in current directory" do
147
- Dir.chdir @config_filename.parent do
148
- config = Furoshiki::Shoes::Configuration.load
149
- expect(config.shortname).to eq('sweet-nebulae')
150
- end
151
- end
152
-
153
- it "blows up if it can't find the file" do
154
- Dir.chdir File.dirname(__FILE__) do
155
- expect { config = Furoshiki::Shoes::Configuration.load }.to raise_error
156
- end
157
- end
158
- end
159
-
160
- shared_examples "config with path" do
161
- it "finds the config" do
162
- Dir.chdir File.dirname(__FILE__) do
163
- config = Furoshiki::Shoes::Configuration.load(path)
164
- expect(config.shortname).to eq('sweet-nebulae')
165
- end
166
- end
167
- end
168
-
169
- context "with an 'app.yaml'" do
170
- let(:path) { @config_filename }
171
- it_behaves_like "config with path"
172
- end
173
-
174
- context "with a path to a directory containing an 'app.yaml'" do
175
- let(:path) { @config_filename.parent }
176
- it_behaves_like "config with path"
177
- end
178
-
179
- context "with a path to a file that is siblings with an 'app.yaml'" do
180
- let(:path) { @config_filename.parent.join('sibling.rb') }
181
- it_behaves_like "config with path"
182
- end
183
-
184
- context "with a path that exists, but no 'app.yaml'" do
185
- let(:path) { @config_filename.parent.join('bin/hello_world') }
186
- subject { Furoshiki::Shoes::Configuration.load(path) }
187
-
188
- its(:name) { should eq('hello_world') }
189
- its(:shortname) { should eq('hello_world') }
190
- end
191
-
192
- context "when the file doesn't exist" do
193
- it "blows up" do
194
- expect { Furoshiki::Shoes::Configuration.load('some/bogus/path') }.to raise_error
195
- end
196
- end
197
- end
198
- end
@@ -1,70 +0,0 @@
1
- SHOESSPEC_ROOT = File.expand_path('..', __FILE__)
2
-
3
- # Packaging caches files in $HOME/.furoshiki/cache by default.
4
- # For testing, we override $HOME using $FUROSHIKI_HOME
5
- ENV['FUROSHIKI_HOME'] = SHOESSPEC_ROOT
6
-
7
- require 'rspec'
8
- require 'rspec/its'
9
- require 'pry'
10
- require 'pathname'
11
- require 'furoshiki/shoes'
12
-
13
- # Guards for running or not running specs. Specs in the guarded block only
14
- # run if the guard conditions are met.
15
- #
16
- # @see Guard#backend_is
17
- module Guard
18
- # Runs specs only if backend matches given name
19
- #
20
- # @example
21
- # backend_is :swt do
22
- # specify "backend_name is :swt" do
23
- # # body of spec
24
- # end
25
- # end
26
- def backend_is(backend)
27
- yield if Shoes.configuration.backend_name == backend && block_given?
28
- end
29
-
30
- # Runs specs only if platform matches
31
- #
32
- # @example
33
- # platform_is :windows do
34
- # it "does something only on windows" do
35
- # # specification
36
- # end
37
- # end
38
- def platform_is(platform)
39
- yield if self.send "platform_is_#{platform.to_s}"
40
- end
41
-
42
- # Runs specs only if platform does not match
43
- #
44
- # @example
45
- # platform_is_not :windows do
46
- # it "does something only on posix systems" do
47
- # # specification
48
- # end
49
- # end
50
- def platform_is_not(platform)
51
- yield unless self.send "platform_is_#{platform.to_s}"
52
- end
53
-
54
- def platform_is_windows
55
- return RbConfig::CONFIG['host_os'] =~ /windows|mswin/i
56
- end
57
-
58
- def platform_is_linux
59
- return RbConfig::CONFIG['host_os'] =~ /linux/i
60
- end
61
-
62
- def platform_is_osx
63
- return RbConfig::CONFIG['host_os'] =~ /darwin/i
64
- end
65
- end
66
-
67
- include Guard
68
-
69
- Dir["#{SHOESSPEC_ROOT}/support/**/*.rb"].each {|f| require f}
70
-
@@ -1,8 +0,0 @@
1
- require 'yaml'
2
- require 'pathname'
3
-
4
- shared_context 'config' do
5
- before :all do
6
- @config_filename = Pathname.new(__FILE__).join('../../test_app/app.yaml').cleanpath
7
- end
8
- end