arduino_sketch_builder 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f05d76dab1e015cd9cea018c97ed10e2ba374efd
4
- data.tar.gz: 0ef6035c27f68418ffafe5fe2b5e0dec358f523b
3
+ metadata.gz: 196ee574d94b524c18b0f26785eabb9303f97ce0
4
+ data.tar.gz: 8ee1dff937b46bd8cd7d5b9cfe20197d5441406c
5
5
  SHA512:
6
- metadata.gz: cf8857390b3841387477f32d59357868e7dcc0c5ace48d0e4feb3d89bd71e4b736c47b9e454650efdceeeb5aaa35e9b071c22775c44214e22e982df0a341aaf9
7
- data.tar.gz: d077308c3527f03a1b47c108f316a77ac529aae07f8a7b9112ca721465def29ef3596ccafacb7168e049b83895916729976232ad12d0fbe666c5bdae0320d17f
6
+ metadata.gz: 271bb1cbef24da3d8d9a9f4c200253e7ecf4ed883e8dd344dc24e7d523f960627d11f7b63c1a5d19cb721e61b9b4fde5d49f43e70e8c68bd6abaea1a84658cf1
7
+ data.tar.gz: 187953360cacb0bf431e4104bf69ba61007b739f66840c2ae42ee945b72fc7be7255659ff66122092d55c645bed3a71fc35e92f6d6784a7529b0510e0ecfa9ad
data/README.md CHANGED
@@ -122,7 +122,24 @@ If Arduino board type and port are different from the default,
122
122
  arduino_sketch_file_path = File.expand_path('~/temp/BlinkCustomized.ino')
123
123
  setup.setup(root_directory, arduino_sketch_file_path, board_type: "diecimila", board_port: "/dev/cu.usbmodem411")
124
124
 
125
- #### Executing cmake commands - compile, make, and make upload
125
+ #### Building and uploading the sketch
126
+
127
+ require "arduino_sketch_builder"
128
+
129
+ main_directory = File.expand_path('~/.arduino_sketches/blink_customized')
130
+ build_directory = File.join(main_directory, "build")
131
+
132
+ # Instantiate ArduinoCmakeBuild with state == :initial (It's a state machine):
133
+ arduino_cmake_build = ArduinoSketchBuilder::ArduinoCmakeBuild.new(main_directory, build_directory)
134
+
135
+ # Build and upload
136
+ # raises error if state at the point of execution is not :initial (i.e. precondition: state == :initial)
137
+ # Success: state == :make_upload_complete
138
+ # Failure: state == :cmake_incomplete, :make_incomplete, or :make_upload_incomplete depending on the step at the time of the failure
139
+ # arduino_cmake_build.message gives message such as error message in case of failure.
140
+ state = arduino_cmake_build.build_and_upload
141
+
142
+ #### (Optional: individual steps for "Building and uploading the sketch" above): Executing cmake commands - compile, make, and make upload
126
143
 
127
144
  require "arduino_sketch_builder"
128
145
 
@@ -25,6 +25,14 @@ class ArduinoSketchBuilder::ArduinoCmakeBuild
25
25
  @state.message
26
26
  end
27
27
 
28
+ def build_and_upload
29
+ self.cmake
30
+ return self.state unless self.state == :cmake_complete
31
+ self.make
32
+ return self.state unless self.state == :make_complete
33
+ self.make_upload
34
+ end
35
+
28
36
  [:cmake, :make, :make_upload].each_with_index do |method_name, index|
29
37
 
30
38
  define_method(method_name) do
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'active_support/core_ext/string/inflections'
2
3
 
3
4
  class ArduinoSketchBuilder::Setup
@@ -1,3 +1,3 @@
1
1
  module ArduinoSketchBuilder
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -102,4 +102,23 @@ describe ArduinoSketchBuilder::ArduinoCmakeBuild do
102
102
 
103
103
  end
104
104
 
105
+ context "one method to do cmake, make and make upload" do
106
+
107
+ it "should execute cmake, make and make upload" do
108
+
109
+ @arduino_cmake_build.state.should == :initial
110
+ File.exists?(File.join(BUILD_DIRECTORY, "Makefile")).should be_false
111
+ File.exists?(File.join(BUILD_DIRECTORY, "src", "blink_customized_for_test.hex")).should be_false
112
+
113
+ @arduino_cmake_build.build_and_upload.should == :make_upload_complete
114
+
115
+ @arduino_cmake_build.state.should == :make_upload_complete
116
+
117
+ File.exists?(File.join(BUILD_DIRECTORY, "Makefile")).should be_true
118
+ File.exists?(File.join(BUILD_DIRECTORY, "src", "blink_customized_for_test.hex")).should be_true
119
+
120
+ end
121
+
122
+ end
123
+
105
124
  end
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadatoshi Takahashi