workshop 0.0.1

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.
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+
3
+ describe Workshop::Builder do
4
+ let(:project_name) {'foo'}
5
+ let(:main_filename) {nil}
6
+ let(:arduino_hardware_directory) {'/app/hardware'}
7
+ let(:arduino_variant_directory) {'/app/hardware/variants/standard'}
8
+ let(:arduino_core_directory) {'/app/hardware/cores/arduino'}
9
+ let(:source_directory) {'/app/src'}
10
+ let(:build_directory) {'/app/build'}
11
+ let(:build_mcu) {'atmega32u4'}
12
+ let(:build_f_cpu) {'16000000L'}
13
+ let(:build_vid) {'0x0000'}
14
+ let(:build_pid) {'0x0001'}
15
+ let(:build_arduino) {'111'}
16
+ let(:project) do
17
+ double(:project).tap do |project|
18
+ project.stub(:arduino_hardware_directory).and_return(arduino_hardware_directory)
19
+ project.stub(:arduino_core_directory).and_return(arduino_core_directory)
20
+ project.stub(:arduino_variant_directory).and_return(arduino_variant_directory)
21
+ project.stub(:source_directory).and_return(source_directory)
22
+ project.stub(:build_directory).and_return(build_directory)
23
+ project.stub(:build_mcu).and_return(build_mcu)
24
+ project.stub(:build_f_cpu).and_return(build_f_cpu)
25
+ project.stub(:build_vid).and_return(build_vid)
26
+ project.stub(:build_pid).and_return(build_pid)
27
+ project.stub(:build_arduino).and_return(build_arduino)
28
+ project.stub(:name).and_return(project_name)
29
+ project.stub(:main_filename).and_return(main_filename)
30
+ project.stub(:includes).and_return([])
31
+ end
32
+ end
33
+ subject do
34
+ Workshop::Builder.new(project).tap do |builder|
35
+ Dir.stub(:[]).with("#{arduino_core_directory}/**/*.c").and_return([
36
+ "#{arduino_core_directory}/core.c"])
37
+ Dir.stub(:[]).with("#{arduino_core_directory}/**/*.cpp").and_return([
38
+ "#{arduino_core_directory}/core.cpp"])
39
+ Dir.stub(:[]).with("#{arduino_variant_directory}/**/*.c").and_return([
40
+ "#{arduino_variant_directory}/variant.c"])
41
+ Dir.stub(:[]).with("#{arduino_variant_directory}/**/*.cpp").and_return([
42
+ "#{arduino_variant_directory}/variant.cpp"])
43
+ Dir.stub(:[]).with("#{source_directory}/**/*.c").and_return([
44
+ "#{source_directory}/app.c"])
45
+ Dir.stub(:[]).with("#{source_directory}/**/*.cpp").and_return([
46
+ "#{source_directory}/app.cpp"])
47
+ end
48
+ end
49
+
50
+ describe '#core_files' do
51
+ it 'it returns the c and cpp files in the "arduino" core directory' do
52
+ files = subject.core_files
53
+ expect(files).to eq(['/app/hardware/cores/arduino/core.c',
54
+ '/app/hardware/cores/arduino/core.cpp'])
55
+ end
56
+ end
57
+
58
+ describe '#variant_files' do
59
+ it 'it returns the c and cpp files in the "standard" variant directory' do
60
+ files = subject.variant_files
61
+ expect(files).to eq(['/app/hardware/variants/standard/variant.c',
62
+ '/app/hardware/variants/standard/variant.cpp'])
63
+ end
64
+ end
65
+
66
+ describe '#source_files' do
67
+ it 'it returns the c and cpp files in the project source directory' do
68
+ files = subject.source_files
69
+ expect(files).to eq(['/app/src/app.c', '/app/src/app.cpp'])
70
+ end
71
+ end
72
+
73
+ describe '#output_file' do
74
+ it 'for "/app/src/foo.c" it returns "/app/build/foo.c.o"' do
75
+ output = subject.output_file('/app/src/foo.c')
76
+ expect(output).to eq('/app/build/foo.c.o')
77
+ end
78
+ end
79
+
80
+ describe '#o_files_to_archive' do
81
+ context 'project name is the same as the main output file' do
82
+ let(:project_name) {'foo'}
83
+ it 'the *.o files to archive do not include the "foo.cpp.o" file' do
84
+ files = subject.o_files_to_archive
85
+ expect(files).to_not include('/app/build/foo.cpp.o')
86
+ end
87
+ end
88
+ end
89
+
90
+ describe '#compiler_flags' do
91
+ context 'build options have values' do
92
+ it 'returns the correct compiler flags for a *.c file' do
93
+ flags = subject.compiler_flags
94
+ expect(flags).to include('-c')
95
+ expect(flags).to include('-g')
96
+ expect(flags).to include('-Os')
97
+ expect(flags).to include('-Wall')
98
+ expect(flags).to include('-fno-exceptions')
99
+ expect(flags).to include('-ffunction-sections')
100
+ expect(flags).to include('-fdata-sections')
101
+ expect(flags).to include('-mmcu=atmega32u4')
102
+ expect(flags).to include('-DF_CPU=16000000L')
103
+ expect(flags).to include('-MMD')
104
+ expect(flags).to include('-DUSB_VID=0x0000')
105
+ expect(flags).to include('-DUSB_PID=0x0001')
106
+ expect(flags).to include('-DARDUINO=111')
107
+ end
108
+ end
109
+
110
+ context 'build options are nil' do
111
+ let(:build_mcu) {nil}
112
+ let(:build_f_cpu) {nil}
113
+ let(:build_vid) {nil}
114
+ let(:build_pid) {nil}
115
+ let(:build_arduino) {nil}
116
+ it 'returns the correct compiler flags for a *.c file' do
117
+ flags = subject.compiler_flags
118
+ expect(flags).to include('-c')
119
+ expect(flags).to include('-g')
120
+ expect(flags).to include('-Os')
121
+ expect(flags).to include('-Wall')
122
+ expect(flags).to include('-fno-exceptions')
123
+ expect(flags).to include('-ffunction-sections')
124
+ expect(flags).to include('-fdata-sections')
125
+ expect(flags).to_not include('-mmcu=')
126
+ expect(flags).to_not include('-DF_CPU=')
127
+ expect(flags).to include('-MMD')
128
+ expect(flags).to_not include('-DUSB_VID=')
129
+ expect(flags).to_not include('-DUSB_PID=')
130
+ expect(flags).to_not include('-DARDUINO=')
131
+ end
132
+ end
133
+ end
134
+
135
+ describe '#compile_command_for' do
136
+ it 'constructs a avr-gcc compile command for a *.c file' do
137
+ command = subject.compile_command_for('/app/src/foo.c')
138
+ expect(command).to include('/app/hardware/tools/avr/bin/avr-gcc')
139
+ expect(command).to include('-c')
140
+ expect(command).to include('-g')
141
+ expect(command).to include('-Os')
142
+ expect(command).to include('-Wall')
143
+ expect(command).to include('-fno-exceptions')
144
+ expect(command).to include('-ffunction-sections')
145
+ expect(command).to include('-fdata-sections')
146
+ expect(command).to include('-mmcu=atmega32u4')
147
+ expect(command).to include('-DF_CPU=16000000L')
148
+ expect(command).to include('-MMD')
149
+ expect(command).to include('-DUSB_VID=0x0000')
150
+ expect(command).to include('-DUSB_PID=0x0001')
151
+ expect(command).to include('-DARDUINO=111')
152
+ expect(command).to include('/app/src/foo.c')
153
+ expect(command).to include('-I/app/hardware/cores/arduino')
154
+ expect(command).to include('-I/app/hardware/variants/standard')
155
+ expect(command).to include('-o /app/build/foo.c.o')
156
+ end
157
+ end
158
+
159
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Workshop::Project::Configuration do
4
+ describe '#arduino_app_directory' do
5
+ it 'defaults arduino app directory to standard OS X app location' do
6
+ config = Workshop::Project::Configuration.new
7
+ expect(config.arduino_app_directory).to eq('/Applications/Arduino.app')
8
+ end
9
+ end
10
+
11
+ describe '#project_name' do
12
+ it 'defaults project name to be the lowercased and underscored folder name' do
13
+ Workshop::Project::Configuration.any_instance.stub(:app_directory).and_return('/a/Foo Bar')
14
+ config = Workshop::Project::Configuration.new
15
+ expect(config.project_name).to eq('foo_bar')
16
+ end
17
+ end
18
+
19
+ describe '#app_directory' do
20
+ it 'returns current working directory for app directory' do
21
+ Dir.stub(:pwd).and_return('/foo/bar')
22
+ config = Workshop::Project::Configuration.new
23
+ expect(config.app_directory).to eq('/foo/bar')
24
+ end
25
+ end
26
+
27
+ describe '#build' do
28
+ it 'initialized with an instance of a build configuration' do
29
+ expect(subject.build.class).to eq(Workshop::Project::Configuration::Build)
30
+ end
31
+ end
32
+
33
+ describe '#upload' do
34
+ it 'initialized with an instance of an upload configuration' do
35
+ expect(subject.upload.class).to eq(Workshop::Project::Configuration::Upload)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Workshop::Project do
4
+ let(:arduino) do
5
+ double(:arduino).tap do |arduino|
6
+ arduino.stub(:hardware_directory).and_return('/hardware')
7
+ end
8
+ end
9
+
10
+ subject do
11
+ Workshop::Project.configure { |config| }.tap do |project|
12
+ project.stub(:arduino).and_return(arduino)
13
+ end
14
+ end
15
+
16
+ describe 'configure' do
17
+ it 'passes a configure parameter' do
18
+ Workshop::Project.configure do |config|
19
+ expect(config.class).to eq(Workshop::Project::Configuration)
20
+ end
21
+ end
22
+ end
23
+
24
+ describe '#arduino_hardware_directory' do
25
+ it 'returns the arduino configs hardware directory' do
26
+ expect(subject.arduino_hardware_directory).to eq('/hardware')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'workshop'
5
+
6
+ RSpec.configure do |config|
7
+
8
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Workshop::Tools do
4
+ context 'arduino hardware directory is "/app/hardware"' do
5
+ let(:hardware_directory) { '/app/hardware' }
6
+ subject { Workshop::Tools.new hardware_directory }
7
+
8
+ describe '#tools_directory' do
9
+ it 'returns "/app/hardware/tools"' do
10
+ expect(subject.tools_directory).to eq('/app/hardware/tools')
11
+ end
12
+ end
13
+
14
+ describe '#avr_gcc' do
15
+ it 'returns "/app/hardware/tools/avr-gcc"' do
16
+ expect(subject.avr_gcc).to eq('/app/hardware/tools/avr/bin/avr-gcc')
17
+ end
18
+ end
19
+
20
+ describe '#compiler' do
21
+ it 'returns "avr-gcc" for a *.c file' do
22
+ compiler = subject.compiler('/app/src/foo.c')
23
+ expect(compiler).to eq('/app/hardware/tools/avr/bin/avr-gcc')
24
+ end
25
+
26
+ it 'returns "avr-g++" for a *.cpp file' do
27
+ compiler = subject.compiler('/app/src/foo.cpp')
28
+ expect(compiler).to eq('/app/hardware/tools/avr/bin/avr-g++')
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Workshop::Project::Configuration::Upload do
4
+ describe '#protocol' do
5
+ it 'returns "stk500" as the default protocol' do
6
+ expect(subject.protocol).to eq('stk500')
7
+ end
8
+ end
9
+ end
data/workshop.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'workshop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "workshop"
8
+ spec.version = Workshop::VERSION
9
+ spec.authors = ["Chase McCarthy"]
10
+ spec.email = ["chase@code0100fun.com"]
11
+ spec.summary = %q{A project managment toolset for the Arduino platform.}
12
+ spec.description = %q{An Arduino project build system designed to make Arduino development more fun and less... crappy.}
13
+ spec.homepage = "https://github.com/code0100fun/workshop"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.bindir = 'bin'
22
+ spec.executables = ['workshop']
23
+
24
+ spec.add_dependency "activesupport", "~>4.1"
25
+ spec.add_dependency "thor", "~>0.19"
26
+ spec.add_dependency "colorize", "~>0.7"
27
+ spec.add_development_dependency "bundler", "~> 1.5"
28
+ spec.add_development_dependency "rake", "~> 10.3"
29
+ spec.add_development_dependency "rspec", "~> 2.14"
30
+ spec.add_development_dependency "pry", "~>0.9"
31
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workshop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chase McCarthy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.14'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.14'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.9'
111
+ description: An Arduino project build system designed to make Arduino development
112
+ more fun and less... crappy.
113
+ email:
114
+ - chase@code0100fun.com
115
+ executables:
116
+ - workshop
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/workshop
127
+ - examples/blink/Rakefile
128
+ - examples/blink/config/com_port.yml
129
+ - examples/blink/src/blink.cpp
130
+ - lib/workshop.rb
131
+ - lib/workshop/arduino.rb
132
+ - lib/workshop/builder.rb
133
+ - lib/workshop/cli.rb
134
+ - lib/workshop/project.rb
135
+ - lib/workshop/project/configuration.rb
136
+ - lib/workshop/project/configuration/build.rb
137
+ - lib/workshop/project/configuration/upload.rb
138
+ - lib/workshop/project/setup.rb
139
+ - lib/workshop/tasks.rb
140
+ - lib/workshop/templates/Rakefile.erb
141
+ - lib/workshop/templates/blink.cpp
142
+ - lib/workshop/tools.rb
143
+ - lib/workshop/uploader.rb
144
+ - lib/workshop/version.rb
145
+ - spec/arduino_spec.rb
146
+ - spec/build_configuration_spec.rb
147
+ - spec/builder_spec.rb
148
+ - spec/configuration_spec.rb
149
+ - spec/project_spec.rb
150
+ - spec/spec_helper.rb
151
+ - spec/tools_spec.rb
152
+ - spec/upload_configuration_spec.rb
153
+ - workshop.gemspec
154
+ homepage: https://github.com/code0100fun/workshop
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.2.2
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: A project managment toolset for the Arduino platform.
178
+ test_files:
179
+ - spec/arduino_spec.rb
180
+ - spec/build_configuration_spec.rb
181
+ - spec/builder_spec.rb
182
+ - spec/configuration_spec.rb
183
+ - spec/project_spec.rb
184
+ - spec/spec_helper.rb
185
+ - spec/tools_spec.rb
186
+ - spec/upload_configuration_spec.rb