arduino_sketch_builder 0.0.3 → 0.0.4

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: 8a21314e76b1a911cc53e4b0d20fd38fff6787c4
4
- data.tar.gz: ca1a3bc1e35042c4049d11ae3f524cf21a4838f2
3
+ metadata.gz: 3943bbdef1392adb00d12ef745bcc50f46f36b0f
4
+ data.tar.gz: e1025545fe5697bc72f739632eb73c5f1e11d19e
5
5
  SHA512:
6
- metadata.gz: b3f041cbe7406472bec5fd9f3673e4d054e003c037a4fb4dd326ecfd23a6c9c28207188a3abfb567bc49d8ada66049e5677063a90b3a2ca5560b588f37e6484c
7
- data.tar.gz: 4a79152cdcc5ac45a0b7c185b2b0c110393273b2fbd20566d026e9a16209edcbaa9900c92883be432256723b12e6ac8854b3f6c8bdb9cc960011d0bb772ea07f
6
+ metadata.gz: 1d4facb2a74786562f2755ed69a05b7b45ed2e97d92853e1716ccc1292894b9f08fd39bda7d987de2b5d202c7d84992342122c10b032cf631247b5c8242c8245
7
+ data.tar.gz: 95829a985555e637df41c7c83b15095adabf8d43b9874c3e500ce74bd64203fb7350f28e7284299e0b9f1dff50b46b51248a5bcd6c28063c0fb9602db35f36ed
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
 
22
22
  Ruby 2.0.0 or more.
23
23
 
24
- * If ARDUINO_DEFAULT_BOARD and ARDUINO_DEFAULT_PORT are used to specify the board ID (e.g uno) and the port (e.g. /dev/tty.usbmodem411) instead of passing them to the method in Ruby code, works with Ruby 1.9.3, too.
24
+ * If ARDUINO_DEFAULT_BOARD and ARDUINO_DEFAULT_PORT are used to specify the board ID (e.g uno) and the port (e.g. /dev/tty.usbmodem411) instead of passing them as "ketword arguments" to the method in Ruby code, works with Ruby 1.9.3, too.
25
25
  * Strongly recommended to use Ruby 2.0.0 since this gem is intended to use its benefits and Ruby 2.0.0 is compatible with Ruby 1.9.3 if you need to run other code written for Ruby 1.9.3 with this gem.
26
26
 
27
27
  Arduino SDK version 0.19 or higher.
@@ -85,7 +85,9 @@ The default board ID: uno
85
85
 
86
86
  The default port: /dev/tty.usbmodem411
87
87
 
88
- You can change them by setting ARDUINO_DEFAULT_BOARD and ARDUINO_DEFAULT_PORT environment variables.
88
+ You can specify them through ArduinoSketchBuilder::Setup.new.setup method (See "Code example" section below).
89
+
90
+ You can also change them by setting ARDUINO_DEFAULT_BOARD and ARDUINO_DEFAULT_PORT environment variables at runtime.
89
91
 
90
92
  ### Code example
91
93
 
@@ -111,6 +113,18 @@ You can change them by setting ARDUINO_DEFAULT_BOARD and ARDUINO_DEFAULT_PORT en
111
113
  arduino_sketch_file_path = File.expand_path('~/temp/BlinkCustomized.ino')
112
114
  setup.setup(root_directory, arduino_sketch_file_path)
113
115
 
116
+ If Arduino board type and port are different from the default,
117
+
118
+ require "arduino_sketch_builder"
119
+
120
+ setup = ArduinoSketchBuilder::Setup.new
121
+
122
+ # Configuring ArduinoSketchBuilder (copies cmake directory under the specified root_directory):
123
+ root_directory = File.expand_path('~/.arduino_sketches')
124
+ # Path to the sketch to be put under the directory structure:
125
+ arduino_sketch_file_path = File.expand_path('~/temp/BlinkCustomized.ino')
126
+ setup.setup(root_directory, arduino_sketch_file_path, board_type: "diecimila", board_port: "/dev/cu.usbmodem411")
127
+
114
128
  #### Executing cmake commands - compile, make, and make upload
115
129
 
116
130
  require "arduino_sketch_builder"
@@ -22,7 +22,7 @@ class ArduinoSketchBuilder::Setup
22
22
 
23
23
  end
24
24
 
25
- def setup(root_directory, sketch_file_path)
25
+ def setup(root_directory, sketch_file_path, board_type: "uno", board_port: "/dev/tty.usbmodem411")
26
26
 
27
27
  sketch_file_name = File.basename(sketch_file_path)
28
28
  sketch_name = sketch_file_name.split('.').first
@@ -35,7 +35,7 @@ class ArduinoSketchBuilder::Setup
35
35
 
36
36
  c_make_lists_file_generator = ArduinoSketchBuilder::CMakeListsFileGenerator.new
37
37
  c_make_lists_file_generator.generate_main(root_directory, File.join(root_directory, main_directory_name))
38
- c_make_lists_file_generator.generate_sketch_specific(sketch_name, File.join(root_directory, main_directory_name, 'src'))
38
+ c_make_lists_file_generator.generate_sketch_specific(sketch_name, File.join(root_directory, main_directory_name, 'src'), board_type: board_type, board_port: board_port)
39
39
 
40
40
  File.write(File.join(root_directory, main_directory_name, 'src', sketch_name, sketch_file_name), File.read(sketch_file_path))
41
41
 
@@ -1,3 +1,3 @@
1
1
  module ArduinoSketchBuilder
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -81,6 +81,33 @@ describe ArduinoSketchBuilder::Setup do
81
81
 
82
82
  end
83
83
 
84
+ context "Arduino board type and port" do
85
+
86
+ it "should create a directory structure for an Arduino sketch with specified board ID and port" do
87
+
88
+ root_directory = TEMP_DIRECTORY
89
+
90
+ @setup.setup(root_directory, ARDUINO_SKETCH_FILE_PATH, board_type: "diecimila", board_port: "/dev/cu.usbmodem411")
91
+
92
+ Dir.exists?(File.join(root_directory, "blink_customized_for_test")).should be_true
93
+ File.exists?(File.join(root_directory, "blink_customized_for_test", "CMakeLists.txt")).should be_true
94
+ Dir.exists?(File.join(root_directory, "blink_customized_for_test", "src")).should be_true
95
+ File.exists?(File.join(root_directory, "blink_customized_for_test", "src", "CMakeLists.txt")).should be_true
96
+ Dir.exists?(File.join(root_directory, "blink_customized_for_test", "src", "BlinkCustomizedForTest")).should be_true
97
+ File.exists?(File.join(root_directory, "blink_customized_for_test", "src", "BlinkCustomizedForTest", "BlinkCustomizedForTest.ino")).should be_true
98
+ Dir.exists?(File.join(root_directory, "blink_customized_for_test", "build")).should be_true
99
+
100
+ # The following checks the generated file with the full path, hence, system specific (e.g. /Users/).
101
+ # Hence, it's considered that the unit test for c_make_lists_file_generator covers it.
102
+ # File.read(File.join(root_directory, "blink_customized_for_test", "CMakeLists.txt")).should == File.read(File.join(FIXTURES_DIRECTORY, "MainCMakeLists.txt"))
103
+ # This one also, it's considered that the unit test for c_make_lists_file_generator covers it.
104
+ # File.read(File.join(root_directory, "blink_customized_for_test", "src", "CMakeLists.txt")).should == File.read(File.join(FIXTURES_DIRECTORY, "CMakeListsForTestSketch2.txt"))
105
+ File.read(File.join(root_directory, "blink_customized_for_test", "src", "BlinkCustomizedForTest", "BlinkCustomizedForTest.ino")).should == File.read(File.join(ARDUINO_SKETCHES_FIXTURE_DIRECTORY, "src", "BlinkCustomizedForTest", "BlinkCustomizedForTest.ino"))
106
+
107
+ end
108
+
109
+ end
110
+
84
111
  end
85
112
 
86
113
  end
@@ -1,5 +1,5 @@
1
- set(ARDUINO_DEFAULT_BOARD uno) # Default Board ID, when not specified
2
- set(ARDUINO_DEFAULT_PORT /dev/tty.usbmodem411) # Default Port, when not specified
1
+ set(ARDUINO_DEFAULT_BOARD diecimila) # Default Board ID, when not specified
2
+ set(ARDUINO_DEFAULT_PORT /dev/cu.usbmodem411) # Default Port, when not specified
3
3
 
4
4
  #====================================================================#
5
5
  # BlinkCustomizedForTest
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_sketch_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadatoshi Takahashi